@fses/workbench-app 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WORKBENCH-CLOSURE.json +80 -0
- package/node_modules/@byteluck/agentic-protocol/LICENSE +9 -0
- package/node_modules/@byteluck/agentic-protocol/README.md +74 -0
- package/node_modules/@byteluck/agentic-protocol/dist/index.d.ts +1623 -0
- package/node_modules/@byteluck/agentic-protocol/dist/index.mjs +3380 -0
- package/node_modules/@byteluck/agentic-protocol/package.json +37 -0
- package/node_modules/@byteluck/workbench-skill-contracts/LICENSE +9 -0
- package/node_modules/@byteluck/workbench-skill-contracts/dist/index.d.ts +234 -0
- package/node_modules/@byteluck/workbench-skill-contracts/dist/index.mjs +394 -0
- package/node_modules/@byteluck/workbench-skill-contracts/package.json +37 -0
- package/node_modules/@fses/ai-chat/LICENSE +9 -0
- package/node_modules/@fses/ai-chat/README.md +320 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/data.d.ts +12 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/from-markdown.d.ts +11 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/from-tool.d.ts +8 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/options.d.ts +4 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/trace.d.ts +19 -0
- package/node_modules/@fses/ai-chat/dist/chart-card/types.d.ts +133 -0
- package/node_modules/@fses/ai-chat/dist/components/CardRecommendationDeferredDraft.vue.d.ts +13 -0
- package/node_modules/@fses/ai-chat/dist/components/CardRecommendationDraft.vue.d.ts +18 -0
- package/node_modules/@fses/ai-chat/dist/components/ChartCardRenderer.vue.d.ts +11 -0
- package/node_modules/@fses/ai-chat/dist/components/ChatMessageItem.vue.d.ts +76 -0
- package/node_modules/@fses/ai-chat/dist/components/ChatMessageList.vue.d.ts +79 -0
- package/node_modules/@fses/ai-chat/dist/components/ChatSender.vue.d.ts +98 -0
- package/node_modules/@fses/ai-chat/dist/components/CollapsedToolActivity.vue.d.ts +9 -0
- package/node_modules/@fses/ai-chat/dist/components/ContextUsageRing.vue.d.ts +12 -0
- package/node_modules/@fses/ai-chat/dist/components/EChartsView.vue.d.ts +6 -0
- package/node_modules/@fses/ai-chat/dist/components/FsesAiChat.vue.d.ts +306 -0
- package/node_modules/@fses/ai-chat/dist/components/PlanDraftCard.vue.d.ts +19 -0
- package/node_modules/@fses/ai-chat/dist/components/ShellExecPanel.vue.d.ts +6 -0
- package/node_modules/@fses/ai-chat/dist/components/TaskTodoPlanBar.vue.d.ts +6 -0
- package/node_modules/@fses/ai-chat/dist/components/ThinkingShimmer.vue.d.ts +6 -0
- package/node_modules/@fses/ai-chat/dist/composables/context-usage.d.ts +11 -0
- package/node_modules/@fses/ai-chat/dist/composables/types.d.ts +465 -0
- package/node_modules/@fses/ai-chat/dist/composables/useChat.d.ts +2 -0
- package/node_modules/@fses/ai-chat/dist/composables/useSystemEChartsIcon.d.ts +11 -0
- package/node_modules/@fses/ai-chat/dist/fses-ai-chat.js +11408 -0
- package/node_modules/@fses/ai-chat/dist/fses-ai-chat.umd.cjs +25 -0
- package/node_modules/@fses/ai-chat/dist/index.d.ts +17 -0
- package/node_modules/@fses/ai-chat/dist/plugin.d.ts +8 -0
- package/node_modules/@fses/ai-chat/dist/style.css +1 -0
- package/node_modules/@fses/ai-chat/dist/utils/assistant-markdown.d.ts +11 -0
- package/node_modules/@fses/ai-chat/dist/utils/attachment-upload.d.ts +22 -0
- package/node_modules/@fses/ai-chat/dist/utils/card-recommendation-config-summary.d.ts +86 -0
- package/node_modules/@fses/ai-chat/dist/utils/card-recommendation-field-label.d.ts +24 -0
- package/node_modules/@fses/ai-chat/dist/utils/card-recommendation-source.d.ts +18 -0
- package/node_modules/@fses/ai-chat/dist/utils/card-recommendation-title-source.d.ts +12 -0
- package/node_modules/@fses/ai-chat/dist/utils/chart-card-visibility.d.ts +24 -0
- package/node_modules/@fses/ai-chat/dist/utils/derived-process-labels.d.ts +13 -0
- package/node_modules/@fses/ai-chat/dist/utils/echarts-recommendation-icon.d.ts +36 -0
- package/node_modules/@fses/ai-chat/dist/utils/group-messages.d.ts +30 -0
- package/node_modules/@fses/ai-chat/dist/utils/status-activity.d.ts +48 -0
- package/node_modules/@fses/ai-chat/dist/utils/system-echarts-template-icons.generated.d.ts +305 -0
- package/node_modules/@fses/ai-chat/dist/utils/system-echarts-template.d.ts +20 -0
- package/node_modules/@fses/ai-chat/dist/utils/task-todo-plan.d.ts +40 -0
- package/node_modules/@fses/ai-chat/dist/utils/workbench-echarts-theme.d.ts +35 -0
- package/node_modules/@fses/ai-chat/package.json +81 -0
- package/node_modules/@fses/workbench-card/LICENSE +9 -0
- package/node_modules/@fses/workbench-card/README.md +81 -0
- package/node_modules/@fses/workbench-card/dist/chart/index.d.ts +8 -0
- package/node_modules/@fses/workbench-card/dist/fses-workbench-card-echarts-protocol.js +2230 -0
- package/node_modules/@fses/workbench-card/dist/fses-workbench-card-renderers.js +33731 -0
- package/node_modules/@fses/workbench-card/dist/fses-workbench-card.js +21238 -0
- package/node_modules/@fses/workbench-card/dist/fses-workbench-card.umd.cjs +1 -0
- package/node_modules/@fses/workbench-card/dist/index.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/registry/cardRegistry.d.ts +50 -0
- package/node_modules/@fses/workbench-card/dist/registry/compositeCardPatterns.d.ts +39 -0
- package/node_modules/@fses/workbench-card/dist/registry/echartsTemplateCategories.d.ts +20 -0
- package/node_modules/@fses/workbench-card/dist/registry/echartsTemplateRegistry.d.ts +1158 -0
- package/node_modules/@fses/workbench-card/dist/registry/echartsTemplateRegistry.generated.d.ts +1141 -0
- package/node_modules/@fses/workbench-card/dist/registry/echartsTemplateTypes.d.ts +76 -0
- package/node_modules/@fses/workbench-card/dist/registry/index.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/WorkbenchBlockRenderer.vue.d.ts +55 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/ChartRegistry.vue.d.ts +22 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/EChartsProtocolRenderer.vue.d.ts +34 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/chartRendererRegistry.d.ts +219 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/chartResponsiveLayout.d.ts +47 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/dynamicEchartOption.d.ts +30 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/adapter.d.ts +73 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/composite.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/configOnly.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/geo.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/graphic.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/layout.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/network.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/scene3D.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/series.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/table.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/timeline.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/transition.converter.d.ts +11 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/tree.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/converters/tuple.converter.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/index.d.ts +9 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/merger.d.ts +16 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echarts-protocol/types.d.ts +447 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echartsRuntimeInteractions.d.ts +30 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echartsTitle.d.ts +13 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/echartsTooltipPortal.d.ts +12 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/types.d.ts +47 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/useEchart.d.ts +29 -0
- package/node_modules/@fses/workbench-card/dist/renderers/chart/workbenchChartTheme.d.ts +36 -0
- package/node_modules/@fses/workbench-card/dist/renderers/custom-canvas/canvasLayoutBindings.d.ts +86 -0
- package/node_modules/@fses/workbench-card/dist/renderers/hostBridge.d.ts +61 -0
- package/node_modules/@fses/workbench-card/dist/renderers/index.d.ts +17 -0
- package/node_modules/@fses/workbench-card/dist/renderers/native/nativeBindings.d.ts +145 -0
- package/node_modules/@fses/workbench-card/dist/renderers/nested/nestedBlockBindings.d.ts +107 -0
- package/node_modules/@fses/workbench-card/dist/renderers/quickLinkDisplay.d.ts +24 -0
- package/node_modules/@fses/workbench-card/dist/renderers/reference-composite/referenceCompositeBindings.d.ts +171 -0
- package/node_modules/@fses/workbench-card/dist/renderers/reference-composite/referenceRiskAndStrategyBindings.d.ts +91 -0
- package/node_modules/@fses/workbench-card/dist/renderers/resizableTable.d.ts +51 -0
- package/node_modules/@fses/workbench-card/dist/renderers/style.css +1 -0
- package/node_modules/@fses/workbench-card/dist/renderers/tableDisplay.d.ts +25 -0
- package/node_modules/@fses/workbench-card/dist/renderers/useWorkbenchBlockRendererBindings.d.ts +580 -0
- package/node_modules/@fses/workbench-card/dist/shell/workbenchVisualShell.d.ts +48 -0
- package/node_modules/@fses/workbench-card/dist/style.css +1 -0
- package/node_modules/@fses/workbench-card/dist/types/block.d.ts +2002 -0
- package/node_modules/@fses/workbench-card/dist/types/canvas.d.ts +25 -0
- package/node_modules/@fses/workbench-card/dist/types/echartsProtocol.d.ts +445 -0
- package/node_modules/@fses/workbench-card/dist/types/index.d.ts +10 -0
- package/node_modules/@fses/workbench-card/dist/types/registry.d.ts +7 -0
- package/node_modules/@fses/workbench-card/dist/types/runtime.d.ts +34 -0
- package/node_modules/@fses/workbench-card/package.json +82 -0
- package/node_modules/@fses/workbench-card/src/chart/index.ts +8 -0
- package/node_modules/@fses/workbench-card/src/index.ts +13 -0
- package/node_modules/@fses/workbench-card/src/registry/cardRegistry.ts +476 -0
- package/node_modules/@fses/workbench-card/src/registry/compositeCardPatterns.ts +206 -0
- package/node_modules/@fses/workbench-card/src/registry/echartsTemplateCategories.ts +74 -0
- package/node_modules/@fses/workbench-card/src/registry/echartsTemplateRegistry.generated.ts +19951 -0
- package/node_modules/@fses/workbench-card/src/registry/echartsTemplateRegistry.ts +32 -0
- package/node_modules/@fses/workbench-card/src/registry/echartsTemplateTypes.ts +83 -0
- package/node_modules/@fses/workbench-card/src/registry/index.ts +10 -0
- package/node_modules/@fses/workbench-card/src/renderers/WorkbenchBlockRenderer.vue +2728 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/ChartRegistry.vue +221 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/EChartsProtocolRenderer.vue +304 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/chartRendererRegistry.ts +311 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/chartResponsiveLayout.ts +172 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/dynamicEchartOption.ts +127 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/adapter.ts +1349 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/composite.converter.ts +71 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/configOnly.converter.ts +45 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/geo.converter.ts +97 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/graphic.converter.ts +59 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/layout.converter.ts +53 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/network.converter.ts +82 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/scene3D.converter.ts +73 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/series.converter.ts +795 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/table.converter.ts +195 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/timeline.converter.ts +62 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/transition.converter.ts +58 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/tree.converter.ts +75 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/converters/tuple.converter.ts +112 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/index.ts +10 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/merger.ts +109 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echarts-protocol/types.ts +515 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echartsRuntimeInteractions.ts +450 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echartsTitle.ts +94 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/echartsTooltipPortal.ts +140 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/types.ts +53 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/useEchart.ts +1820 -0
- package/node_modules/@fses/workbench-card/src/renderers/chart/workbenchChartTheme.ts +240 -0
- package/node_modules/@fses/workbench-card/src/renderers/custom-canvas/canvasLayoutBindings.ts +660 -0
- package/node_modules/@fses/workbench-card/src/renderers/hostBridge.ts +74 -0
- package/node_modules/@fses/workbench-card/src/renderers/index.ts +25 -0
- package/node_modules/@fses/workbench-card/src/renderers/native/nativeBindings.ts +1081 -0
- package/node_modules/@fses/workbench-card/src/renderers/nested/nestedBlockBindings.ts +1349 -0
- package/node_modules/@fses/workbench-card/src/renderers/quickLinkDisplay.ts +53 -0
- package/node_modules/@fses/workbench-card/src/renderers/reference-composite/referenceCompositeBindings.ts +3205 -0
- package/node_modules/@fses/workbench-card/src/renderers/reference-composite/referenceRiskAndStrategyBindings.ts +1004 -0
- package/node_modules/@fses/workbench-card/src/renderers/resizableTable.ts +136 -0
- package/node_modules/@fses/workbench-card/src/renderers/tableDisplay.ts +140 -0
- package/node_modules/@fses/workbench-card/src/renderers/useWorkbenchBlockRendererBindings.ts +3192 -0
- package/node_modules/@fses/workbench-card/src/shell/workbenchVisualShell.ts +228 -0
- package/node_modules/@fses/workbench-card/src/styles/workbench-card.css +343 -0
- package/node_modules/@fses/workbench-card/src/types/block.ts +2487 -0
- package/node_modules/@fses/workbench-card/src/types/canvas.ts +30 -0
- package/node_modules/@fses/workbench-card/src/types/echartsProtocol.ts +513 -0
- package/node_modules/@fses/workbench-card/src/types/index.ts +10 -0
- package/node_modules/@fses/workbench-card/src/types/registry.ts +17 -0
- package/node_modules/@fses/workbench-card/src/types/runtime.ts +31 -0
- package/node_modules/dompurify/LICENSE +568 -0
- package/node_modules/dompurify/README.md +523 -0
- package/node_modules/dompurify/dist/purify.cjs.d.ts +451 -0
- package/node_modules/dompurify/dist/purify.cjs.js +1472 -0
- package/node_modules/dompurify/dist/purify.cjs.js.map +1 -0
- package/node_modules/dompurify/dist/purify.es.d.mts +448 -0
- package/node_modules/dompurify/dist/purify.es.mjs +1470 -0
- package/node_modules/dompurify/dist/purify.es.mjs.map +1 -0
- package/node_modules/dompurify/dist/purify.js +1478 -0
- package/node_modules/dompurify/dist/purify.js.map +1 -0
- package/node_modules/dompurify/dist/purify.min.js +3 -0
- package/node_modules/dompurify/dist/purify.min.js.map +1 -0
- package/node_modules/dompurify/package.json +168 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +208 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/package.json +118 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +56 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +257 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5136 -0
- package/node_modules/zod/src/v4/classic/checks.ts +30 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +66 -0
- package/node_modules/zod/src/v4/classic/errors.ts +75 -0
- package/node_modules/zod/src/v4/classic/external.ts +50 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +33 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2054 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +63 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +352 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +296 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +313 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +619 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +527 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +91 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +268 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +829 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +171 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +108 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +92 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +196 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +247 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +563 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +123 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +147 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +37 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +298 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +342 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +356 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +881 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +758 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +250 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +94 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1594 -0
- package/node_modules/zod/src/v4/core/checks.ts +1283 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +134 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +424 -0
- package/node_modules/zod/src/v4/core/function.ts +176 -0
- package/node_modules/zod/src/v4/core/index.ts +15 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +143 -0
- package/node_modules/zod/src/v4/core/parse.ts +94 -0
- package/node_modules/zod/src/v4/core/regexes.ts +135 -0
- package/node_modules/zod/src/v4/core/registries.ts +96 -0
- package/node_modules/zod/src/v4/core/schemas.ts +3842 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +64 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +977 -0
- package/node_modules/zod/src/v4/core/util.ts +775 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +125 -0
- package/node_modules/zod/src/v4/locales/az.ts +121 -0
- package/node_modules/zod/src/v4/locales/be.ts +184 -0
- package/node_modules/zod/src/v4/locales/ca.ts +127 -0
- package/node_modules/zod/src/v4/locales/cs.ts +142 -0
- package/node_modules/zod/src/v4/locales/de.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +127 -0
- package/node_modules/zod/src/v4/locales/eo.ts +125 -0
- package/node_modules/zod/src/v4/locales/es.ts +125 -0
- package/node_modules/zod/src/v4/locales/fa.ts +134 -0
- package/node_modules/zod/src/v4/locales/fi.ts +131 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +126 -0
- package/node_modules/zod/src/v4/locales/fr.ts +124 -0
- package/node_modules/zod/src/v4/locales/he.ts +125 -0
- package/node_modules/zod/src/v4/locales/hu.ts +126 -0
- package/node_modules/zod/src/v4/locales/id.ts +125 -0
- package/node_modules/zod/src/v4/locales/index.ts +39 -0
- package/node_modules/zod/src/v4/locales/it.ts +125 -0
- package/node_modules/zod/src/v4/locales/ja.ts +122 -0
- package/node_modules/zod/src/v4/locales/kh.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +131 -0
- package/node_modules/zod/src/v4/locales/mk.ts +127 -0
- package/node_modules/zod/src/v4/locales/ms.ts +124 -0
- package/node_modules/zod/src/v4/locales/nl.ts +126 -0
- package/node_modules/zod/src/v4/locales/no.ts +124 -0
- package/node_modules/zod/src/v4/locales/ota.ts +125 -0
- package/node_modules/zod/src/v4/locales/pl.ts +126 -0
- package/node_modules/zod/src/v4/locales/ps.ts +133 -0
- package/node_modules/zod/src/v4/locales/pt.ts +123 -0
- package/node_modules/zod/src/v4/locales/ru.ts +184 -0
- package/node_modules/zod/src/v4/locales/sl.ts +126 -0
- package/node_modules/zod/src/v4/locales/sv.ts +127 -0
- package/node_modules/zod/src/v4/locales/ta.ts +125 -0
- package/node_modules/zod/src/v4/locales/th.ts +126 -0
- package/node_modules/zod/src/v4/locales/tr.ts +121 -0
- package/node_modules/zod/src/v4/locales/ua.ts +126 -0
- package/node_modules/zod/src/v4/locales/ur.ts +126 -0
- package/node_modules/zod/src/v4/locales/vi.ts +125 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +123 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +125 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +22 -0
- package/node_modules/zod/src/v4/mini/external.ts +40 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +62 -0
- package/node_modules/zod/src/v4/mini/parse.ts +1 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1579 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +51 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +871 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +185 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +299 -0
- package/node_modules/zod/src/v4-mini/index.ts +1 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +111 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3775 -0
- package/node_modules/zod/v3/types.d.cts +1031 -0
- package/node_modules/zod/v3/types.d.ts +1031 -0
- package/node_modules/zod/v3/types.js +3693 -0
- package/node_modules/zod/v4/classic/checks.cjs +32 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +57 -0
- package/node_modules/zod/v4/classic/compat.d.cts +46 -0
- package/node_modules/zod/v4/classic/compat.d.ts +46 -0
- package/node_modules/zod/v4/classic/compat.js +27 -0
- package/node_modules/zod/v4/classic/errors.cjs +67 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +41 -0
- package/node_modules/zod/v4/classic/external.cjs +70 -0
- package/node_modules/zod/v4/classic/external.d.cts +13 -0
- package/node_modules/zod/v4/classic/external.d.ts +13 -0
- package/node_modules/zod/v4/classic/external.js +18 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/parse.cjs +32 -0
- package/node_modules/zod/v4/classic/parse.d.cts +23 -0
- package/node_modules/zod/v4/classic/parse.d.ts +23 -0
- package/node_modules/zod/v4/classic/parse.js +6 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1109 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +630 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +630 -0
- package/node_modules/zod/v4/classic/schemas.js +1006 -0
- package/node_modules/zod/v4/core/api.cjs +1039 -0
- package/node_modules/zod/v4/core/api.d.cts +284 -0
- package/node_modules/zod/v4/core/api.d.ts +284 -0
- package/node_modules/zod/v4/core/api.js +906 -0
- package/node_modules/zod/v4/core/checks.cjs +591 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +565 -0
- package/node_modules/zod/v4/core/core.cjs +67 -0
- package/node_modules/zod/v4/core/core.d.cts +49 -0
- package/node_modules/zod/v4/core/core.d.ts +49 -0
- package/node_modules/zod/v4/core/core.js +61 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +226 -0
- package/node_modules/zod/v4/core/errors.d.cts +208 -0
- package/node_modules/zod/v4/core/errors.d.ts +208 -0
- package/node_modules/zod/v4/core/errors.js +195 -0
- package/node_modules/zod/v4/core/function.cjs +102 -0
- package/node_modules/zod/v4/core/function.d.cts +52 -0
- package/node_modules/zod/v4/core/function.d.ts +52 -0
- package/node_modules/zod/v4/core/function.js +75 -0
- package/node_modules/zod/v4/core/index.cjs +44 -0
- package/node_modules/zod/v4/core/index.d.cts +15 -0
- package/node_modules/zod/v4/core/index.d.ts +15 -0
- package/node_modules/zod/v4/core/index.js +15 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +87 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +87 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/parse.cjs +87 -0
- package/node_modules/zod/v4/core/parse.d.cts +25 -0
- package/node_modules/zod/v4/core/parse.d.ts +25 -0
- package/node_modules/zod/v4/core/parse.js +57 -0
- package/node_modules/zod/v4/core/regexes.cjs +103 -0
- package/node_modules/zod/v4/core/regexes.d.cts +62 -0
- package/node_modules/zod/v4/core/regexes.d.ts +62 -0
- package/node_modules/zod/v4/core/regexes.js +95 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +1748 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1041 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1041 -0
- package/node_modules/zod/v4/core/schemas.js +1717 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +55 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +55 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +854 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/to-json-schema.js +849 -0
- package/node_modules/zod/v4/core/util.cjs +539 -0
- package/node_modules/zod/v4/core/util.d.cts +183 -0
- package/node_modules/zod/v4/core/util.d.ts +183 -0
- package/node_modules/zod/v4/core/util.js +493 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +142 -0
- package/node_modules/zod/v4/locales/ar.d.cts +4 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +116 -0
- package/node_modules/zod/v4/locales/az.cjs +141 -0
- package/node_modules/zod/v4/locales/az.d.cts +4 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +115 -0
- package/node_modules/zod/v4/locales/be.cjs +190 -0
- package/node_modules/zod/v4/locales/be.d.cts +4 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +164 -0
- package/node_modules/zod/v4/locales/ca.cjs +144 -0
- package/node_modules/zod/v4/locales/ca.d.cts +4 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +118 -0
- package/node_modules/zod/v4/locales/cs.cjs +161 -0
- package/node_modules/zod/v4/locales/cs.d.cts +4 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +135 -0
- package/node_modules/zod/v4/locales/de.cjs +142 -0
- package/node_modules/zod/v4/locales/de.d.cts +4 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +116 -0
- package/node_modules/zod/v4/locales/en.cjs +145 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +5 -0
- package/node_modules/zod/v4/locales/en.js +117 -0
- package/node_modules/zod/v4/locales/eo.cjs +144 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +5 -0
- package/node_modules/zod/v4/locales/eo.js +116 -0
- package/node_modules/zod/v4/locales/es.cjs +143 -0
- package/node_modules/zod/v4/locales/es.d.cts +4 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +117 -0
- package/node_modules/zod/v4/locales/fa.cjs +148 -0
- package/node_modules/zod/v4/locales/fa.d.cts +4 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +122 -0
- package/node_modules/zod/v4/locales/fi.cjs +148 -0
- package/node_modules/zod/v4/locales/fi.d.cts +4 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +122 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +143 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +117 -0
- package/node_modules/zod/v4/locales/fr.cjs +142 -0
- package/node_modules/zod/v4/locales/fr.d.cts +4 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +116 -0
- package/node_modules/zod/v4/locales/he.cjs +143 -0
- package/node_modules/zod/v4/locales/he.d.cts +4 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +117 -0
- package/node_modules/zod/v4/locales/hu.cjs +143 -0
- package/node_modules/zod/v4/locales/hu.d.cts +4 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +117 -0
- package/node_modules/zod/v4/locales/id.cjs +142 -0
- package/node_modules/zod/v4/locales/id.d.cts +4 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +116 -0
- package/node_modules/zod/v4/locales/index.cjs +84 -0
- package/node_modules/zod/v4/locales/index.d.cts +39 -0
- package/node_modules/zod/v4/locales/index.d.ts +39 -0
- package/node_modules/zod/v4/locales/index.js +39 -0
- package/node_modules/zod/v4/locales/it.cjs +143 -0
- package/node_modules/zod/v4/locales/it.d.cts +4 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +117 -0
- package/node_modules/zod/v4/locales/ja.cjs +141 -0
- package/node_modules/zod/v4/locales/ja.d.cts +4 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +115 -0
- package/node_modules/zod/v4/locales/kh.cjs +143 -0
- package/node_modules/zod/v4/locales/kh.d.cts +4 -0
- package/node_modules/zod/v4/locales/kh.d.ts +4 -0
- package/node_modules/zod/v4/locales/kh.js +117 -0
- package/node_modules/zod/v4/locales/ko.cjs +147 -0
- package/node_modules/zod/v4/locales/ko.d.cts +4 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +121 -0
- package/node_modules/zod/v4/locales/mk.cjs +144 -0
- package/node_modules/zod/v4/locales/mk.d.cts +4 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +118 -0
- package/node_modules/zod/v4/locales/ms.cjs +142 -0
- package/node_modules/zod/v4/locales/ms.d.cts +4 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +116 -0
- package/node_modules/zod/v4/locales/nl.cjs +143 -0
- package/node_modules/zod/v4/locales/nl.d.cts +4 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +117 -0
- package/node_modules/zod/v4/locales/no.cjs +142 -0
- package/node_modules/zod/v4/locales/no.d.cts +4 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +116 -0
- package/node_modules/zod/v4/locales/ota.cjs +143 -0
- package/node_modules/zod/v4/locales/ota.d.cts +4 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +117 -0
- package/node_modules/zod/v4/locales/pl.cjs +143 -0
- package/node_modules/zod/v4/locales/pl.d.cts +4 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +117 -0
- package/node_modules/zod/v4/locales/ps.cjs +148 -0
- package/node_modules/zod/v4/locales/ps.d.cts +4 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +122 -0
- package/node_modules/zod/v4/locales/pt.cjs +142 -0
- package/node_modules/zod/v4/locales/pt.d.cts +4 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +116 -0
- package/node_modules/zod/v4/locales/ru.cjs +190 -0
- package/node_modules/zod/v4/locales/ru.d.cts +4 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +164 -0
- package/node_modules/zod/v4/locales/sl.cjs +143 -0
- package/node_modules/zod/v4/locales/sl.d.cts +4 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +117 -0
- package/node_modules/zod/v4/locales/sv.cjs +144 -0
- package/node_modules/zod/v4/locales/sv.d.cts +4 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +118 -0
- package/node_modules/zod/v4/locales/ta.cjs +143 -0
- package/node_modules/zod/v4/locales/ta.d.cts +4 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +143 -0
- package/node_modules/zod/v4/locales/th.d.cts +4 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +117 -0
- package/node_modules/zod/v4/locales/tr.cjs +143 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +5 -0
- package/node_modules/zod/v4/locales/tr.js +115 -0
- package/node_modules/zod/v4/locales/ua.cjs +143 -0
- package/node_modules/zod/v4/locales/ua.d.cts +4 -0
- package/node_modules/zod/v4/locales/ua.d.ts +4 -0
- package/node_modules/zod/v4/locales/ua.js +117 -0
- package/node_modules/zod/v4/locales/ur.cjs +143 -0
- package/node_modules/zod/v4/locales/ur.d.cts +4 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +117 -0
- package/node_modules/zod/v4/locales/vi.cjs +142 -0
- package/node_modules/zod/v4/locales/vi.d.cts +4 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +116 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +142 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +116 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +143 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +117 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +47 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +17 -0
- package/node_modules/zod/v4/mini/external.cjs +62 -0
- package/node_modules/zod/v4/mini/external.d.cts +11 -0
- package/node_modules/zod/v4/mini/external.d.ts +11 -0
- package/node_modules/zod/v4/mini/external.js +13 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +60 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +30 -0
- package/node_modules/zod/v4/mini/parse.cjs +8 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +839 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +356 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +356 -0
- package/node_modules/zod/v4/mini/schemas.js +732 -0
- package/node_modules/zod/v4-mini/index.cjs +17 -0
- package/node_modules/zod/v4-mini/index.d.cts +1 -0
- package/node_modules/zod/v4-mini/index.d.ts +1 -0
- package/node_modules/zod/v4-mini/index.js +1 -0
- package/package.json +99 -104
|
@@ -0,0 +1,1349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ECharts 协议适配器 — 将协议配置和数据载荷转换为 ECharts option 的主入口类
|
|
3
|
+
* @author seadon
|
|
4
|
+
* @created 2026-05-05
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { EChartsOption } from 'echarts';
|
|
8
|
+
import { isProxy, toRaw } from 'vue';
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
ProtocolConfigPayload,
|
|
12
|
+
ProtocolConverter,
|
|
13
|
+
ProtocolDataPayload,
|
|
14
|
+
ProtocolType,
|
|
15
|
+
TableDataPayload,
|
|
16
|
+
} from './types';
|
|
17
|
+
import { seriesConverter } from './converters/series.converter';
|
|
18
|
+
import { tableConverter } from './converters/table.converter';
|
|
19
|
+
import { tupleConverter } from './converters/tuple.converter';
|
|
20
|
+
import { treeConverter } from './converters/tree.converter';
|
|
21
|
+
import { networkConverter } from './converters/network.converter';
|
|
22
|
+
import { geoConverter } from './converters/geo.converter';
|
|
23
|
+
import { scene3DConverter } from './converters/scene3D.converter';
|
|
24
|
+
import { timelineConverter } from './converters/timeline.converter';
|
|
25
|
+
import { transitionConverter } from './converters/transition.converter';
|
|
26
|
+
import { graphicConverter } from './converters/graphic.converter';
|
|
27
|
+
import { layoutConverter } from './converters/layout.converter';
|
|
28
|
+
import { compositeConverter } from './converters/composite.converter';
|
|
29
|
+
import { configOnlyConverter } from './converters/configOnly.converter';
|
|
30
|
+
import { deepMergeOption } from './merger';
|
|
31
|
+
|
|
32
|
+
const OFFICIAL_ECHARTS_EXAMPLES_ROOT = 'https://echarts.apache.org/examples';
|
|
33
|
+
const GL_REMOTE_TEXTURE_KEYS = new Set([
|
|
34
|
+
'baseTexture',
|
|
35
|
+
'heightTexture',
|
|
36
|
+
'texture',
|
|
37
|
+
'normalTexture',
|
|
38
|
+
'detailTexture',
|
|
39
|
+
'displacementTexture',
|
|
40
|
+
'roughnessTexture',
|
|
41
|
+
'metalnessTexture',
|
|
42
|
+
'emissionTexture',
|
|
43
|
+
'matcap',
|
|
44
|
+
]);
|
|
45
|
+
const GL_GLOBE_FALLBACK_COLOR = '#103b5d';
|
|
46
|
+
const GL_ENVIRONMENT_FALLBACK_COLOR = '#000';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 克隆 ECharts option 片段,兼容 Vue 响应式代理对象。
|
|
50
|
+
* @param value - 待克隆的 option 值
|
|
51
|
+
* @param seen - 循环引用缓存,避免递归复制时重复遍历
|
|
52
|
+
* @returns 已解除响应式代理的 option 值副本
|
|
53
|
+
*/
|
|
54
|
+
function cloneOptionValue<T>(value: T, seen = new WeakMap<object, unknown>()): T {
|
|
55
|
+
const rawValue = isProxy(value) ? toRaw(value) : value;
|
|
56
|
+
|
|
57
|
+
if (!rawValue || typeof rawValue !== 'object') return rawValue;
|
|
58
|
+
|
|
59
|
+
if (seen.has(rawValue)) return seen.get(rawValue) as T;
|
|
60
|
+
|
|
61
|
+
if (Array.isArray(rawValue)) {
|
|
62
|
+
const result: unknown[] = [];
|
|
63
|
+
seen.set(rawValue, result);
|
|
64
|
+
rawValue.forEach((item, index) => {
|
|
65
|
+
result[index] = cloneOptionValue(item, seen);
|
|
66
|
+
});
|
|
67
|
+
return result as T;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (rawValue instanceof Date) {
|
|
71
|
+
return new Date(rawValue.getTime()) as T;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (rawValue instanceof RegExp) {
|
|
75
|
+
return new RegExp(rawValue.source, rawValue.flags) as T;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const result: Record<string, unknown> = {};
|
|
79
|
+
seen.set(rawValue, result);
|
|
80
|
+
Object.entries(rawValue as Record<string, unknown>).forEach(([key, item]) => {
|
|
81
|
+
result[key] = cloneOptionValue(item, seen);
|
|
82
|
+
});
|
|
83
|
+
return result as T;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 判断给定值是否为普通对象。
|
|
88
|
+
* @param value - 待判断的值
|
|
89
|
+
* @returns 普通对象返回 true
|
|
90
|
+
*/
|
|
91
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
92
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 判断 option 字符串是否指向 ECharts 官方 GL 示例资源。
|
|
97
|
+
* @param value - option 字符串值
|
|
98
|
+
* @returns 指向官方远程 GL 资源时返回 true
|
|
99
|
+
*/
|
|
100
|
+
function isOfficialRemoteGlAssetUrl(value: string): boolean {
|
|
101
|
+
return value.startsWith(`${OFFICIAL_ECHARTS_EXAMPLES_ROOT}/data-gl/asset/`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 读取 ECharts matrix 轴节点的叶子标签。
|
|
106
|
+
* @param value - matrix.x.data 或 matrix.y.data 中的节点数组
|
|
107
|
+
* @returns 叶子标签列表
|
|
108
|
+
*/
|
|
109
|
+
function matrixAxisLabels(value: unknown): string[] {
|
|
110
|
+
if (!Array.isArray(value)) return [];
|
|
111
|
+
return value.flatMap((item) => {
|
|
112
|
+
if (typeof item === 'string' || typeof item === 'number') return [String(item)];
|
|
113
|
+
if (!isPlainObject(item)) return [];
|
|
114
|
+
if (Array.isArray(item.children)) return matrixAxisLabels(item.children);
|
|
115
|
+
const itemValue = item.value;
|
|
116
|
+
return typeof itemValue === 'string' || typeof itemValue === 'number' ? [String(itemValue)] : [];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 将 matrix 坐标的原始数据点转换为笛卡尔热力图索引坐标。
|
|
122
|
+
* @param value - series.data 候选值
|
|
123
|
+
* @param xLabels - x 轴叶子标签
|
|
124
|
+
* @param yLabels - y 轴叶子标签
|
|
125
|
+
* @returns 转换后的 series.data
|
|
126
|
+
*/
|
|
127
|
+
function downgradeMatrixSeriesData(value: unknown, xLabels: string[], yLabels: string[]): unknown {
|
|
128
|
+
if (!Array.isArray(value)) return value;
|
|
129
|
+
const xIndexByLabel = new Map(xLabels.map((label, index) => [label, index]));
|
|
130
|
+
const yIndexByLabel = new Map(yLabels.map((label, index) => [label, index]));
|
|
131
|
+
|
|
132
|
+
return value.map((item) => {
|
|
133
|
+
if (!Array.isArray(item) || item.length < 2) return item;
|
|
134
|
+
const xLabel = String(item[0] ?? '');
|
|
135
|
+
const yLabel = String(item[1] ?? '');
|
|
136
|
+
return [
|
|
137
|
+
xIndexByLabel.get(xLabel) ?? item[0],
|
|
138
|
+
yIndexByLabel.get(yLabel) ?? item[1],
|
|
139
|
+
...item.slice(2),
|
|
140
|
+
];
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 判断 series 是否声明使用 matrix 坐标系。
|
|
146
|
+
* @param value - 候选 series 配置
|
|
147
|
+
* @returns matrix 坐标系返回 true
|
|
148
|
+
*/
|
|
149
|
+
function isMatrixSeries(value: unknown): value is Record<string, unknown> {
|
|
150
|
+
return isPlainObject(value) && value.coordinateSystem === 'matrix';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 从 transform 配置中读取 transform 类型。
|
|
155
|
+
* @param transform - ECharts dataset transform 配置
|
|
156
|
+
* @returns transform 类型;无法读取时返回空字符串
|
|
157
|
+
*/
|
|
158
|
+
function transformType(transform: unknown): string {
|
|
159
|
+
if (!isPlainObject(transform)) return '';
|
|
160
|
+
const type = transform.type;
|
|
161
|
+
return typeof type === 'string' ? type : '';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 判断 transform 是否依赖当前运行时未注册的外部插件。
|
|
166
|
+
* @param transform - ECharts dataset transform 配置
|
|
167
|
+
* @returns 依赖外部插件返回 true
|
|
168
|
+
*/
|
|
169
|
+
function isUnsupportedExternalTransform(transform: unknown): boolean {
|
|
170
|
+
const type = transformType(transform);
|
|
171
|
+
return type.startsWith('ecStat:') || type.startsWith('ecSimpleTransform:');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 判断 dataset 配置是否包含未注册的外部 transform。
|
|
176
|
+
* @param dataset - ECharts dataset 配置
|
|
177
|
+
* @returns 包含未注册 transform 返回 true
|
|
178
|
+
*/
|
|
179
|
+
function datasetHasUnsupportedTransform(dataset: unknown): boolean {
|
|
180
|
+
if (!isPlainObject(dataset)) return false;
|
|
181
|
+
const transform = dataset.transform;
|
|
182
|
+
if (Array.isArray(transform)) return transform.some(isUnsupportedExternalTransform);
|
|
183
|
+
return isUnsupportedExternalTransform(transform);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 清理 series 中对已移除 dataset transform 的引用。
|
|
188
|
+
* @param value - 候选 series 配置
|
|
189
|
+
* @returns 清理后的 series 配置
|
|
190
|
+
*/
|
|
191
|
+
function sanitizeSeriesDatasetReferences(value: unknown): unknown {
|
|
192
|
+
if (!Array.isArray(value)) return value;
|
|
193
|
+
return value.map((item) => {
|
|
194
|
+
if (!isPlainObject(item)) return item;
|
|
195
|
+
const {
|
|
196
|
+
datasetId: _datasetId,
|
|
197
|
+
datasetIndex: _datasetIndex,
|
|
198
|
+
encode: _encode,
|
|
199
|
+
...rest
|
|
200
|
+
} = item;
|
|
201
|
+
return rest;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 清理没有 renderItem 的 custom series,避免 ECharts 抛出 render required。
|
|
207
|
+
* @param value - 候选 option 片段
|
|
208
|
+
* @returns 清理后的 option 片段
|
|
209
|
+
*/
|
|
210
|
+
function sanitizeCustomSeriesWithoutRenderer(value: unknown): unknown {
|
|
211
|
+
if (Array.isArray(value)) {
|
|
212
|
+
return value.map((item) => sanitizeCustomSeriesWithoutRenderer(item));
|
|
213
|
+
}
|
|
214
|
+
if (!isPlainObject(value)) return value;
|
|
215
|
+
|
|
216
|
+
const result: Record<string, unknown> = {};
|
|
217
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
218
|
+
result[key] = sanitizeCustomSeriesWithoutRenderer(item);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (result.type === 'custom' && !result.renderItem && !result.render) {
|
|
222
|
+
result.type = 'scatter';
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 从 table 协议数据中读取第一组二维数值源数据。
|
|
230
|
+
* @param data - 协议数据载荷
|
|
231
|
+
* @returns 二维数值数组
|
|
232
|
+
*/
|
|
233
|
+
/**
|
|
234
|
+
* Removes empty inline data arrays from dataset-driven series patches.
|
|
235
|
+
* @param value - Candidate series option field.
|
|
236
|
+
* @returns Series option field without empty inline data arrays.
|
|
237
|
+
*/
|
|
238
|
+
function sanitizeEmptyDatasetDrivenSeriesData(value: unknown): unknown {
|
|
239
|
+
if (!Array.isArray(value)) return value;
|
|
240
|
+
return value.map((item) => {
|
|
241
|
+
if (!isPlainObject(item)) return item;
|
|
242
|
+
if (!Array.isArray(item.data) || item.data.length > 0) return item;
|
|
243
|
+
const { data: _data, ...rest } = item;
|
|
244
|
+
return rest;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function tableNumericSourceRows(data?: ProtocolDataPayload): number[][] {
|
|
249
|
+
if (!data || data.protocolType !== 'table') return [];
|
|
250
|
+
const tableData = data as TableDataPayload;
|
|
251
|
+
const source = tableData.datasets[0]?.source || [];
|
|
252
|
+
return source
|
|
253
|
+
.map((row) => Array.isArray(row) ? [Number(row[0]), Number(row[1])] : [Number.NaN, Number.NaN])
|
|
254
|
+
.filter(([x, y]) => Number.isFinite(x) && Number.isFinite(y));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 从 table 协议中读取第一组数据源,优先使用非空 rows。
|
|
259
|
+
* @param data - 协议数据载荷
|
|
260
|
+
* @returns 第一组 table 数据源
|
|
261
|
+
*/
|
|
262
|
+
function tableSource(data?: ProtocolDataPayload): unknown[] {
|
|
263
|
+
if (!data || data.protocolType !== 'table') return [];
|
|
264
|
+
const firstDataset = (data as TableDataPayload).datasets[0];
|
|
265
|
+
if (!firstDataset) return [];
|
|
266
|
+
return firstDataset.rows?.length ? firstDataset.rows : firstDataset.source;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 从 table 协议中读取维度声明。
|
|
271
|
+
* @param data - 协议数据载荷
|
|
272
|
+
* @returns 维度名数组
|
|
273
|
+
*/
|
|
274
|
+
function tableDimensions(data?: ProtocolDataPayload): string[] {
|
|
275
|
+
if (!data || data.protocolType !== 'table') return [];
|
|
276
|
+
return (data as TableDataPayload).datasets[0]?.dimensions || [];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 解线性方程组,用于多项式最小二乘拟合。
|
|
281
|
+
* @param matrix - 增广矩阵
|
|
282
|
+
* @returns 方程系数;无法求解时返回空数组
|
|
283
|
+
*/
|
|
284
|
+
function solveLinearSystem(matrix: number[][]): number[] {
|
|
285
|
+
const size = matrix.length;
|
|
286
|
+
const rows = matrix.map((row) => [...row]);
|
|
287
|
+
|
|
288
|
+
for (let column = 0; column < size; column += 1) {
|
|
289
|
+
let pivot = column;
|
|
290
|
+
for (let row = column + 1; row < size; row += 1) {
|
|
291
|
+
if (Math.abs(rows[row][column]) > Math.abs(rows[pivot][column])) pivot = row;
|
|
292
|
+
}
|
|
293
|
+
if (Math.abs(rows[pivot][column]) < 1e-12) return [];
|
|
294
|
+
[rows[column], rows[pivot]] = [rows[pivot], rows[column]];
|
|
295
|
+
|
|
296
|
+
const divisor = rows[column][column];
|
|
297
|
+
for (let item = column; item <= size; item += 1) rows[column][item] /= divisor;
|
|
298
|
+
|
|
299
|
+
for (let row = 0; row < size; row += 1) {
|
|
300
|
+
if (row === column) continue;
|
|
301
|
+
const factor = rows[row][column];
|
|
302
|
+
for (let item = column; item <= size; item += 1) {
|
|
303
|
+
rows[row][item] -= factor * rows[column][item];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return rows.map((row) => row[size]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 计算一元线性拟合参数。
|
|
313
|
+
* @param points - 输入点集
|
|
314
|
+
* @returns 斜率和截距
|
|
315
|
+
*/
|
|
316
|
+
function fitLinear(points: number[][]): { slope: number; intercept: number } | null {
|
|
317
|
+
if (points.length < 2) return null;
|
|
318
|
+
const count = points.length;
|
|
319
|
+
const sumX = points.reduce((sum, [x]) => sum + x, 0);
|
|
320
|
+
const sumY = points.reduce((sum, [, y]) => sum + y, 0);
|
|
321
|
+
const sumXX = points.reduce((sum, [x]) => sum + x * x, 0);
|
|
322
|
+
const sumXY = points.reduce((sum, [x, y]) => sum + x * y, 0);
|
|
323
|
+
const denominator = count * sumXX - sumX * sumX;
|
|
324
|
+
if (Math.abs(denominator) < 1e-12) return null;
|
|
325
|
+
const slope = (count * sumXY - sumX * sumY) / denominator;
|
|
326
|
+
const intercept = (sumY - slope * sumX) / count;
|
|
327
|
+
return { slope, intercept };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 计算多项式拟合系数。
|
|
332
|
+
* @param points - 输入点集
|
|
333
|
+
* @param order - 多项式阶数
|
|
334
|
+
* @returns 从常数项开始的多项式系数
|
|
335
|
+
*/
|
|
336
|
+
function fitPolynomial(points: number[][], order: number): number[] {
|
|
337
|
+
const degree = Math.max(1, Math.min(6, Math.round(order || 2)));
|
|
338
|
+
if (points.length < degree + 1) return [];
|
|
339
|
+
const matrix = Array.from({ length: degree + 1 }, (_, row) => (
|
|
340
|
+
Array.from({ length: degree + 2 }, (_, column) => {
|
|
341
|
+
if (column === degree + 1) {
|
|
342
|
+
return points.reduce((sum, [x, y]) => sum + y * x ** row, 0);
|
|
343
|
+
}
|
|
344
|
+
return points.reduce((sum, [x]) => sum + x ** (row + column), 0);
|
|
345
|
+
})
|
|
346
|
+
));
|
|
347
|
+
return solveLinearSystem(matrix);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* 根据 ecStat regression 配置预计算回归线数据。
|
|
352
|
+
* @param data - 协议数据载荷
|
|
353
|
+
* @param config - regression transform config
|
|
354
|
+
* @returns ECharts dataset source;无法计算时返回空数组
|
|
355
|
+
*/
|
|
356
|
+
function materializeRegressionSource(data: ProtocolDataPayload | undefined, config: Record<string, unknown>): unknown[][] {
|
|
357
|
+
const points = tableNumericSourceRows(data).sort(([left], [right]) => left - right);
|
|
358
|
+
if (!points.length) return [];
|
|
359
|
+
const method = typeof config.method === 'string' ? config.method : 'linear';
|
|
360
|
+
const label = `y = ${method}`;
|
|
361
|
+
|
|
362
|
+
if (method === 'exponential') {
|
|
363
|
+
const positivePoints = points.filter(([, y]) => y > 0);
|
|
364
|
+
const fitted = fitLinear(positivePoints.map(([x, y]) => [x, Math.log(y)]));
|
|
365
|
+
if (!fitted) return points.map(([x, y]) => [x, y, label]);
|
|
366
|
+
return points.map(([x]) => [x, Math.exp(fitted.intercept + fitted.slope * x), label]);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (method === 'logarithmic') {
|
|
370
|
+
const positivePoints = points.filter(([x]) => x > 0);
|
|
371
|
+
const fitted = fitLinear(positivePoints.map(([x, y]) => [Math.log(x), y]));
|
|
372
|
+
if (!fitted) return points.map(([x, y]) => [x, y, label]);
|
|
373
|
+
return points.map(([x]) => [x, fitted.slope * Math.log(x) + fitted.intercept, label]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (method === 'polynomial') {
|
|
377
|
+
const coefficients = fitPolynomial(points, Number(config.order) || 2);
|
|
378
|
+
if (!coefficients.length) return points.map(([x, y]) => [x, y, label]);
|
|
379
|
+
return points.map(([x]) => [
|
|
380
|
+
x,
|
|
381
|
+
coefficients.reduce((sum, coefficient, power) => sum + coefficient * x ** power, 0),
|
|
382
|
+
label,
|
|
383
|
+
]);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const fitted = fitLinear(points);
|
|
387
|
+
if (!fitted) return points.map(([x, y]) => [x, y, label]);
|
|
388
|
+
return points.map(([x]) => [x, fitted.slope * x + fitted.intercept, label]);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* 从 dataset transform 中提取 ecStat regression 配置。
|
|
393
|
+
* @param dataset - ECharts dataset 配置
|
|
394
|
+
* @returns regression 配置;不存在时返回 null
|
|
395
|
+
*/
|
|
396
|
+
function regressionTransformConfig(dataset: unknown): Record<string, unknown> | null {
|
|
397
|
+
if (!isPlainObject(dataset)) return null;
|
|
398
|
+
const transform = dataset.transform;
|
|
399
|
+
if (!isPlainObject(transform) || transform.type !== 'ecStat:regression') return null;
|
|
400
|
+
return isPlainObject(transform.config) ? transform.config : {};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* 从 dataset transform 中提取 ecStat histogram 配置。
|
|
405
|
+
* @param dataset - ECharts dataset 配置
|
|
406
|
+
* @returns histogram 配置;不存在时返回 null
|
|
407
|
+
*/
|
|
408
|
+
function histogramTransformConfig(dataset: unknown): Record<string, unknown> | null {
|
|
409
|
+
if (!isPlainObject(dataset)) return null;
|
|
410
|
+
const transform = dataset.transform;
|
|
411
|
+
if (!isPlainObject(transform) || transform.type !== 'ecStat:histogram') return null;
|
|
412
|
+
return isPlainObject(transform.config) ? transform.config : {};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* 读取 histogram 要统计的列下标。
|
|
417
|
+
* @param config - ecStat histogram 配置
|
|
418
|
+
* @returns 列下标
|
|
419
|
+
*/
|
|
420
|
+
function histogramDimensionIndex(config: Record<string, unknown>): number {
|
|
421
|
+
const dimensions = config.dimensions;
|
|
422
|
+
if (Array.isArray(dimensions) && typeof dimensions[0] === 'number') return dimensions[0];
|
|
423
|
+
if (typeof dimensions === 'number') return dimensions;
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* 按给定分位位置读取排序数组中的值。
|
|
429
|
+
* @param values - 已排序数值
|
|
430
|
+
* @param ratio - 分位比例
|
|
431
|
+
* @returns 分位值
|
|
432
|
+
*/
|
|
433
|
+
function quantile(values: number[], ratio: number): number {
|
|
434
|
+
if (!values.length) return Number.NaN;
|
|
435
|
+
const index = (values.length - 1) * ratio;
|
|
436
|
+
const lower = Math.floor(index);
|
|
437
|
+
const upper = Math.ceil(index);
|
|
438
|
+
if (lower === upper) return values[lower];
|
|
439
|
+
return values[lower] + (values[upper] - values[lower]) * (index - lower);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* 根据 ecStat histogram 配置预计算直方图数据。
|
|
444
|
+
* @param data - 协议数据载荷
|
|
445
|
+
* @param config - histogram transform config
|
|
446
|
+
* @returns ECharts dataset source
|
|
447
|
+
*/
|
|
448
|
+
function materializeHistogramSource(data: ProtocolDataPayload | undefined, config: Record<string, unknown>): unknown[][] {
|
|
449
|
+
const dimensionIndex = histogramDimensionIndex(config);
|
|
450
|
+
const values = tableSource(data)
|
|
451
|
+
.map((row) => (Array.isArray(row) ? Number(row[dimensionIndex]) : Number.NaN))
|
|
452
|
+
.filter((value) => Number.isFinite(value))
|
|
453
|
+
.sort((left, right) => left - right);
|
|
454
|
+
if (!values.length) return [];
|
|
455
|
+
|
|
456
|
+
const min = values[0];
|
|
457
|
+
const max = values[values.length - 1];
|
|
458
|
+
const iqr = quantile(values, 0.75) - quantile(values, 0.25);
|
|
459
|
+
const autoBinWidth = iqr > 0 ? (2 * iqr) / Math.cbrt(values.length) : (max - min) / Math.sqrt(values.length);
|
|
460
|
+
const binWidth = Number.isFinite(autoBinWidth) && autoBinWidth > 0 ? autoBinWidth : 1;
|
|
461
|
+
const binCount = Math.max(1, Math.ceil((max - min || 1) / binWidth));
|
|
462
|
+
const normalizedBinWidth = (max - min || 1) / binCount;
|
|
463
|
+
const counts = Array.from({ length: binCount }, () => 0);
|
|
464
|
+
|
|
465
|
+
values.forEach((value) => {
|
|
466
|
+
const rawIndex = Math.floor((value - min) / normalizedBinWidth);
|
|
467
|
+
const index = Math.min(binCount - 1, Math.max(0, rawIndex));
|
|
468
|
+
counts[index] += 1;
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
return counts.map((count, index) => {
|
|
472
|
+
const start = min + index * normalizedBinWidth;
|
|
473
|
+
const end = index === binCount - 1 ? max : start + normalizedBinWidth;
|
|
474
|
+
const center = (start + end) / 2;
|
|
475
|
+
return [center, count, start, end, `${start.toFixed(2)} - ${end.toFixed(2)}`];
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* 将主 table 数据注入 dataset 数组首项,保留内置 sort/filter transform 的输入源。
|
|
481
|
+
* @param datasets - optionPatch 中的 dataset 数组
|
|
482
|
+
* @param data - 协议数据载荷
|
|
483
|
+
* @returns 注入后的 dataset 数组
|
|
484
|
+
*/
|
|
485
|
+
function hydratePrimaryTableDataset(datasets: unknown[], data?: ProtocolDataPayload): unknown[] {
|
|
486
|
+
const source = tableSource(data);
|
|
487
|
+
const dimensions = tableDimensions(data);
|
|
488
|
+
if (!source.length && !dimensions.length) return datasets;
|
|
489
|
+
|
|
490
|
+
return datasets.map((dataset, index) => {
|
|
491
|
+
if (index !== 0 || !isPlainObject(dataset)) return dataset;
|
|
492
|
+
return {
|
|
493
|
+
...dataset,
|
|
494
|
+
...(source.length ? { source } : {}),
|
|
495
|
+
...(dimensions.length ? { dimensions } : {}),
|
|
496
|
+
};
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* 替换 ecStat histogram transform,避免运行时缺少 ecStat 插件。
|
|
502
|
+
* @param datasets - optionPatch 中的 dataset 数组
|
|
503
|
+
* @param data - 协议数据载荷
|
|
504
|
+
* @returns 替换后的 dataset 数组;没有 histogram 时返回 null
|
|
505
|
+
*/
|
|
506
|
+
function materializeHistogramDatasets(datasets: unknown[], data?: ProtocolDataPayload): unknown[] | null {
|
|
507
|
+
if (!datasets.some((dataset) => histogramTransformConfig(dataset))) return null;
|
|
508
|
+
return datasets.map((dataset, index) => {
|
|
509
|
+
const config = histogramTransformConfig(dataset);
|
|
510
|
+
if (!config) return index === 0 && isPlainObject(dataset) ? dataset : dataset;
|
|
511
|
+
if (!isPlainObject(dataset)) return dataset;
|
|
512
|
+
const { transform: _transform, ...rest } = dataset;
|
|
513
|
+
return {
|
|
514
|
+
...rest,
|
|
515
|
+
source: materializeHistogramSource(data, config),
|
|
516
|
+
};
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* 判断 pattern 配置是否携带浏览器 createPattern 无法接受的图片对象。
|
|
522
|
+
* @param value - 候选 pattern 配置
|
|
523
|
+
* @returns 非法 pattern 返回 true
|
|
524
|
+
*/
|
|
525
|
+
function isInvalidCanvasPattern(value: unknown): boolean {
|
|
526
|
+
if (!isPlainObject(value) || value.type !== 'pattern') return false;
|
|
527
|
+
const image = value.image;
|
|
528
|
+
return Boolean(image && typeof image === 'object');
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* 清理从官方示例中抽取出的不可序列化 Canvas pattern。
|
|
533
|
+
* @param value - 候选 option 值
|
|
534
|
+
* @returns 清理后的 option 值
|
|
535
|
+
*/
|
|
536
|
+
function sanitizeInvalidCanvasPatterns(value: unknown): unknown {
|
|
537
|
+
if (Array.isArray(value)) {
|
|
538
|
+
return value.map((item) => sanitizeInvalidCanvasPatterns(item));
|
|
539
|
+
}
|
|
540
|
+
if (!isPlainObject(value)) return value;
|
|
541
|
+
|
|
542
|
+
const result: Record<string, unknown> = {};
|
|
543
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
544
|
+
if (isInvalidCanvasPattern(item)) return;
|
|
545
|
+
result[key] = sanitizeInvalidCanvasPatterns(item);
|
|
546
|
+
});
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* 判断 option 片段是否为 ECharts 渐变色对象。
|
|
552
|
+
* @param value - 候选 option 值
|
|
553
|
+
* @returns 渐变色对象返回 true
|
|
554
|
+
*/
|
|
555
|
+
function isGradientColor(value: Record<string, unknown>): boolean {
|
|
556
|
+
return (value.type === 'linear' || value.type === 'radial') && Array.isArray(value.colorStops);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* 将渐变 stop 偏移量限制为 CanvasGradient 可接受的有限数。
|
|
561
|
+
* @param stop - 候选 color stop
|
|
562
|
+
* @param index - stop 下标
|
|
563
|
+
* @param count - stop 总数
|
|
564
|
+
* @returns 归一化后的 color stop
|
|
565
|
+
*/
|
|
566
|
+
function normalizeGradientColorStop(stop: unknown, index: number, count: number): unknown {
|
|
567
|
+
if (!isPlainObject(stop)) return stop;
|
|
568
|
+
const fallbackOffset = count <= 1 ? 0 : index / (count - 1);
|
|
569
|
+
const rawOffset = Number(stop.offset);
|
|
570
|
+
const offset = Number.isFinite(rawOffset)
|
|
571
|
+
? Math.min(1, Math.max(0, rawOffset))
|
|
572
|
+
: fallbackOffset;
|
|
573
|
+
return { ...stop, offset };
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* 清理渐变色 stop 中的 NaN/Infinity/缺失 offset,避免 CanvasGradient.addColorStop 抛错。
|
|
578
|
+
* @param value - 候选 option 值
|
|
579
|
+
* @returns 清理后的 option 值
|
|
580
|
+
*/
|
|
581
|
+
function sanitizeGradientColorStops(value: unknown): unknown {
|
|
582
|
+
if (Array.isArray(value)) {
|
|
583
|
+
return value.map((item) => sanitizeGradientColorStops(item));
|
|
584
|
+
}
|
|
585
|
+
if (!isPlainObject(value)) return value;
|
|
586
|
+
|
|
587
|
+
const result: Record<string, unknown> = {};
|
|
588
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
589
|
+
result[key] = sanitizeGradientColorStops(item);
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
if (isGradientColor(result)) {
|
|
593
|
+
const colorStops = result.colorStops as unknown[];
|
|
594
|
+
result.colorStops = colorStops.map((stop, index) => normalizeGradientColorStop(stop, index, colorStops.length));
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* 判断 option 片段是否包含无法离线渲染的 bmap 坐标系。
|
|
602
|
+
* @param value - 候选 option 值
|
|
603
|
+
* @returns 命中 bmap 坐标系返回 true
|
|
604
|
+
*/
|
|
605
|
+
function optionUsesBmapCoordinateSystem(value: unknown): boolean {
|
|
606
|
+
if (Array.isArray(value)) return value.some(optionUsesBmapCoordinateSystem);
|
|
607
|
+
if (!isPlainObject(value)) return false;
|
|
608
|
+
return Object.entries(value).some(([key, item]) => (
|
|
609
|
+
(key === 'coordinateSystem' && item === 'bmap')
|
|
610
|
+
|| key === 'bmap'
|
|
611
|
+
|| optionUsesBmapCoordinateSystem(item)
|
|
612
|
+
));
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* 判断 option 片段是否使用非笛卡尔二维坐标系。
|
|
617
|
+
* @param value - 候选 option 值
|
|
618
|
+
* @returns 使用 calendar 或 matrix 坐标系时返回 true
|
|
619
|
+
*/
|
|
620
|
+
function optionUsesNonCartesian2DCoordinateSystem(value: unknown): boolean {
|
|
621
|
+
if (Array.isArray(value)) return value.some(optionUsesNonCartesian2DCoordinateSystem);
|
|
622
|
+
if (!isPlainObject(value)) return false;
|
|
623
|
+
return Object.entries(value).some(([key, item]) => (
|
|
624
|
+
(key === 'coordinateSystem' && (item === 'calendar' || item === 'matrix'))
|
|
625
|
+
|| key === 'calendar'
|
|
626
|
+
|| key === 'matrix'
|
|
627
|
+
|| optionUsesNonCartesian2DCoordinateSystem(item)
|
|
628
|
+
));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* 清理 calendar/matrix 官方示例中从 series 协议骨架继承来的笛卡尔轴。
|
|
633
|
+
* @param value - 候选 option 值
|
|
634
|
+
* @returns 去除不相关笛卡尔轴后的 option 值
|
|
635
|
+
*/
|
|
636
|
+
function sanitizeNonCartesian2DCoordinateAxes(value: unknown): unknown {
|
|
637
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeNonCartesian2DCoordinateAxes(item));
|
|
638
|
+
if (!isPlainObject(value)) return value;
|
|
639
|
+
|
|
640
|
+
const shouldRemoveCartesianAxes = optionUsesNonCartesian2DCoordinateSystem(value);
|
|
641
|
+
const result: Record<string, unknown> = {};
|
|
642
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
643
|
+
if (shouldRemoveCartesianAxes && (key === 'xAxis' || key === 'yAxis' || key === 'grid')) return;
|
|
644
|
+
result[key] = sanitizeNonCartesian2DCoordinateAxes(item);
|
|
645
|
+
});
|
|
646
|
+
return result;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* 判断 series 是否不依赖笛卡尔坐标系。
|
|
651
|
+
* @param series - ECharts series 配置片段
|
|
652
|
+
* @returns 非坐标轴类 series 返回 true
|
|
653
|
+
*/
|
|
654
|
+
function isCoordinateFreeSeries(series: Record<string, unknown>): boolean {
|
|
655
|
+
return series.type === 'funnel'
|
|
656
|
+
|| series.type === 'pie'
|
|
657
|
+
|| series.type === 'radar'
|
|
658
|
+
|| series.type === 'gauge';
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* 移除非坐标轴类 series 上继承到的笛卡尔坐标字段。
|
|
663
|
+
* @param series - ECharts series 配置片段
|
|
664
|
+
* @returns 清理后的 series 配置
|
|
665
|
+
*/
|
|
666
|
+
function sanitizeCoordinateFreeSeries(series: Record<string, unknown>): Record<string, unknown> {
|
|
667
|
+
if (!isCoordinateFreeSeries(series)) return series;
|
|
668
|
+
const {
|
|
669
|
+
coordinateSystem: _coordinateSystem,
|
|
670
|
+
xAxisIndex: _xAxisIndex,
|
|
671
|
+
yAxisIndex: _yAxisIndex,
|
|
672
|
+
gridIndex: _gridIndex,
|
|
673
|
+
...rest
|
|
674
|
+
} = series;
|
|
675
|
+
return rest;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* 运行时数据把多漏斗模板收敛为单漏斗时,将漏斗重新放回画布中心。
|
|
680
|
+
* @param series - 单个漏斗 series 配置
|
|
681
|
+
* @returns 居中后的漏斗 series 配置
|
|
682
|
+
*/
|
|
683
|
+
function normalizeSingleRuntimeFunnelLayout(series: Record<string, unknown>): Record<string, unknown> {
|
|
684
|
+
if (series.type !== 'funnel') return series;
|
|
685
|
+
const { right: _right, ...rest } = series;
|
|
686
|
+
return {
|
|
687
|
+
...rest,
|
|
688
|
+
left: 'center',
|
|
689
|
+
width: '70%',
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* 清理运行时最终 option 中非坐标轴图表从模板继承到的坐标配置。
|
|
695
|
+
* @param option - 已合并真实数据的 ECharts option
|
|
696
|
+
* @returns 可安全交给 ECharts 渲染的 option
|
|
697
|
+
*/
|
|
698
|
+
function sanitizeRuntimeCoordinateFreeSeriesOption(option: EChartsOption): EChartsOption {
|
|
699
|
+
if (!isPlainObject(option)) return option;
|
|
700
|
+
|
|
701
|
+
const mutable = option as Record<string, unknown>;
|
|
702
|
+
const rawSeries = mutable.series;
|
|
703
|
+
const seriesItems = Array.isArray(rawSeries)
|
|
704
|
+
? rawSeries.filter(isPlainObject)
|
|
705
|
+
: isPlainObject(rawSeries)
|
|
706
|
+
? [rawSeries]
|
|
707
|
+
: [];
|
|
708
|
+
if (seriesItems.length === 0) return option;
|
|
709
|
+
|
|
710
|
+
let nextSeries = seriesItems.map(sanitizeCoordinateFreeSeries);
|
|
711
|
+
const hasOnlyCoordinateFreeSeries = nextSeries.every(isCoordinateFreeSeries);
|
|
712
|
+
|
|
713
|
+
if (nextSeries.length === 1 && nextSeries[0].type === 'funnel') {
|
|
714
|
+
nextSeries = [normalizeSingleRuntimeFunnelLayout(nextSeries[0])];
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const nextOption: Record<string, unknown> = {
|
|
718
|
+
...mutable,
|
|
719
|
+
series: Array.isArray(rawSeries) ? nextSeries : nextSeries[0],
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
if (hasOnlyCoordinateFreeSeries) {
|
|
723
|
+
delete nextOption.xAxis;
|
|
724
|
+
delete nextOption.yAxis;
|
|
725
|
+
delete nextOption.grid;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return nextOption as EChartsOption;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* 将 ECharts 6 matrix 坐标模板降级为 ECharts 5 可渲染的类目坐标图。
|
|
733
|
+
* @param option - 待清洗的最终 option
|
|
734
|
+
* @returns 兼容 ECharts 5 的 option
|
|
735
|
+
*/
|
|
736
|
+
function downgradeMatrixCoordinateOption(option: EChartsOption): EChartsOption {
|
|
737
|
+
const mutable = option as Record<string, unknown>;
|
|
738
|
+
if (!isPlainObject(mutable.matrix)) return option;
|
|
739
|
+
const seriesItems = Array.isArray(mutable.series) ? mutable.series : mutable.series ? [mutable.series] : [];
|
|
740
|
+
if (!seriesItems.some(isMatrixSeries)) return option;
|
|
741
|
+
|
|
742
|
+
const matrix = mutable.matrix;
|
|
743
|
+
const xAxisConfig = isPlainObject(matrix.x) ? matrix.x : {};
|
|
744
|
+
const yAxisConfig = isPlainObject(matrix.y) ? matrix.y : {};
|
|
745
|
+
const xLabels = matrixAxisLabels(xAxisConfig.data);
|
|
746
|
+
const yLabels = matrixAxisLabels(yAxisConfig.data);
|
|
747
|
+
if (!xLabels.length || !yLabels.length) return option;
|
|
748
|
+
|
|
749
|
+
const { matrix: _matrix, ...rest } = mutable;
|
|
750
|
+
return {
|
|
751
|
+
...rest,
|
|
752
|
+
grid: isPlainObject(mutable.grid)
|
|
753
|
+
? { containLabel: true, ...mutable.grid }
|
|
754
|
+
: { left: 72, right: 32, top: 72, bottom: 48, containLabel: true },
|
|
755
|
+
xAxis: { type: 'category', ...(xAxisConfig.show === false ? { show: false } : {}), data: xLabels },
|
|
756
|
+
yAxis: { type: 'category', ...(yAxisConfig.show === false ? { show: false } : {}), data: yLabels },
|
|
757
|
+
series: seriesItems.map((item) => {
|
|
758
|
+
if (!isMatrixSeries(item)) return item;
|
|
759
|
+
const { coordinateSystem: _coordinateSystem, ...seriesRest } = item;
|
|
760
|
+
return {
|
|
761
|
+
...seriesRest,
|
|
762
|
+
data: downgradeMatrixSeriesData(seriesRest.data, xLabels, yLabels),
|
|
763
|
+
};
|
|
764
|
+
}),
|
|
765
|
+
} as EChartsOption;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* 将官方示例中的外部地图名和 bmap 坐标系降级为内置工作台地图。
|
|
770
|
+
* @param value - 候选 option 值
|
|
771
|
+
* @returns 不依赖外部地图资源或 bmap 插件的 option 值
|
|
772
|
+
*/
|
|
773
|
+
function sanitizeExternalGeoDependencies(value: unknown): unknown {
|
|
774
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeExternalGeoDependencies(item));
|
|
775
|
+
if (!isPlainObject(value)) return value;
|
|
776
|
+
|
|
777
|
+
const result: Record<string, unknown> = {};
|
|
778
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
779
|
+
if (key === 'bmap') return;
|
|
780
|
+
if ((key === 'map' || key === 'mapType') && typeof item === 'string') {
|
|
781
|
+
result[key] = 'workbench-regions';
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (key === 'coordinateSystem' && item === 'bmap') {
|
|
785
|
+
result[key] = 'geo';
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
result[key] = sanitizeExternalGeoDependencies(item);
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
if (
|
|
792
|
+
result.type === 'map'
|
|
793
|
+
&& typeof result.map !== 'string'
|
|
794
|
+
&& typeof result.mapType !== 'string'
|
|
795
|
+
) {
|
|
796
|
+
result.map = 'workbench-regions';
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return result;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* 移除卡片中心会被 CORS 拦截的 ECharts 官方远程 GL 纹理。
|
|
804
|
+
* @param value - 待处理的 option 值
|
|
805
|
+
* @param parentKey - 当前值所属的父级 key
|
|
806
|
+
* @returns 不依赖远程 GL 纹理的 option 值
|
|
807
|
+
*/
|
|
808
|
+
function sanitizeOfficialRemoteGlAssets(value: unknown, parentKey = ''): unknown {
|
|
809
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeOfficialRemoteGlAssets(item, parentKey));
|
|
810
|
+
if (!isPlainObject(value)) return value;
|
|
811
|
+
|
|
812
|
+
const result: Record<string, unknown> = {};
|
|
813
|
+
let removedGlobeTexture = false;
|
|
814
|
+
|
|
815
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
816
|
+
if (typeof item === 'string' && isOfficialRemoteGlAssetUrl(item)) {
|
|
817
|
+
if (key === 'environment') {
|
|
818
|
+
result[key] = GL_ENVIRONMENT_FALLBACK_COLOR;
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
if (key === 'baseTexture' || key === 'heightTexture') {
|
|
822
|
+
removedGlobeTexture = true;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (GL_REMOTE_TEXTURE_KEYS.has(key)) return;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
result[key] = sanitizeOfficialRemoteGlAssets(item, key);
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
if (parentKey === 'globe' && removedGlobeTexture && !result.baseColor) {
|
|
832
|
+
result.baseColor = GL_GLOBE_FALLBACK_COLOR;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
return result;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* 移除模板补丁中的静态图例项,避免运行时数据合并后又被示例 legend 覆盖。
|
|
840
|
+
* @param legend - optionPatch.legend 候选值
|
|
841
|
+
* @returns 不含 data 字段的 legend 配置
|
|
842
|
+
*/
|
|
843
|
+
function stripRuntimeLegendData(legend: unknown): unknown {
|
|
844
|
+
if (Array.isArray(legend)) {
|
|
845
|
+
return legend.map((item) => stripRuntimeLegendData(item));
|
|
846
|
+
}
|
|
847
|
+
if (!isPlainObject(legend)) return legend;
|
|
848
|
+
|
|
849
|
+
const { data: _data, ...rest } = legend;
|
|
850
|
+
return rest;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* 判断协议数据是否携带笛卡尔类目图的真实运行时数据。
|
|
855
|
+
* @param data - 协议数据载荷。
|
|
856
|
+
* @returns 有真实类目或序列数据时返回 true。
|
|
857
|
+
*/
|
|
858
|
+
function hasRuntimeCartesianSeriesData(data: ProtocolDataPayload | undefined): boolean {
|
|
859
|
+
if (!data || data.protocolType !== 'series') return false;
|
|
860
|
+
const categories = isPlainObject(data.categories) && Array.isArray(data.categories.xAxis)
|
|
861
|
+
? data.categories.xAxis
|
|
862
|
+
: Array.isArray(data.categories)
|
|
863
|
+
? data.categories
|
|
864
|
+
: [];
|
|
865
|
+
const series = Array.isArray(data.series) ? data.series : [];
|
|
866
|
+
return categories.length > 0 || series.some((item) => (
|
|
867
|
+
isPlainObject(item) && Array.isArray(item.data) && item.data.length > 0
|
|
868
|
+
));
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* 将模板 dataZoom 初始窗口归一为全量范围,避免真实数据默认只显示前几条。
|
|
873
|
+
* @param item - 单个 dataZoom 配置项。
|
|
874
|
+
* @returns 不裁剪初始数据窗口的 dataZoom 配置。
|
|
875
|
+
*/
|
|
876
|
+
function normalizeRuntimeDataZoomItem(item: unknown): unknown {
|
|
877
|
+
if (!isPlainObject(item)) return item;
|
|
878
|
+
const {
|
|
879
|
+
startValue: _startValue,
|
|
880
|
+
endValue: _endValue,
|
|
881
|
+
...rest
|
|
882
|
+
} = item;
|
|
883
|
+
return {
|
|
884
|
+
...rest,
|
|
885
|
+
start: 0,
|
|
886
|
+
end: 100,
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* 归一化运行时 dataZoom 配置,保留缩放能力但默认展示完整真实数据。
|
|
892
|
+
* @param dataZoom - optionPatch.dataZoom 候选值。
|
|
893
|
+
* @returns 全量初始窗口的 dataZoom 配置。
|
|
894
|
+
*/
|
|
895
|
+
function normalizeRuntimeDataZoomWindow(dataZoom: unknown): unknown {
|
|
896
|
+
if (Array.isArray(dataZoom)) return dataZoom.map(normalizeRuntimeDataZoomItem);
|
|
897
|
+
return normalizeRuntimeDataZoomItem(dataZoom);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* 对最终 ECharts option 应用 dataZoom 全量窗口归一化,覆盖模板、AI 注入、
|
|
902
|
+
* 用户改卡等所有来源的 dataZoom 配置,确保运行时全部数据默认可见。
|
|
903
|
+
* @param option - 已合并的最终 ECharts option
|
|
904
|
+
* @param data - 协议数据载荷,用于判定是否携带真实运行时数据
|
|
905
|
+
* @returns dataZoom 已被归一化的 option 副本
|
|
906
|
+
*/
|
|
907
|
+
function normalizeFinalDataZoom(
|
|
908
|
+
option: EChartsOption,
|
|
909
|
+
data?: ProtocolDataPayload,
|
|
910
|
+
): EChartsOption {
|
|
911
|
+
if (!isPlainObject(option)) return option;
|
|
912
|
+
const mutable = option as Record<string, unknown>;
|
|
913
|
+
const dataZoom = mutable.dataZoom;
|
|
914
|
+
if (dataZoom === undefined) return option;
|
|
915
|
+
// 仅当携带真实运行时数据时才覆盖 dataZoom,避免误伤纯静态展示模板。
|
|
916
|
+
if (!hasRuntimeCartesianSeriesData(data)) return option;
|
|
917
|
+
return {
|
|
918
|
+
...mutable,
|
|
919
|
+
dataZoom: normalizeRuntimeDataZoomWindow(dataZoom),
|
|
920
|
+
} as EChartsOption;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* 清洗运行时不支持的官方 optionPatch 片段。
|
|
925
|
+
* @param patch - 原始 optionPatch
|
|
926
|
+
* @param data - 可选协议数据,用于预计算部分 transform
|
|
927
|
+
* @returns 可安全传给 ECharts 的 optionPatch
|
|
928
|
+
*/
|
|
929
|
+
function sanitizeRuntimeOptionPatch(
|
|
930
|
+
patch: Record<string, unknown>,
|
|
931
|
+
data?: ProtocolDataPayload,
|
|
932
|
+
): Record<string, unknown> {
|
|
933
|
+
const usesBmap = optionUsesBmapCoordinateSystem(patch);
|
|
934
|
+
const sanitized = sanitizeExternalGeoDependencies(
|
|
935
|
+
sanitizeOfficialRemoteGlAssets(
|
|
936
|
+
sanitizeInvalidCanvasPatterns(
|
|
937
|
+
sanitizeGradientColorStops(
|
|
938
|
+
sanitizeCustomSeriesWithoutRenderer(cloneOptionValue(patch)),
|
|
939
|
+
),
|
|
940
|
+
),
|
|
941
|
+
),
|
|
942
|
+
) as Record<string, unknown>;
|
|
943
|
+
|
|
944
|
+
if (usesBmap && !sanitized.geo) {
|
|
945
|
+
sanitized.geo = {
|
|
946
|
+
map: 'workbench-regions',
|
|
947
|
+
roam: true,
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (data && sanitized.legend !== undefined) {
|
|
952
|
+
sanitized.legend = stripRuntimeLegendData(sanitized.legend);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
if (sanitized.dataZoom !== undefined && hasRuntimeCartesianSeriesData(data)) {
|
|
956
|
+
sanitized.dataZoom = normalizeRuntimeDataZoomWindow(sanitized.dataZoom);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
if (isRuntimeSeriesData(data)) {
|
|
960
|
+
sanitized.title = stripRuntimeTitleText(sanitized.title);
|
|
961
|
+
sanitized.tooltip = stripRuntimeTooltipFormatter(sanitized.tooltip);
|
|
962
|
+
const seriesPatch = stripRuntimeSeriesPatchSemantics(sanitized.series, data);
|
|
963
|
+
if (seriesPatch === undefined) {
|
|
964
|
+
delete sanitized.series;
|
|
965
|
+
} else {
|
|
966
|
+
sanitized.series = seriesPatch;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (sanitized.dataset && Array.isArray(sanitized.series)) {
|
|
971
|
+
sanitized.series = sanitizeEmptyDatasetDrivenSeriesData(sanitized.series);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const datasetPatch = sanitized.dataset;
|
|
975
|
+
if (!Array.isArray(datasetPatch)) return sanitized;
|
|
976
|
+
|
|
977
|
+
const hydratedDatasets = hydratePrimaryTableDataset(datasetPatch, data);
|
|
978
|
+
const histogramDatasets = materializeHistogramDatasets(hydratedDatasets, data);
|
|
979
|
+
sanitized.dataset = histogramDatasets || hydratedDatasets;
|
|
980
|
+
|
|
981
|
+
const currentDatasets = sanitized.dataset as unknown[];
|
|
982
|
+
const regressionIndex = currentDatasets.findIndex((dataset) => regressionTransformConfig(dataset));
|
|
983
|
+
if (regressionIndex > 0) {
|
|
984
|
+
const regressionConfig = regressionTransformConfig(currentDatasets[regressionIndex]) || {};
|
|
985
|
+
sanitized.dataset = [
|
|
986
|
+
{ source: tableNumericSourceRows(data) },
|
|
987
|
+
{ source: materializeRegressionSource(data, regressionConfig) },
|
|
988
|
+
];
|
|
989
|
+
return sanitized;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if (currentDatasets.some(datasetHasUnsupportedTransform)) {
|
|
993
|
+
const { dataset: _dataset, visualMap: _visualMap, ...rest } = sanitized;
|
|
994
|
+
return {
|
|
995
|
+
...rest,
|
|
996
|
+
...(Array.isArray(rest.series) ? { series: sanitizeSeriesDatasetReferences(rest.series) } : {}),
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
return sanitized;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* 判断协议数据是否为可由运行时真实 series 接管语义的序列数据。
|
|
1005
|
+
* @param data - 协议数据负载。
|
|
1006
|
+
* @returns series 协议数据返回 true。
|
|
1007
|
+
*/
|
|
1008
|
+
function isRuntimeSeriesData(data: ProtocolDataPayload | undefined): data is ProtocolDataPayload {
|
|
1009
|
+
return Boolean(data && data.protocolType === 'series');
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* 读取运行时 series 协议中的真实系列数量。
|
|
1014
|
+
* @param data - series 协议数据。
|
|
1015
|
+
* @returns 真实 series 数量。
|
|
1016
|
+
*/
|
|
1017
|
+
function runtimeSeriesCount(data: ProtocolDataPayload): number {
|
|
1018
|
+
const record = data as unknown as Record<string, unknown>;
|
|
1019
|
+
if (Array.isArray(record.series)) return record.series.filter(isPlainObject).length;
|
|
1020
|
+
const dataset = isPlainObject(record.dataset) ? record.dataset : undefined;
|
|
1021
|
+
return Array.isArray(dataset?.series) ? dataset.series.filter(isPlainObject).length : 0;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* 去掉官方模板标题中的演示文本,只保留定位和样式。
|
|
1026
|
+
* @param value - ECharts title 配置。
|
|
1027
|
+
* @returns 不含 text/subtext 等展示文案的 title 配置。
|
|
1028
|
+
*/
|
|
1029
|
+
function stripRuntimeTitleText(value: unknown): unknown {
|
|
1030
|
+
if (Array.isArray(value)) return value.map(stripRuntimeTitleText);
|
|
1031
|
+
if (!isPlainObject(value)) return value;
|
|
1032
|
+
const {
|
|
1033
|
+
text: _text,
|
|
1034
|
+
subtext: _subtext,
|
|
1035
|
+
link: _link,
|
|
1036
|
+
sublink: _sublink,
|
|
1037
|
+
target: _target,
|
|
1038
|
+
subtarget: _subtarget,
|
|
1039
|
+
...rest
|
|
1040
|
+
} = value;
|
|
1041
|
+
return rest;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* 去掉官方模板 tooltip formatter,避免 formatter 中的模板占位语义压过真实数据。
|
|
1046
|
+
* @param value - ECharts tooltip 配置。
|
|
1047
|
+
* @returns 不含 formatter 的 tooltip 配置。
|
|
1048
|
+
*/
|
|
1049
|
+
function stripRuntimeTooltipFormatter(value: unknown): unknown {
|
|
1050
|
+
if (Array.isArray(value)) return value.map(stripRuntimeTooltipFormatter);
|
|
1051
|
+
if (!isPlainObject(value)) return value;
|
|
1052
|
+
const { formatter: _formatter, ...rest } = value;
|
|
1053
|
+
return rest;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* 将官方模板 series patch 限定为视觉样式,真实 id/name/data 由协议数据提供。
|
|
1058
|
+
* @param value - ECharts optionPatch.series。
|
|
1059
|
+
* @param data - 运行时 series 协议数据。
|
|
1060
|
+
* @returns 只包含样式字段且不新增 demo series 的 series patch。
|
|
1061
|
+
*/
|
|
1062
|
+
function stripRuntimeSeriesPatchSemantics(value: unknown, data: ProtocolDataPayload): unknown {
|
|
1063
|
+
const count = runtimeSeriesCount(data);
|
|
1064
|
+
if (count <= 0) return undefined;
|
|
1065
|
+
|
|
1066
|
+
if (!Array.isArray(value)) {
|
|
1067
|
+
const firstSeriesPatch = stripOneRuntimeSeriesPatchSemantics(value);
|
|
1068
|
+
return [firstSeriesPatch ?? {}];
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const waterfallSeriesPatch = count === 1 ? legacyWaterfallRuntimeSeriesPatch(value) : undefined;
|
|
1072
|
+
if (waterfallSeriesPatch) return waterfallSeriesPatch;
|
|
1073
|
+
|
|
1074
|
+
return Array.from({ length: count }, (_, index) => (
|
|
1075
|
+
stripOneRuntimeSeriesPatchSemantics(value[index]) ?? {}
|
|
1076
|
+
));
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* 判断颜色值是否为透明色。
|
|
1081
|
+
* @param value - 待判断的颜色值。
|
|
1082
|
+
* @returns 透明色返回 true。
|
|
1083
|
+
*/
|
|
1084
|
+
function isTransparentColor(value: unknown): boolean {
|
|
1085
|
+
const normalized = typeof value === 'string' ? value.trim().toLowerCase().replace(/\s+/gu, '') : '';
|
|
1086
|
+
return normalized === 'transparent'
|
|
1087
|
+
|| normalized === 'rgba(0,0,0,0)'
|
|
1088
|
+
|| normalized === 'rgba(255,255,255,0)';
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* 判断 series patch 是否为瀑布图透明占位柱。
|
|
1093
|
+
* @param value - 候选 series patch。
|
|
1094
|
+
* @returns 透明占位柱返回 true。
|
|
1095
|
+
*/
|
|
1096
|
+
function isWaterfallHelperSeriesPatch(value: unknown): value is Record<string, unknown> {
|
|
1097
|
+
if (!isPlainObject(value) || value.type !== 'bar' || typeof value.stack !== 'string') return false;
|
|
1098
|
+
const itemStyle = isPlainObject(value.itemStyle) ? value.itemStyle : {};
|
|
1099
|
+
const emphasis = isPlainObject(value.emphasis) ? value.emphasis : {};
|
|
1100
|
+
const emphasisItemStyle = isPlainObject(emphasis.itemStyle) ? emphasis.itemStyle : {};
|
|
1101
|
+
return isTransparentColor(itemStyle.color)
|
|
1102
|
+
|| isTransparentColor(itemStyle.borderColor)
|
|
1103
|
+
|| isTransparentColor(emphasisItemStyle.color)
|
|
1104
|
+
|| isTransparentColor(emphasisItemStyle.borderColor);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* 从旧瀑布图模板 patch 中保留透明 helper 和真实可见柱两个结构 series。
|
|
1109
|
+
* @param value - optionPatch.series 候选值。
|
|
1110
|
+
* @returns 瀑布图两条结构 series patch;非瀑布图返回 undefined。
|
|
1111
|
+
*/
|
|
1112
|
+
function legacyWaterfallRuntimeSeriesPatch(value: unknown[]): Array<Record<string, unknown>> | undefined {
|
|
1113
|
+
const helperIndex = value.findIndex(isWaterfallHelperSeriesPatch);
|
|
1114
|
+
if (helperIndex < 0) return undefined;
|
|
1115
|
+
const helper = value[helperIndex] as Record<string, unknown>;
|
|
1116
|
+
const helperStack = typeof helper.stack === 'string' ? helper.stack : undefined;
|
|
1117
|
+
const visibleIndex = value.findIndex((item, index) => (
|
|
1118
|
+
index !== helperIndex
|
|
1119
|
+
&& isPlainObject(item)
|
|
1120
|
+
&& item.type === 'bar'
|
|
1121
|
+
&& typeof item.stack === 'string'
|
|
1122
|
+
&& item.stack === helperStack
|
|
1123
|
+
&& !isWaterfallHelperSeriesPatch(item)
|
|
1124
|
+
));
|
|
1125
|
+
if (visibleIndex < 0) return undefined;
|
|
1126
|
+
return [
|
|
1127
|
+
stripOneRuntimeSeriesPatchSemantics(value[helperIndex]) ?? {},
|
|
1128
|
+
stripOneRuntimeSeriesPatchSemantics(value[visibleIndex]) ?? {},
|
|
1129
|
+
];
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* 去掉单个模板 series 中会覆盖真实数据语义的字段。
|
|
1134
|
+
* @param value - 模板 series patch。
|
|
1135
|
+
* @returns 仅保留视觉和结构配置的 series patch。
|
|
1136
|
+
*/
|
|
1137
|
+
function stripOneRuntimeSeriesPatchSemantics(value: unknown): Record<string, unknown> | undefined {
|
|
1138
|
+
if (!isPlainObject(value)) return undefined;
|
|
1139
|
+
const {
|
|
1140
|
+
id: _id,
|
|
1141
|
+
name: _name,
|
|
1142
|
+
data: _data,
|
|
1143
|
+
...rest
|
|
1144
|
+
} = value;
|
|
1145
|
+
return rest;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* 在真实 series 数据完成合并后再次清理最终 option,防止基础配置标题等模板语义残留。
|
|
1150
|
+
* @param option - 已合并 optionPatch 的 ECharts option。
|
|
1151
|
+
* @param data - 可选协议数据。
|
|
1152
|
+
* @returns 用户可见语义由运行时数据接管后的 option。
|
|
1153
|
+
*/
|
|
1154
|
+
function stripRuntimeOptionSemantics(option: EChartsOption, data?: ProtocolDataPayload): EChartsOption {
|
|
1155
|
+
if (!isRuntimeSeriesData(data)) return option;
|
|
1156
|
+
const next = { ...(option as Record<string, unknown>) };
|
|
1157
|
+
next.title = stripRuntimeTitleText(next.title);
|
|
1158
|
+
next.tooltip = stripRuntimeTooltipFormatter(next.tooltip);
|
|
1159
|
+
return next as EChartsOption;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* 协议类型到转换器的映射表,覆盖全部 13 种协议类型。
|
|
1164
|
+
*/
|
|
1165
|
+
const CONVERTER_MAP: Record<ProtocolType, ProtocolConverter> = {
|
|
1166
|
+
series: seriesConverter,
|
|
1167
|
+
table: tableConverter,
|
|
1168
|
+
tuple: tupleConverter,
|
|
1169
|
+
tree: treeConverter,
|
|
1170
|
+
network: networkConverter,
|
|
1171
|
+
geo: geoConverter,
|
|
1172
|
+
scene3D: scene3DConverter,
|
|
1173
|
+
timeline: timelineConverter,
|
|
1174
|
+
transition: transitionConverter,
|
|
1175
|
+
graphic: graphicConverter,
|
|
1176
|
+
layout: layoutConverter,
|
|
1177
|
+
composite: compositeConverter,
|
|
1178
|
+
configOnly: configOnlyConverter,
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* ECharts 协议适配器 — 管理协议配置和数据的生命周期,
|
|
1183
|
+
* 将协议载荷转换为 ECharts option 实例。
|
|
1184
|
+
*/
|
|
1185
|
+
export class EChartsProtocolAdapter {
|
|
1186
|
+
/** 当前已生成的 ECharts option */
|
|
1187
|
+
private currentOption: EChartsOption | null = null;
|
|
1188
|
+
|
|
1189
|
+
/** 当前保存的协议配置 */
|
|
1190
|
+
private config: ProtocolConfigPayload | null = null;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* 设置协议配置并生成初始 ECharts option。
|
|
1194
|
+
* 若转换器构建 option 失败,会尝试回退到 config 中的 optionPatch。
|
|
1195
|
+
*
|
|
1196
|
+
* @param config - 协议配置载荷,定义图表的骨架结构
|
|
1197
|
+
* @returns 生成的 ECharts option
|
|
1198
|
+
* @throws 当转换器未找到或构建失败且无 optionPatch 可回退时抛出异常
|
|
1199
|
+
*/
|
|
1200
|
+
setConfig(config: ProtocolConfigPayload): EChartsOption {
|
|
1201
|
+
this.config = config;
|
|
1202
|
+
|
|
1203
|
+
try {
|
|
1204
|
+
const converter = this.resolveConverter(config.protocolType);
|
|
1205
|
+
this.currentOption = this.applyOptionPatch(converter.buildOption(this.configWithoutOptionPatch(config)));
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
// 构建 option 失败时,尝试回退到 optionPatch
|
|
1208
|
+
if (config.optionPatch) {
|
|
1209
|
+
this.currentOption = deepMergeOption({}, config.optionPatch);
|
|
1210
|
+
} else {
|
|
1211
|
+
throw error;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
return this.currentOption;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* 将数据载荷合并到当前 ECharts option 中。
|
|
1220
|
+
* 必须先调用 setConfig 设置配置,否则无法合并数据。
|
|
1221
|
+
* 若合并过程出错,会安全地返回当前未修改的 option。
|
|
1222
|
+
*
|
|
1223
|
+
* @param data - 协议数据载荷,包含图表展示所需的实际数据
|
|
1224
|
+
* @returns 更新后的 ECharts option;若未设置配置或合并失败则返回当前 option
|
|
1225
|
+
*/
|
|
1226
|
+
setData(data: ProtocolDataPayload): EChartsOption {
|
|
1227
|
+
if (!this.config || !this.currentOption) {
|
|
1228
|
+
return this.currentOption as EChartsOption;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
try {
|
|
1232
|
+
const converter = this.resolveConverter(this.config.protocolType);
|
|
1233
|
+
// 先解除 Vue 响应式代理,避免 structuredClone 遇到 Proxy 后丢弃本次数据合并。
|
|
1234
|
+
const currentOptionDataZoom = isPlainObject(this.currentOption)
|
|
1235
|
+
? (this.currentOption as Record<string, unknown>).dataZoom
|
|
1236
|
+
: undefined;
|
|
1237
|
+
const baseOption = converter.buildOption(this.configWithoutOptionPatch(this.config));
|
|
1238
|
+
const patchedBaseOption = isRuntimeSeriesData(data)
|
|
1239
|
+
? this.config.optionPatch
|
|
1240
|
+
? deepMergeOption(baseOption, sanitizeRuntimeOptionPatch(this.config.optionPatch, data))
|
|
1241
|
+
: baseOption
|
|
1242
|
+
: baseOption;
|
|
1243
|
+
// 真实数据刷新时从无模板 patch 的协议骨架重建,避免 setConfig 阶段的官方 demo series 残留。
|
|
1244
|
+
const clonedOption = cloneOptionValue(patchedBaseOption);
|
|
1245
|
+
const mergedOption = converter.mergeData(clonedOption, data);
|
|
1246
|
+
const nextOption = isRuntimeSeriesData(data)
|
|
1247
|
+
? downgradeMatrixCoordinateOption(sanitizeRuntimeCoordinateFreeSeriesOption(
|
|
1248
|
+
sanitizeNonCartesian2DCoordinateAxes(
|
|
1249
|
+
sanitizeExternalGeoDependencies(stripRuntimeOptionSemantics(mergedOption, data)),
|
|
1250
|
+
) as EChartsOption,
|
|
1251
|
+
))
|
|
1252
|
+
: this.applyOptionPatch(mergedOption, data);
|
|
1253
|
+
const optionWithRuntimeDataZoom = currentOptionDataZoom !== undefined
|
|
1254
|
+
&& isPlainObject(nextOption)
|
|
1255
|
+
&& (nextOption as Record<string, unknown>).dataZoom === undefined
|
|
1256
|
+
? { ...(nextOption as Record<string, unknown>), dataZoom: currentOptionDataZoom } as EChartsOption
|
|
1257
|
+
: nextOption;
|
|
1258
|
+
// 最后再在最终 option 上做一次 dataZoom 归一化,覆盖所有来源(模板 optionPatch、
|
|
1259
|
+
// converter 内联、AI 注入、用户改卡)的 dataZoom 配置,避免模板只露前几条。
|
|
1260
|
+
this.currentOption = this.normalizeRuntimeDataZoom(optionWithRuntimeDataZoom, data);
|
|
1261
|
+
} catch (error) {
|
|
1262
|
+
// 合并数据失败时保持当前 option 不变,记录错误
|
|
1263
|
+
console.warn(
|
|
1264
|
+
`[EChartsProtocolAdapter] setData failed for protocol "${this.config.protocolType}":`,
|
|
1265
|
+
error,
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return this.currentOption as EChartsOption;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* 获取当前 ECharts option。
|
|
1274
|
+
*
|
|
1275
|
+
* @returns 当前的 ECharts option,若尚未设置配置则返回 null
|
|
1276
|
+
*/
|
|
1277
|
+
getOption(): EChartsOption | null {
|
|
1278
|
+
return this.currentOption;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* 重置适配器状态,清空配置和 option。
|
|
1283
|
+
*/
|
|
1284
|
+
reset(): void {
|
|
1285
|
+
this.currentOption = null;
|
|
1286
|
+
this.config = null;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* 根据协议类型从映射表中查找对应的转换器。
|
|
1291
|
+
*
|
|
1292
|
+
* @param protocolType - 协议类型标识
|
|
1293
|
+
* @returns 对应的协议转换器实例
|
|
1294
|
+
* @throws 当协议类型未注册时抛出错误
|
|
1295
|
+
*/
|
|
1296
|
+
private resolveConverter(protocolType: ProtocolType): ProtocolConverter {
|
|
1297
|
+
const converter = CONVERTER_MAP[protocolType];
|
|
1298
|
+
if (!converter) {
|
|
1299
|
+
throw new Error(
|
|
1300
|
+
`[EChartsProtocolAdapter] No converter registered for protocol type: "${protocolType}"`,
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
return converter;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* 移除配置中的 optionPatch,让各协议转换器只负责生成基础 option。
|
|
1308
|
+
* @param config - 原始协议配置
|
|
1309
|
+
* @returns 不含 optionPatch 的协议配置
|
|
1310
|
+
*/
|
|
1311
|
+
private configWithoutOptionPatch(config: ProtocolConfigPayload): ProtocolConfigPayload {
|
|
1312
|
+
const { optionPatch: _optionPatch, ...baseConfig } = config;
|
|
1313
|
+
return baseConfig;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* 将当前配置中的 optionPatch 深合并到 ECharts option。
|
|
1318
|
+
* @param option - 转换器生成或刷新数据后的基础 option
|
|
1319
|
+
* @returns 合并用户展示补丁后的 ECharts option
|
|
1320
|
+
*/
|
|
1321
|
+
private applyOptionPatch(option: EChartsOption, data?: ProtocolDataPayload): EChartsOption {
|
|
1322
|
+
const patchedOption = this.config?.optionPatch
|
|
1323
|
+
? deepMergeOption(option, sanitizeRuntimeOptionPatch(this.config.optionPatch, data))
|
|
1324
|
+
: option;
|
|
1325
|
+
const semanticSafeOption = stripRuntimeOptionSemantics(patchedOption, data);
|
|
1326
|
+
const sanitizedOption = sanitizeNonCartesian2DCoordinateAxes(
|
|
1327
|
+
sanitizeExternalGeoDependencies(semanticSafeOption),
|
|
1328
|
+
) as EChartsOption;
|
|
1329
|
+
return downgradeMatrixCoordinateOption(
|
|
1330
|
+
isRuntimeSeriesData(data)
|
|
1331
|
+
? sanitizeRuntimeCoordinateFreeSeriesOption(sanitizedOption)
|
|
1332
|
+
: sanitizedOption,
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* 对最终 ECharts option 上的 dataZoom 做一次兜底归一化,覆盖模板 optionPatch 之外的
|
|
1338
|
+
* dataZoom 来源(AI 注入、converter 内联、用户改卡等),保证运行时全量数据默认可见。
|
|
1339
|
+
* @param option - 已合并的最终 ECharts option
|
|
1340
|
+
* @param data - 协议数据载荷,用于判定是否存在真实运行时数据
|
|
1341
|
+
* @returns dataZoom 已被归一化为 start:0,end:100 的 option
|
|
1342
|
+
*/
|
|
1343
|
+
private normalizeRuntimeDataZoom(
|
|
1344
|
+
option: EChartsOption,
|
|
1345
|
+
data?: ProtocolDataPayload,
|
|
1346
|
+
): EChartsOption {
|
|
1347
|
+
return normalizeFinalDataZoom(option, data);
|
|
1348
|
+
}
|
|
1349
|
+
}
|