open-grid 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +376 -365
- package/dist/{OpenGrid-0r_543Kj.cjs → OpenGrid-B7m7ei7f.cjs} +1222 -1029
- package/dist/{OpenGrid-HmhGVC2V.js → OpenGrid-CeUdO_fM.js} +1613 -1418
- package/dist/index-CeJ-0-80.cjs +260 -0
- package/dist/index-DnarQ4eR.js +266 -0
- package/dist/index-DrCPRuYi.js +548 -0
- package/dist/index-JjfWY3Bt.cjs +520 -0
- package/dist/open-grid-base.css +12 -1
- package/dist/open-grid-react.cjs +1 -1
- package/dist/open-grid-react.js +1 -1
- package/dist/open-grid-vue.cjs +7 -7
- package/dist/open-grid-vue.js +2 -2
- package/dist/open-grid.cjs +1 -1
- package/dist/open-grid.js +2 -2
- package/dist/types/bench/perf.d.ts +14 -8
- package/dist/types/core/AppearanceResolver.d.ts +98 -11
- package/dist/types/core/CFRenderBridge.d.ts +13 -0
- package/dist/types/core/CellTypeRegistry.d.ts +24 -0
- package/dist/types/core/ColumnLayout.d.ts +100 -2
- package/dist/types/core/CrossGridMapper.d.ts +43 -5
- package/dist/types/core/DataLayer.d.ts +210 -15
- package/dist/types/core/DragVisuals.d.ts +33 -4
- package/dist/types/core/EventEmitter.d.ts +54 -0
- package/dist/types/core/FormulaEngine.d.ts +15 -4
- package/dist/types/core/GridRenderer.d.ts +143 -10
- package/dist/types/core/GroupEngine.d.ts +68 -10
- package/dist/types/core/MathUtils.d.ts +58 -5
- package/dist/types/core/MergeEngine.d.ts +45 -10
- package/dist/types/core/OGDecimal.d.ts +144 -13
- package/dist/types/core/OpenGrid.d.ts +99 -0
- package/dist/types/core/PivotEngine.d.ts +37 -0
- package/dist/types/core/RowDragDrop.d.ts +52 -6
- package/dist/types/core/SkinRegistry.d.ts +4 -0
- package/dist/types/core/TreeEngine.d.ts +60 -6
- package/dist/types/core/VirtualScroll.d.ts +64 -0
- package/dist/types/core/a11y/AccessibilityAdapter.d.ts +103 -0
- package/dist/types/core/a11y/AriaIntent.d.ts +34 -0
- package/dist/types/core/a11y/KeyboardInteractionModel.d.ts +64 -0
- package/dist/types/core/a11y/LiveRegionController.d.ts +89 -0
- package/dist/types/core/a11y/OverlayStack.d.ts +36 -0
- package/dist/types/core/a11y/VisualEquivRegistry.d.ts +37 -0
- package/dist/types/core/a11y/index.d.ts +13 -0
- package/dist/types/core/a11y/ports.d.ts +24 -0
- package/dist/types/core/appearance/Appearance.d.ts +68 -0
- package/dist/types/core/appearance/AppearanceAxis.d.ts +94 -0
- package/dist/types/core/appearance/AppearanceComposer.d.ts +45 -0
- package/dist/types/core/appearance/AppearanceProvider.d.ts +50 -0
- package/dist/types/core/appearance/AppearanceView.d.ts +51 -0
- package/dist/types/core/appearance/DensityRegistry.d.ts +36 -0
- package/dist/types/core/appearance/ResolvedAppearanceSnapshot.d.ts +84 -0
- package/dist/types/core/appearance/TextureRegistry.d.ts +32 -0
- package/dist/types/core/appearance/ThemeMetaRegistry.d.ts +67 -0
- package/dist/types/core/appearance/axisAdapters.d.ts +37 -0
- package/dist/types/core/appearance/defaults.d.ts +10 -0
- package/dist/types/core/appearance/index.d.ts +20 -0
- package/dist/types/core/appearance/tokenCatalog.d.ts +30 -0
- package/dist/types/core/cf/CFEngine.d.ts +56 -0
- package/dist/types/core/cf/CFEvaluator.d.ts +24 -0
- package/dist/types/core/cf/CFRule.d.ts +127 -0
- package/dist/types/core/cf/ColorScale.d.ts +49 -0
- package/dist/types/core/cf/InkResolver.d.ts +33 -0
- package/dist/types/core/cf/appearance.d.ts +20 -0
- package/dist/types/core/cf/encoders.d.ts +61 -0
- package/dist/types/core/cf/eval-types.d.ts +93 -0
- package/dist/types/core/cf/index.d.ts +21 -0
- package/dist/types/core/cf/lineage.d.ts +32 -0
- package/dist/types/core/cf/predicates.d.ts +27 -0
- package/dist/types/core/cf/serialize.d.ts +46 -0
- package/dist/types/core/chart/CanvasAdapter.d.ts +50 -1
- package/dist/types/core/chart/DataExtractor.d.ts +53 -12
- package/dist/types/core/chart/a11y.d.ts +22 -0
- package/dist/types/core/chart/chart-type-registry.d.ts +53 -0
- package/dist/types/core/chart/downsample-report.d.ts +36 -0
- package/dist/types/core/chart/downsample.d.ts +26 -1
- package/dist/types/core/chart/engine/ChartEngineRegistry.d.ts +52 -0
- package/dist/types/core/chart/geometry.d.ts +96 -0
- package/dist/types/core/chart/hittest.d.ts +21 -3
- package/dist/types/core/chart/palette.d.ts +96 -12
- package/dist/types/core/chart/parity.d.ts +12 -0
- package/dist/types/core/chart/provenance.d.ts +47 -0
- package/dist/types/core/chart/scales.d.ts +28 -1
- package/dist/types/core/chart/scene.d.ts +102 -0
- package/dist/types/core/chart/server.d.ts +36 -0
- package/dist/types/core/chart/surfaces/CanvasSurface.d.ts +48 -0
- package/dist/types/core/chart/surfaces/ServerRasterSurface.d.ts +26 -0
- package/dist/types/core/chart/surfaces/SvgSurface.d.ts +24 -0
- package/dist/types/core/chart/surfaces/pattern-overlay.d.ts +24 -0
- package/dist/types/core/command/CommandBus.d.ts +51 -0
- package/dist/types/core/command/CommandRegistry.d.ts +43 -0
- package/dist/types/core/command/CommandStack.d.ts +38 -0
- package/dist/types/core/command/ICommand.d.ts +110 -0
- package/dist/types/core/command/commands/CellWriteCommand.d.ts +32 -0
- package/dist/types/core/command/commands/CompositeCommand.d.ts +17 -0
- package/dist/types/core/command/commands/RowCommands.d.ts +39 -0
- package/dist/types/core/command/index.d.ts +9 -0
- package/dist/types/core/command/support.d.ts +51 -0
- package/dist/types/core/coordinate/ColumnMetrics.d.ts +30 -0
- package/dist/types/core/coordinate/CoordinateKernel.d.ts +88 -0
- package/dist/types/core/coordinate/FrozenPanes.d.ts +29 -0
- package/dist/types/core/coordinate/MergeSourceAdapter.d.ts +18 -0
- package/dist/types/core/coordinate/NodeBudget.d.ts +33 -0
- package/dist/types/core/coordinate/ResizeGovernor.d.ts +50 -0
- package/dist/types/core/coordinate/RowMetrics.d.ts +37 -0
- package/dist/types/core/coordinate/ViewPermutation.d.ts +23 -0
- package/dist/types/core/coordinate/index.d.ts +10 -0
- package/dist/types/core/coordinate/ports.d.ts +45 -0
- package/dist/types/core/coordinate/types.d.ts +76 -0
- package/dist/types/core/detail/DetailGlyph.d.ts +42 -7
- package/dist/types/core/detail/DetailSplice.d.ts +42 -11
- package/dist/types/core/detail/DetailState.d.ts +80 -11
- package/dist/types/core/detail/SubgridCache.d.ts +72 -10
- package/dist/types/core/detail/index.d.ts +8 -0
- package/dist/types/core/domain/AggregateResult.d.ts +54 -0
- package/dist/types/core/domain/CellAddress.d.ts +61 -0
- package/dist/types/core/domain/CellValueAccess.d.ts +29 -0
- package/dist/types/core/domain/Delta.d.ts +37 -0
- package/dist/types/core/domain/DomainValue.d.ts +80 -0
- package/dist/types/core/domain/Missing.d.ts +65 -0
- package/dist/types/core/domain/Money.d.ts +42 -0
- package/dist/types/core/domain/NormalizationBasis.d.ts +47 -0
- package/dist/types/core/domain/Plain.d.ts +45 -0
- package/dist/types/core/domain/Quantity.d.ts +32 -0
- package/dist/types/core/domain/Ratios.d.ts +100 -0
- package/dist/types/core/domain/ThresholdSet.d.ts +46 -0
- package/dist/types/core/domain/ValueType.d.ts +71 -0
- package/dist/types/core/domain/rounding.d.ts +25 -0
- package/dist/types/core/domain/strategies.d.ts +38 -0
- package/dist/types/core/editors/DateEditor.d.ts +18 -0
- package/dist/types/core/editors/SelectEditor.d.ts +29 -0
- package/dist/types/core/export/ChannelRegistry.d.ts +18 -0
- package/dist/types/core/export/ExportManifest.d.ts +13 -0
- package/dist/types/core/export/GridArtifactSource.d.ts +62 -0
- package/dist/types/core/export/Provenance.d.ts +34 -0
- package/dist/types/core/export/StreamPump.d.ts +28 -0
- package/dist/types/core/export/channels/CsvChannel.d.ts +20 -0
- package/dist/types/core/export/channels/JsonChannel.d.ts +18 -0
- package/dist/types/core/export/channels/XlsxChannel.d.ts +53 -0
- package/dist/types/core/export/channels/XmlChannel.d.ts +21 -0
- package/dist/types/core/export/channels/capabilities.d.ts +13 -0
- package/dist/types/core/export/index.d.ts +24 -0
- package/dist/types/core/export/print/OutputChannelAdapter.d.ts +61 -0
- package/dist/types/core/export/print/Paginator.d.ts +48 -0
- package/dist/types/core/export/print/PrintRenderTarget.d.ts +36 -0
- package/dist/types/core/export/sinks.d.ts +40 -0
- package/dist/types/core/export/types.d.ts +211 -0
- package/dist/types/core/extension/DeprecationManager.d.ts +42 -0
- package/dist/types/core/extension/IExtension.d.ts +90 -0
- package/dist/types/core/extension/Registry.d.ts +142 -0
- package/dist/types/core/extension/SlotRegistry.d.ts +46 -0
- package/dist/types/core/extension/adapters.d.ts +44 -0
- package/dist/types/core/extension/conformance.d.ts +47 -0
- package/dist/types/core/extension/index.d.ts +16 -0
- package/dist/types/core/extension/registries.d.ts +31 -0
- package/dist/types/core/extension/reserved.d.ts +10 -0
- package/dist/types/core/format/DisplayFormatter.d.ts +47 -0
- package/dist/types/core/format/FormatCache.d.ts +20 -0
- package/dist/types/core/format/FormatterRegistry.d.ts +22 -0
- package/dist/types/core/format/grammar/AstRenderer.d.ts +10 -0
- package/dist/types/core/format/grammar/FormatCompiler.d.ts +16 -0
- package/dist/types/core/format/index.d.ts +55 -0
- package/dist/types/core/format/pipeline/DomainTypeResolver.d.ts +8 -0
- package/dist/types/core/format/pipeline/LocaleFormat.d.ts +11 -0
- package/dist/types/core/format/pipeline/ValueInterpreter.d.ts +8 -0
- package/dist/types/core/format/policy/MaskPolicy.d.ts +8 -0
- package/dist/types/core/format/policy/NegativePolicy.d.ts +12 -0
- package/dist/types/core/format/policy/NullPolicy.d.ts +10 -0
- package/dist/types/core/format/policy/TruncatePolicy.d.ts +11 -0
- package/dist/types/core/format/types.d.ts +292 -0
- package/dist/types/core/formula/CalcCacheStore.d.ts +89 -0
- package/dist/types/core/formula/CalcProvenance.d.ts +44 -0
- package/dist/types/core/formula/CalcService.d.ts +137 -0
- package/dist/types/core/formula/CyclePathReporter.d.ts +28 -0
- package/dist/types/core/formula/FormulaEvaluator.d.ts +35 -1
- package/dist/types/core/formula/FormulaGraph.d.ts +84 -7
- package/dist/types/core/formula/FormulaParser.d.ts +9 -0
- package/dist/types/core/formula/FormulaStore.d.ts +63 -1
- package/dist/types/core/formula/FunctionRegistry.d.ts +138 -0
- package/dist/types/core/formula/Generation.d.ts +86 -0
- package/dist/types/core/formula/RecalcCoordinator.d.ts +151 -9
- package/dist/types/core/formula/ReferenceRewriter.d.ts +81 -0
- package/dist/types/core/formula/functions/essential.d.ts +3 -0
- package/dist/types/core/formula/functions/extended/index.d.ts +10 -0
- package/dist/types/core/formula/normalizeRefs.d.ts +34 -3
- package/dist/types/core/formula/numericLiteral.d.ts +11 -1
- package/dist/types/core/formula/serializeFormula.d.ts +10 -1
- package/dist/types/core/host/CapabilityRegistry.d.ts +61 -0
- package/dist/types/core/host/GridHostDriver.d.ts +27 -0
- package/dist/types/core/host/GridHostPort.d.ts +37 -0
- package/dist/types/core/host/SliceOwnershipGuard.d.ts +27 -0
- package/dist/types/core/host/archCheck.d.ts +26 -0
- package/dist/types/core/host/index.d.ts +6 -0
- package/dist/types/core/host/reconcile.d.ts +22 -0
- package/dist/types/core/i18n/LocaleContext.d.ts +40 -0
- package/dist/types/core/i18n/types.d.ts +26 -1
- package/dist/types/core/icons/bootstrap-icons.d.ts +4 -2
- package/dist/types/core/quality/ContrastAuditor.d.ts +64 -0
- package/dist/types/core/quality/DeterminismKernel.d.ts +68 -0
- package/dist/types/core/quality/PerfBaseline.d.ts +23 -0
- package/dist/types/core/quality/PerfSpec.d.ts +95 -0
- package/dist/types/core/quality/RealBrowserGate.d.ts +69 -0
- package/dist/types/core/quality/RegressionJudge.d.ts +35 -0
- package/dist/types/core/quality/ReleaseGate.d.ts +94 -0
- package/dist/types/core/quality/VisualRegression.d.ts +74 -0
- package/dist/types/core/quality/hooks.d.ts +53 -0
- package/dist/types/core/quality/index.d.ts +20 -0
- package/dist/types/core/quality/pixelMetrics.d.ts +24 -0
- package/dist/types/core/range/ClipboardCodec.d.ts +46 -4
- package/dist/types/core/range/FillEngine.d.ts +69 -9
- package/dist/types/core/range/RangeModel.d.ts +100 -13
- package/dist/types/core/range/types.d.ts +27 -11
- package/dist/types/core/realtime/BackpressureScheduler.d.ts +0 -0
- package/dist/types/core/realtime/FreshnessClock.d.ts +34 -0
- package/dist/types/core/realtime/IRealtimeSource.d.ts +82 -0
- package/dist/types/core/realtime/LiveStateGuard.d.ts +23 -0
- package/dist/types/core/realtime/PollingSource.d.ts +42 -0
- package/dist/types/core/realtime/RealtimeController.d.ts +54 -0
- package/dist/types/core/realtime/RtAnnouncePolicy.d.ts +53 -0
- package/dist/types/core/realtime/RtApplyCommand.d.ts +29 -0
- package/dist/types/core/realtime/RtChartTargetTrigger.d.ts +26 -0
- package/dist/types/core/realtime/StreamingSource.d.ts +47 -0
- package/dist/types/core/realtime/backoff.d.ts +12 -0
- package/dist/types/core/realtime/index.d.ts +13 -0
- package/dist/types/core/realtime/ports.d.ts +80 -0
- package/dist/types/core/render/CellApplier.d.ts +18 -0
- package/dist/types/core/render/CellErrorBoundary.d.ts +65 -0
- package/dist/types/core/render/CellPipeline.d.ts +39 -0
- package/dist/types/core/render/CellRenderRequest.d.ts +209 -0
- package/dist/types/core/render/CellStageRegistry.d.ts +53 -0
- package/dist/types/core/render/OverlayCompositor.d.ts +38 -0
- package/dist/types/core/render/RenderBudget.d.ts +67 -0
- package/dist/types/core/render/contrast.d.ts +33 -0
- package/dist/types/core/render/index.d.ts +35 -0
- package/dist/types/core/render/stages/BackgroundStage.d.ts +14 -0
- package/dist/types/core/render/stages/DecoratorStage.d.ts +12 -0
- package/dist/types/core/render/stages/OverlayStage.d.ts +12 -0
- package/dist/types/core/render/stages/ValueRendererStage.d.ts +15 -0
- package/dist/types/core/render/stages/index.d.ts +14 -0
- package/dist/types/core/state/AutosaveController.d.ts +63 -0
- package/dist/types/core/state/IStatePersistence.d.ts +59 -0
- package/dist/types/core/state/MultiTabGuard.d.ts +33 -0
- package/dist/types/core/state/SchemaMigrator.d.ts +33 -0
- package/dist/types/core/state/SemVerPolicy.d.ts +39 -0
- package/dist/types/core/state/StateCodec.d.ts +75 -0
- package/dist/types/core/state/index.d.ts +6 -0
- package/dist/types/core/types.d.ts +17 -0
- package/dist/types/react/OpenGrid.d.ts +54 -0
- package/dist/types/react/index.d.ts +5 -0
- package/dist/types/realtime/index.d.ts +1 -0
- package/dist/types/vue/index.d.ts +5 -0
- package/dist/types/vue/types.d.ts +35 -0
- package/package.json +112 -111
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ChartDataModelMeta } from './types.js';
|
|
2
|
+
/** 배지 종류(§9.4 통일 문법). / Badge kind (§9.4 unified grammar). */
|
|
3
|
+
export type BadgeKind = 'sampled' | 'aggregated' | 'negativesAbsInPie' | 'pieReducedToFirst' | 'truncatedAxis' | 'engineFallback' | 'unsupportedType';
|
|
4
|
+
/** 무결성 배지 한 건(위치·형태·상호작용은 렌더 계층, 여기선 데이터). / One integrity badge (data only). */
|
|
5
|
+
export interface ProvenanceBadge {
|
|
6
|
+
readonly kind: BadgeKind;
|
|
7
|
+
/** 배지 M(표시)/N(원본) — sampled 에서 채워짐(REQ-T6-810). / Badge M(shown)/N(source). */
|
|
8
|
+
readonly m?: number;
|
|
9
|
+
readonly n?: number;
|
|
10
|
+
/** 로케일 키(t 해석). / Locale key (resolved by t). */
|
|
11
|
+
readonly key: string;
|
|
12
|
+
/** 로케일 파라미터. / Locale params. */
|
|
13
|
+
readonly params?: Readonly<Record<string, string | number>>;
|
|
14
|
+
}
|
|
15
|
+
/** 차트 provenance(scene.meta 동행). / Chart provenance (travels with scene.meta). */
|
|
16
|
+
export interface ChartProvenance {
|
|
17
|
+
readonly badges: readonly ProvenanceBadge[];
|
|
18
|
+
/** 정상(무왜곡) 차트는 배지 0개(§9.3.4 게이트). / An honest (undistorted) chart has 0 badges. */
|
|
19
|
+
readonly clean: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** 추가 변환 플래그(meta 에 없는 절단축·엔진/타입 폴백). / Extra transform flags not in meta. */
|
|
22
|
+
export interface ProvenanceExtra {
|
|
23
|
+
/** line y축 절단(min≠0 opt-in) — 배지 강제(§9.3.1). / Truncated line y-axis (opt-in). */
|
|
24
|
+
truncatedAxis?: boolean;
|
|
25
|
+
/** 외부 엔진 미로드 → builtin 폴백(REQ-T6-812). / External engine fallback. */
|
|
26
|
+
engineFallback?: boolean;
|
|
27
|
+
/** 미지원 차트타입 → builtin 폴백(REQ-T6-812). / Unsupported chart type fallback. */
|
|
28
|
+
unsupportedType?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* meta(+extra) → provenance 배지 모델. 순수·결정론. 변형이 없으면 clean=true(배지 0).
|
|
32
|
+
* / meta (+extra) → provenance badge model. Pure & deterministic. clean=true (0 badges) when nothing transformed.
|
|
33
|
+
*
|
|
34
|
+
* @param meta - 차트 데이터 모델 메타 / Chart data model meta
|
|
35
|
+
* @param extra - 절단축·엔진/타입 폴백 플래그(선택) / Truncated-axis / engine-type fallback flags (optional)
|
|
36
|
+
* @returns provenance 배지 모델 / Provenance badge model
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildProvenance(meta: ChartDataModelMeta, extra?: ProvenanceExtra): ChartProvenance;
|
|
39
|
+
/**
|
|
40
|
+
* 배지 → 표시 문자열(로케일 t 주입). 산발 각주 대신 이 함수를 전 표면 공유(§9.4).
|
|
41
|
+
* / Badge → display string (inject locale t). Shared by all surfaces instead of scattered footnotes.
|
|
42
|
+
*
|
|
43
|
+
* @param badge - 배지 / The badge
|
|
44
|
+
* @param t - 로케일 해석기(키·파라미터 → 문자열). 미주입 시 폴백 영문 / Locale resolver; English fallback when absent
|
|
45
|
+
* @returns 표시 문자열 / Display string
|
|
46
|
+
*/
|
|
47
|
+
export declare function badgeText(badge: ProvenanceBadge, t?: (key: string, params?: Record<string, string | number>) => string): string;
|
|
@@ -1,24 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* F4 — nice-number 축 눈금 스케일(순수 함수, 헤드리스). §8.1(자동검증 대상 수학).
|
|
3
|
+
* / F4 — nice-number axis-tick scaling (pure functions, headless). §8.1 (auto-verified math).
|
|
3
4
|
*
|
|
4
5
|
* 표준 Heckbert "Nice Numbers for Graph Labels" 알고리즘. 목표 tick 수(default 6)에 맞춰
|
|
5
6
|
* step 을 1/2/5×10^n 중에서 선택하고, [min,max] 를 그 step 배수로 확장한다.
|
|
7
|
+
* / The standard Heckbert "Nice Numbers for Graph Labels" algorithm. It picks a step among
|
|
8
|
+
* 1/2/5×10^n to fit a target tick count (default 6) and expands [min,max] to multiples of that step.
|
|
6
9
|
*
|
|
7
10
|
* 한계(정직 명시): 이 알고리즘은 min=0 류의 "원점 기준" 범위에서는 매우 안정적으로
|
|
8
11
|
* tick 5~6개를 낸다(설계서 §8.1 문서화 예시 [0,97]→6 tick 포함). min≠0 인 임의 구간에서는
|
|
9
12
|
* step 후보가 {1,2,5,10} 로 성기어(coarse) tick 수가 4개나 7개로 튈 수 있다 — 표준 알고리즘의
|
|
10
13
|
* 알려진 한계이며, 본 구현은 문서화된 대표 입력(§8.1)에 대해서만 5~6 불변식을 보장한다.
|
|
14
|
+
* / Honest limitation: for origin-anchored ranges like min=0 the algorithm very stably yields
|
|
15
|
+
* 5–6 ticks (e.g. the documented §8.1 example [0,97]→6 ticks). For arbitrary ranges with min≠0
|
|
16
|
+
* the coarse {1,2,5,10} step candidates can make the tick count jump to 4 or 7 — a known
|
|
17
|
+
* limitation of the standard algorithm; this implementation guarantees the 5–6 invariant only for
|
|
18
|
+
* the documented representative inputs (§8.1).
|
|
11
19
|
*/
|
|
20
|
+
/** nice-number 스케일 결과(min/max/step 과 tick 배열). / A nice-number scale result (min/max/step and tick array). */
|
|
12
21
|
export interface NiceScale {
|
|
22
|
+
/** 확장된 최솟값. / Expanded minimum. */
|
|
13
23
|
min: number;
|
|
24
|
+
/** 확장된 최댓값. / Expanded maximum. */
|
|
14
25
|
max: number;
|
|
26
|
+
/** tick 간격. / Tick step. */
|
|
15
27
|
step: number;
|
|
28
|
+
/** tick 값 배열. / Array of tick values. */
|
|
16
29
|
ticks: number[];
|
|
17
30
|
}
|
|
18
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* range 를 1/2/5×10^n 중 하나로 반올림한다(round=true: 가장 가까운 값, false: 올림 쪽 느슨한 값).
|
|
33
|
+
* / Round a range to one of 1/2/5×10^n (round=true: nearest; false: looser round-up).
|
|
34
|
+
*
|
|
35
|
+
* @param range - 반올림할 범위 크기 / Range magnitude to round
|
|
36
|
+
* @param round - true=가장 가까운 nice 값, false=올림 쪽 / true = nearest nice value, false = round-up side
|
|
37
|
+
* @returns nice 값 / The nice value
|
|
38
|
+
*/
|
|
19
39
|
export declare function niceNum(range: number, round: boolean): number;
|
|
20
40
|
/**
|
|
21
41
|
* [dataMin,dataMax] → nice range/step/tick 배열(§8.1). maxTicks 는 목표 tick 수(default 6).
|
|
22
42
|
* dataMin===dataMax(degenerate) 이면 값 주변으로 인위 확장한다.
|
|
43
|
+
* / [dataMin,dataMax] → nice range/step/tick array (§8.1). maxTicks is the target tick count
|
|
44
|
+
* (default 6). A degenerate dataMin===dataMax is artificially expanded around the value.
|
|
45
|
+
*
|
|
46
|
+
* @param dataMin - 데이터 최솟값 / Data minimum
|
|
47
|
+
* @param dataMax - 데이터 최댓값 / Data maximum
|
|
48
|
+
* @param maxTicks - 목표 tick 수(기본 6) / Target tick count (default 6)
|
|
49
|
+
* @returns nice min/max/step 과 tick 배열 / Nice min/max/step and the tick array
|
|
23
50
|
*/
|
|
24
51
|
export declare function niceScale(dataMin: number, dataMax: number, maxTicks?: number): NiceScale;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ChartDataModel, ChartRenderSpec, ChartDataModelMeta, ChartSeries } from './types.js';
|
|
2
|
+
import { ChartGeometry } from './geometry.js';
|
|
3
|
+
import { patternOverlay, dashFor } from './surfaces/pattern-overlay.js';
|
|
4
|
+
/** 색 외 구분 패턴(§9.2). / Redundant (non-color) pattern (§9.2). */
|
|
5
|
+
export type SeriesPattern = NonNullable<ChartSeries['pattern']>;
|
|
6
|
+
/** 텍스트 정렬. / Text alignment. */
|
|
7
|
+
export type TextAlign = 'start' | 'center' | 'end';
|
|
8
|
+
/** 텍스트 기준선. / Text baseline. */
|
|
9
|
+
export type TextBaseline = 'top' | 'middle' | 'bottom';
|
|
10
|
+
/** 원시 드로우명령(타깃 무관). / Primitive draw command (target-agnostic). */
|
|
11
|
+
export type DrawPrim = {
|
|
12
|
+
readonly k: 'rect';
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
fill: string;
|
|
18
|
+
pattern?: SeriesPattern;
|
|
19
|
+
} | {
|
|
20
|
+
readonly k: 'polyline';
|
|
21
|
+
pts: ReadonlyArray<readonly [number, number]>;
|
|
22
|
+
stroke: string;
|
|
23
|
+
width: number;
|
|
24
|
+
dash?: readonly number[];
|
|
25
|
+
} | {
|
|
26
|
+
readonly k: 'circle';
|
|
27
|
+
cx: number;
|
|
28
|
+
cy: number;
|
|
29
|
+
r: number;
|
|
30
|
+
fill: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly k: 'line';
|
|
33
|
+
x1: number;
|
|
34
|
+
y1: number;
|
|
35
|
+
x2: number;
|
|
36
|
+
y2: number;
|
|
37
|
+
stroke: string;
|
|
38
|
+
width: number;
|
|
39
|
+
} | {
|
|
40
|
+
readonly k: 'text';
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
s: string;
|
|
44
|
+
fill: string;
|
|
45
|
+
align: TextAlign;
|
|
46
|
+
baseline: TextBaseline;
|
|
47
|
+
font: string;
|
|
48
|
+
} | {
|
|
49
|
+
readonly k: 'arc';
|
|
50
|
+
cx: number;
|
|
51
|
+
cy: number;
|
|
52
|
+
r: number;
|
|
53
|
+
a0: number;
|
|
54
|
+
a1: number;
|
|
55
|
+
fill: string;
|
|
56
|
+
pattern?: SeriesPattern;
|
|
57
|
+
};
|
|
58
|
+
/** 장면 = 배경→축→데이터→마커 순서의 원시명령 + 자기고지 메타. / Scene = ordered prims + self-declaring meta. */
|
|
59
|
+
export interface ChartScene {
|
|
60
|
+
readonly width: number;
|
|
61
|
+
readonly height: number;
|
|
62
|
+
readonly bg: string;
|
|
63
|
+
readonly prims: readonly DrawPrim[];
|
|
64
|
+
readonly geometry: ChartGeometry;
|
|
65
|
+
readonly meta: ChartDataModelMeta;
|
|
66
|
+
}
|
|
67
|
+
/** 렌더 타깃 종류. / Render target kind. */
|
|
68
|
+
export type RenderTargetKind = 'canvas' | 'svg' | 'server';
|
|
69
|
+
/** 장면을 백엔드 원시연산으로 번역하는 humble 어댑터. 로직·판단 없음(§2.3). / Humble scene→backend translator. */
|
|
70
|
+
export interface RenderSurface {
|
|
71
|
+
readonly kind: RenderTargetKind;
|
|
72
|
+
paint(scene: ChartScene): void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 순수: 완전 기하 → 드로우리스트(§2.2). 색/패턴은 palette 로 확정. **유일한 그림 결정 지점**.
|
|
76
|
+
* / Pure: complete geometry → draw list. Colors/patterns finalized via palette. The sole drawing-decision point.
|
|
77
|
+
*
|
|
78
|
+
* @param model - 차트 데이터 모델 / Chart data model
|
|
79
|
+
* @param spec - 렌더 스펙 / Render spec
|
|
80
|
+
* @param geometry - 공유 기하(computeChartGeometry 산출) / Shared geometry
|
|
81
|
+
* @param hidden - 숨긴 series 인덱스 / Hidden series indices
|
|
82
|
+
* @returns 타깃 무관 장면 / Target-agnostic scene
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildChartScene(model: ChartDataModel, spec: ChartRenderSpec, geometry: ChartGeometry, hidden?: ReadonlySet<number>): ChartScene;
|
|
85
|
+
/**
|
|
86
|
+
* 타깃 통일 진입점 — 계산은 공유(geometry+scene), surface 만 분기(§2.4). scene 반환(파리티 골든·hit-test).
|
|
87
|
+
* / Unified render entry — computation shared (geometry+scene), only the surface branches. Returns
|
|
88
|
+
* the scene (parity golden / hit-test).
|
|
89
|
+
*
|
|
90
|
+
* @param model - 차트 데이터 모델 / Chart data model
|
|
91
|
+
* @param spec - 렌더 스펙 / Render spec
|
|
92
|
+
* @param size - 렌더 크기 / Render size
|
|
93
|
+
* @param surface - 타깃 surface(humble) / Target surface (humble)
|
|
94
|
+
* @param hidden - 숨긴 series 인덱스 / Hidden series indices
|
|
95
|
+
* @returns 소비된 장면 / The consumed scene
|
|
96
|
+
*/
|
|
97
|
+
export declare function renderChart(model: ChartDataModel, spec: ChartRenderSpec, size: {
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
}, surface: RenderSurface, hidden?: ReadonlySet<number>): ChartScene;
|
|
101
|
+
/** scene 텍스처 오버레이 재노출(surface 공유). / Re-export texture overlay for surfaces. */
|
|
102
|
+
export { patternOverlay, dashFor };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChartDataModel, ChartRenderSpec } from './types.js';
|
|
2
|
+
import { ChartScene } from './scene.js';
|
|
3
|
+
import { IRasterizer } from './surfaces/ServerRasterSurface.js';
|
|
4
|
+
import { ChartProvenance, ProvenanceExtra } from './provenance.js';
|
|
5
|
+
/** 서버 렌더 옵션. / Server render options. */
|
|
6
|
+
export interface ServerRenderOptions {
|
|
7
|
+
/** PNG 픽셀화 주입(없으면 png 미산출, SVG 1급). / PNG rasterizer injection (no png without it). */
|
|
8
|
+
rasterizer?: IRasterizer;
|
|
9
|
+
/** DPR(서버 스케일). 기본 1. / DPR (server scale). Default 1. */
|
|
10
|
+
dpr?: number;
|
|
11
|
+
/** 숨긴 series 인덱스. / Hidden series indices. */
|
|
12
|
+
hidden?: ReadonlySet<number>;
|
|
13
|
+
/** 절단축·엔진/타입 폴백 배지 플래그. / Truncated-axis / engine-type fallback badge flags. */
|
|
14
|
+
provenance?: ProvenanceExtra;
|
|
15
|
+
}
|
|
16
|
+
/** 서버 렌더 결과(§2.5). png 는 rasterizer 주입 시에만. / Server render result. png only with a rasterizer. */
|
|
17
|
+
export interface ServerRenderResult {
|
|
18
|
+
readonly scene: ChartScene;
|
|
19
|
+
readonly svg: string;
|
|
20
|
+
readonly png?: Uint8Array;
|
|
21
|
+
readonly provenance: ChartProvenance;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 서버 헤드리스 렌더 — SVG·scene·provenance 항상 산출, PNG 는 opt-in. 클라이언트와 동일 scene.
|
|
25
|
+
* / Server headless render — always yields SVG/scene/provenance; PNG is opt-in. Same scene as client.
|
|
26
|
+
*
|
|
27
|
+
* @param spec - 렌더 스펙(타입·테마·포맷) / Render spec (type, theme, format)
|
|
28
|
+
* @param model - 차트 데이터 모델 / Chart data model
|
|
29
|
+
* @param size - 렌더 크기 / Render size
|
|
30
|
+
* @param opts - rasterizer·dpr·hidden·provenance(선택) / rasterizer·dpr·hidden·provenance (optional)
|
|
31
|
+
* @returns scene·svg·(png?)·provenance / scene·svg·(png?)·provenance
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderChartServer(spec: ChartRenderSpec, model: ChartDataModel, size: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}, opts?: ServerRenderOptions): ServerRenderResult;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ChartScene, RenderSurface } from '../scene.js';
|
|
2
|
+
type Ctx = {
|
|
3
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
4
|
+
clearRect(x: number, y: number, w: number, h: number): void;
|
|
5
|
+
beginPath(): void;
|
|
6
|
+
moveTo(x: number, y: number): void;
|
|
7
|
+
lineTo(x: number, y: number): void;
|
|
8
|
+
arc(cx: number, cy: number, r: number, a0: number, a1: number): void;
|
|
9
|
+
closePath(): void;
|
|
10
|
+
fill(): void;
|
|
11
|
+
stroke(): void;
|
|
12
|
+
fillRect(x: number, y: number, w: number, h: number): void;
|
|
13
|
+
fillText(s: string, x: number, y: number): void;
|
|
14
|
+
save(): void;
|
|
15
|
+
restore(): void;
|
|
16
|
+
clip(): void;
|
|
17
|
+
rect(x: number, y: number, w: number, h: number): void;
|
|
18
|
+
setLineDash(d: number[]): void;
|
|
19
|
+
fillStyle: string;
|
|
20
|
+
strokeStyle: string;
|
|
21
|
+
lineWidth: number;
|
|
22
|
+
font: string;
|
|
23
|
+
textAlign: string;
|
|
24
|
+
textBaseline: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* canvas 2D 로 scene 을 래스터화한다. constructor 에 canvas·dpr 을 주입받고, paint 시 ctx 를
|
|
28
|
+
* 해소한다(없으면 no-op). / Rasterizes a scene onto a canvas 2D context. Injects canvas/dpr;
|
|
29
|
+
* resolves the ctx at paint time (no-op if absent).
|
|
30
|
+
*/
|
|
31
|
+
export declare class CanvasSurface implements RenderSurface {
|
|
32
|
+
readonly kind: "canvas";
|
|
33
|
+
private _canvas;
|
|
34
|
+
private _dpr;
|
|
35
|
+
/**
|
|
36
|
+
* @param canvas - 렌더 대상 canvas(주입) / Target canvas (injected)
|
|
37
|
+
* @param dpr - devicePixelRatio(호스트 주입, 헤드리스 순수) / devicePixelRatio (host-injected, headless-pure)
|
|
38
|
+
*/
|
|
39
|
+
constructor(canvas: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
getContext?: (id: string) => Ctx | null;
|
|
43
|
+
}, dpr?: number);
|
|
44
|
+
paint(scene: ChartScene): void;
|
|
45
|
+
private _prim;
|
|
46
|
+
private _overlay;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChartScene, RenderSurface } from '../scene.js';
|
|
2
|
+
/** 주입형 래스터라이저 SPI(옵트인 애드온). scene 또는 SVG→PNG. / Injected rasterizer SPI (opt-in add-on). */
|
|
3
|
+
export interface IRasterizer {
|
|
4
|
+
/** scene 을 PNG 바이트로 래스터화(sharp/pngjs/resvg 등 호스트 제공). / Rasterize scene → PNG bytes. */
|
|
5
|
+
rasterize(scene: ChartScene): Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 서버 PNG surface — DOM/canvas 전역 없이 동작. rasterizer 미주입 시 toPNG()=throw.
|
|
9
|
+
* / Server PNG surface — works with no DOM/canvas globals. If no rasterizer, toPNG() throws.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ServerRasterSurface implements RenderSurface {
|
|
12
|
+
readonly kind: "server";
|
|
13
|
+
private _rasterizer;
|
|
14
|
+
private _scene;
|
|
15
|
+
/**
|
|
16
|
+
* @param rasterizer - 주입 래스터라이저(없으면 PNG 미산출) / Injected rasterizer (no PNG without it)
|
|
17
|
+
*/
|
|
18
|
+
constructor(rasterizer?: IRasterizer);
|
|
19
|
+
paint(scene: ChartScene): void;
|
|
20
|
+
/**
|
|
21
|
+
* 주입 rasterizer 로 PNG 산출(코어 미내장). 미주입/미paint 시 throw(불변식4).
|
|
22
|
+
* / Produce PNG via the injected rasterizer (not embedded in core). Throws if not injected / not painted.
|
|
23
|
+
* @returns PNG 바이트 / PNG bytes
|
|
24
|
+
*/
|
|
25
|
+
toPNG(): Uint8Array;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChartScene, RenderSurface } from '../scene.js';
|
|
2
|
+
/**
|
|
3
|
+
* scene 을 SVG 문자열로 래스터화하는 humble surface. `paint(scene)` 후 `toString()` 으로 완성 마크업.
|
|
4
|
+
* provenance(§9.4)는 `<title>/<desc>` 로 동행한다(REQ-T6-811).
|
|
5
|
+
* / Humble surface that rasterizes a scene into an SVG string. After `paint(scene)`, `toString()`
|
|
6
|
+
* yields the full markup. Provenance travels along in `<title>/<desc>` (REQ-T6-811).
|
|
7
|
+
*/
|
|
8
|
+
export declare class SvgSurface implements RenderSurface {
|
|
9
|
+
readonly kind: "svg";
|
|
10
|
+
private _dpr;
|
|
11
|
+
private _out;
|
|
12
|
+
/** @param opts.dpr - viewBox 배율(선택, 기본 1) / viewBox scale (optional, default 1) */
|
|
13
|
+
constructor(opts?: {
|
|
14
|
+
dpr?: number;
|
|
15
|
+
});
|
|
16
|
+
paint(scene: ChartScene): void;
|
|
17
|
+
/** 완성 <svg> 마크업(RT-803 서버 SVG 출력). / Full <svg> markup (RT-803 server SVG output). */
|
|
18
|
+
toString(): string;
|
|
19
|
+
private _desc;
|
|
20
|
+
private _prim;
|
|
21
|
+
private _overlay;
|
|
22
|
+
/** 파이 슬라이스 path(중심→호→닫기). / Pie-slice path (center → arc → close). */
|
|
23
|
+
private _arcPath;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SeriesPattern } from '../scene.js';
|
|
2
|
+
/** 오버레이 선분 [x1,y1,x2,y2]. / Overlay line segment. */
|
|
3
|
+
export type OverlaySeg = readonly [number, number, number, number];
|
|
4
|
+
/** 오버레이 점 [cx,cy,r]. / Overlay dot. */
|
|
5
|
+
export type OverlayDot = readonly [number, number, number];
|
|
6
|
+
/** 텍스처 오버레이 결과(선분·점). / Texture overlay result (segments + dots). */
|
|
7
|
+
export interface PatternOverlay {
|
|
8
|
+
readonly segs: readonly OverlaySeg[];
|
|
9
|
+
readonly dots: readonly OverlayDot[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 사각형 안의 색약 안전 텍스처 좌표(§9.2). solid/undefined → 빈 오버레이.
|
|
13
|
+
* / Colorblind-safe texture coordinates inside a rect. solid/undefined → empty overlay.
|
|
14
|
+
*
|
|
15
|
+
* @param x - 사각형 좌상단 x / Rect top-left x
|
|
16
|
+
* @param y - 사각형 좌상단 y / Rect top-left y
|
|
17
|
+
* @param w - 너비 / Width
|
|
18
|
+
* @param h - 높이 / Height
|
|
19
|
+
* @param pattern - 패턴 종류 / Pattern kind
|
|
20
|
+
* @returns 텍스처 선분·점 좌표 / Texture segments and dots
|
|
21
|
+
*/
|
|
22
|
+
export declare function patternOverlay(x: number, y: number, w: number, h: number, pattern: SeriesPattern | undefined): PatternOverlay;
|
|
23
|
+
/** line/area 대시 배열(현 CanvasAdapter.dashFor 와 동일). / Line dash array (matches CanvasAdapter.dashFor). */
|
|
24
|
+
export declare function dashFor(pattern: SeriesPattern | undefined): number[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ICommand, ICommandCtx } from './ICommand.js';
|
|
2
|
+
import { CommandStack } from './CommandStack.js';
|
|
3
|
+
import { DirtyTracker, MutationGuard, AuditLog } from './support.js';
|
|
4
|
+
/** CommandBus 협력자(전부 옵션 — 기본 구현 주입). / CommandBus collaborators (all optional — defaults injected). */
|
|
5
|
+
export interface CommandBusDeps<T = any> {
|
|
6
|
+
readonly ctx: ICommandCtx<T>;
|
|
7
|
+
stack?: CommandStack<T>;
|
|
8
|
+
audit?: AuditLog;
|
|
9
|
+
dirty?: DirtyTracker;
|
|
10
|
+
guard?: MutationGuard;
|
|
11
|
+
/** 자동저장/협업/감사 구독 fan-out. / Fan-out for autosave/collaboration/audit subscribers. */
|
|
12
|
+
emit?: (event: 'command', cmd: ICommand<T>) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 유일한 쓰기 진입점. 이벤트 오케스트레이션(DD-08/896)이 UI 이벤트를 커맨드로 번역해 여기로 보낸다.
|
|
16
|
+
* / The sole write entry point. Event orchestration (DD-08/896) translates UI events into commands here.
|
|
17
|
+
*/
|
|
18
|
+
export declare class CommandBus<T = any> {
|
|
19
|
+
private readonly _ctx;
|
|
20
|
+
private readonly _stack;
|
|
21
|
+
private readonly _audit;
|
|
22
|
+
private readonly _dirty;
|
|
23
|
+
private readonly _guard;
|
|
24
|
+
private readonly _emit;
|
|
25
|
+
private _macro;
|
|
26
|
+
private _macroLabel;
|
|
27
|
+
constructor(deps: CommandBusDeps<T>);
|
|
28
|
+
get stack(): CommandStack<T>;
|
|
29
|
+
get audit(): AuditLog;
|
|
30
|
+
get dirty(): DirtyTracker;
|
|
31
|
+
get guard(): MutationGuard;
|
|
32
|
+
/**
|
|
33
|
+
* 커맨드 실행: do → 스택 push(coalesce 시도) → audit → dirty → emit. 매크로 녹화 중이면 스택 대신
|
|
34
|
+
* 프레임에 수집(그대로 실행됨). / Execute a command; while recording a macro, collect into the frame instead of the stack.
|
|
35
|
+
*/
|
|
36
|
+
dispatch(cmd: ICommand<T>): void;
|
|
37
|
+
/** 되돌리기: 스택에서 꺼내 undo 재적용. / Undo: pop and apply undo. */
|
|
38
|
+
undo(): boolean;
|
|
39
|
+
/** 다시하기: 스택에서 꺼내 do 재적용. / Redo: pop and re-apply do. */
|
|
40
|
+
redo(): boolean;
|
|
41
|
+
canUndo(): boolean;
|
|
42
|
+
canRedo(): boolean;
|
|
43
|
+
/** 매크로 녹화 시작 — 이후 dispatch 는 프레임에 수집(실행은 됨). / Begin macro recording. */
|
|
44
|
+
beginMacro(label: string): void;
|
|
45
|
+
/** 매크로 중지 — 수집분을 CompositeCommand 로 접어 단일 undo 단위로 스택에 등록. / End macro; fold into one undo unit. */
|
|
46
|
+
endMacro(): void;
|
|
47
|
+
/** 트랜잭션 배치 — body 안의 dispatch 를 하나의 undo 단위로. 예외 시에도 endMacro 로 닫는다. / Transaction batch. */
|
|
48
|
+
transact(label: string, body: () => void): void;
|
|
49
|
+
/** 녹화 중 여부. / Whether a macro is being recorded. */
|
|
50
|
+
get recording(): boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IRegistry, RegisterOptions } from '../extension/Registry.js';
|
|
2
|
+
import { ICommand, CommandDTO } from './ICommand.js';
|
|
3
|
+
import { CompositeCommand } from './commands/CompositeCommand.js';
|
|
4
|
+
import { CellWriteCommand } from './commands/CellWriteCommand.js';
|
|
5
|
+
import { RowInsertCommand, RowDeleteCommand } from './commands/RowCommands.js';
|
|
6
|
+
/** 커맨드 종류 등록 명세(payload 버저닝·복원). / Command-kind registration spec (payload versioning + restore). */
|
|
7
|
+
export interface CommandSpec<T = any> {
|
|
8
|
+
/** payload 최신 스키마 버전(커맨드 단위). 봉투 schemaVersion 과 독립 진화. / Latest payload schema version. */
|
|
9
|
+
readonly payloadVersion: number;
|
|
10
|
+
/** 구버전 payload → 최신 payload 마이그레이션(없으면 동일버전만 허용). / Old payload → latest migration. */
|
|
11
|
+
migratePayload?(payload: unknown, from: number): unknown;
|
|
12
|
+
/** payload → 살아있는 커맨드. / payload → live command. */
|
|
13
|
+
fromPayload(payload: unknown): ICommand<T>;
|
|
14
|
+
}
|
|
15
|
+
/** 미등록 kind / 미지 상위버전 재수화 실패(조용한 스킵 금지). / Rehydrate failure (never silent-skip). */
|
|
16
|
+
export declare class RehydrateError extends Error {
|
|
17
|
+
readonly kind: string;
|
|
18
|
+
constructor(kind: string, reason: string);
|
|
19
|
+
}
|
|
20
|
+
/** kind → (DTO 역직렬화기). 커스텀 커맨드도 이 포트로 등록돼 매크로/협업 재생에 참여. / kind → DTO deserializer. */
|
|
21
|
+
export interface CommandRegistry<T = any> {
|
|
22
|
+
register(kind: string, spec: CommandSpec<T>, opts?: RegisterOptions): void;
|
|
23
|
+
/** DTO → ICommand 복원. 미등록 kind = 정의된 오류(throw). / DTO → ICommand; unknown kind throws. */
|
|
24
|
+
rehydrate(dto: CommandDTO): ICommand<T>;
|
|
25
|
+
has(kind: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* DD-10 IRegistry 동형 기본 구현(C1). 내장 커맨드(cell.write·row.insert·row.delete·composite)를
|
|
29
|
+
* 부트스트랩하고, 커스텀 kind 를 register 로 확장한다. composite 는 자식 DTO 를 재귀 재수화한다.
|
|
30
|
+
* / Default IRegistry-homomorphic implementation (C1). Bootstraps built-in commands and lets custom
|
|
31
|
+
* kinds extend via register; composite recursively rehydrates its children.
|
|
32
|
+
*/
|
|
33
|
+
export declare class DefaultCommandRegistry<T = any> implements CommandRegistry<T> {
|
|
34
|
+
private readonly _reg;
|
|
35
|
+
constructor(reg?: IRegistry<CommandSpec<T>>);
|
|
36
|
+
private _registerBuiltins;
|
|
37
|
+
register(kind: string, spec: CommandSpec<T>, opts?: RegisterOptions): void;
|
|
38
|
+
has(kind: string): boolean;
|
|
39
|
+
rehydrate(dto: CommandDTO): ICommand<T>;
|
|
40
|
+
/** C1: 내부 IRegistry 노출(진단·override 표면 편입용). / C1: expose the inner IRegistry (diagnostics/override surface). */
|
|
41
|
+
get registry(): IRegistry<CommandSpec<T>>;
|
|
42
|
+
}
|
|
43
|
+
export { CellWriteCommand, RowInsertCommand, RowDeleteCommand, CompositeCommand };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ICommand, CommandDTO } from './ICommand.js';
|
|
2
|
+
/** CommandStack 구성. / CommandStack configuration. */
|
|
3
|
+
export interface CommandStackConfig {
|
|
4
|
+
/** undo 스택 최대 깊이. 기본 200. / Max undo depth. Default 200. */
|
|
5
|
+
capacity?: number;
|
|
6
|
+
/** 인접 coalesce 시간 창(ms). 기본 500. / Adjacency coalesce window (ms). Default 500. */
|
|
7
|
+
coalesceWindowMs?: number;
|
|
8
|
+
/** 시각 소스(테스트 주입). 기본 Date.now. / Time source (test-injectable). Default Date.now. */
|
|
9
|
+
now?: () => number;
|
|
10
|
+
}
|
|
11
|
+
/** undo/redo 이중 스택. / undo/redo double stack. */
|
|
12
|
+
export declare class CommandStack<T = any> {
|
|
13
|
+
private _undo;
|
|
14
|
+
private _redo;
|
|
15
|
+
private _lastPushAt;
|
|
16
|
+
private readonly _cap;
|
|
17
|
+
private readonly _win;
|
|
18
|
+
private readonly _now;
|
|
19
|
+
constructor(cfg?: CommandStackConfig);
|
|
20
|
+
/**
|
|
21
|
+
* 커맨드를 스택에 올린다. 최근 커맨드와 시간 창 내이고 coalesce 가 병합을 반환하면 접는다.
|
|
22
|
+
* 새 엔트리는 redo 스택을 비운다(분기 방지).
|
|
23
|
+
* / Push a command; fold into the top if within the window and its coalesce returns a merge.
|
|
24
|
+
* A new entry clears the redo stack (no branching).
|
|
25
|
+
*/
|
|
26
|
+
push(cmd: ICommand<T>): void;
|
|
27
|
+
/** 최근 undo 엔트리를 꺼내 redo 로 옮긴다(호출자가 undo 실행). / Pop the latest undo entry onto redo. */
|
|
28
|
+
popUndo(): ICommand<T> | null;
|
|
29
|
+
/** 최근 redo 엔트리를 꺼내 undo 로 되돌린다(호출자가 do 재실행). / Pop the latest redo entry back onto undo. */
|
|
30
|
+
popRedo(): ICommand<T> | null;
|
|
31
|
+
canUndo(): boolean;
|
|
32
|
+
canRedo(): boolean;
|
|
33
|
+
clear(): void;
|
|
34
|
+
get undoDepth(): number;
|
|
35
|
+
get redoDepth(): number;
|
|
36
|
+
/** undo 이력 영속화용 직렬화(선택). / Serialize the undo history (optional persistence). */
|
|
37
|
+
serializeHistory(): CommandDTO[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dirty·부분저장·협업 병합용 변경 지문. 커맨드가 만지는 범위를 데이터로 신고한다.
|
|
3
|
+
* / Change footprint for dirty tracking / partial save / collaboration merge.
|
|
4
|
+
*/
|
|
5
|
+
export type CommandFootprint = {
|
|
6
|
+
readonly scope: 'cell';
|
|
7
|
+
readonly rowId: string;
|
|
8
|
+
readonly field: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly scope: 'row';
|
|
11
|
+
readonly rowIds: readonly string[];
|
|
12
|
+
} | {
|
|
13
|
+
readonly scope: 'range';
|
|
14
|
+
readonly rowIds: readonly string[];
|
|
15
|
+
readonly fields: readonly string[];
|
|
16
|
+
} | {
|
|
17
|
+
readonly scope: 'structure';
|
|
18
|
+
} | {
|
|
19
|
+
readonly scope: 'meta';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 직렬화 커맨드(매크로 스텝·협업 op·감사 레코드 공통). 값·좌표는 stable rowId 로 최소 재구성 정보만.
|
|
23
|
+
* / Serialized command (shared by macro step / collaboration op / audit record).
|
|
24
|
+
*/
|
|
25
|
+
export interface CommandDTO {
|
|
26
|
+
readonly kind: string;
|
|
27
|
+
readonly payload: unknown;
|
|
28
|
+
/** 동결 시각(재생 결정론). / Frozen timestamp (replay determinism). */
|
|
29
|
+
readonly at: number;
|
|
30
|
+
/** 협업 actorId(옵션). / Collaboration actor id (optional). */
|
|
31
|
+
readonly actor?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 커맨드가 모델을 만지는 유일한 표면 — 기존 MutationService(mutate→render→emit)를 1:1 위임(회귀 0).
|
|
35
|
+
* DD-09 는 이 파사드로만 위임하며 렌더/emit 내부를 모른다(§2.9).
|
|
36
|
+
* / The only surface a command uses to touch the model — delegates 1:1 to the existing
|
|
37
|
+
* MutationService (mutate→render→emit); DD-09 has no knowledge of render/emit internals.
|
|
38
|
+
*/
|
|
39
|
+
export interface MutationServiceFacade<T = any> {
|
|
40
|
+
writeCell(rowIndex: number, field: string, value: unknown): void;
|
|
41
|
+
writeCells(patches: ReadonlyArray<{
|
|
42
|
+
rowIndex: number;
|
|
43
|
+
field: string;
|
|
44
|
+
value: unknown;
|
|
45
|
+
}>): number;
|
|
46
|
+
insertRow(item: Partial<T>, position?: number | 'first' | 'last' | 'before' | 'after'): void;
|
|
47
|
+
deleteRows(indices: readonly number[]): void;
|
|
48
|
+
beginBatch(): void;
|
|
49
|
+
endBatch(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 도메인 좌표 해석(flat index ⇄ stable rowId) + 값/스냅샷 읽기. undo 안정성의 근간(§3.2):
|
|
53
|
+
* 커맨드는 좌표를 rowId 로만 앵커하고 실행 시점에 index 로 해소한다(구조 변경에 안전).
|
|
54
|
+
* / Domain coordinate resolution (flat index ⇄ stable rowId) plus value/snapshot reads.
|
|
55
|
+
*/
|
|
56
|
+
export interface CoordResolver {
|
|
57
|
+
rowCount(): number;
|
|
58
|
+
rowIdAt(index: number): string | undefined;
|
|
59
|
+
/** 미존재 → -1. / Absent → -1. */
|
|
60
|
+
indexOf(rowId: string): number;
|
|
61
|
+
getCellValue(rowId: string, field: string): unknown;
|
|
62
|
+
getRowSnapshot(rowId: string): Record<string, unknown> | undefined;
|
|
63
|
+
}
|
|
64
|
+
/** 값 객체 동치성(DD-01 위임) — coalesce/oldValue 비교. / Value-object equality (delegated to DD-01). */
|
|
65
|
+
export interface ValueEquality {
|
|
66
|
+
equals(a: unknown, b: unknown): boolean;
|
|
67
|
+
}
|
|
68
|
+
/** 재생 결정론용 동결 시계(do 시 캡처, undo/replay 는 캡처값 사용). / Frozen clock for replay determinism. */
|
|
69
|
+
export interface FrozenClock {
|
|
70
|
+
now(): number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 커맨드 실행 문맥 — do/undo 가 받는 협력자 묶음. / Command execution context passed to do/undo.
|
|
74
|
+
*/
|
|
75
|
+
export interface ICommandCtx<T = any> {
|
|
76
|
+
readonly mutation: MutationServiceFacade<T>;
|
|
77
|
+
readonly coords: CoordResolver;
|
|
78
|
+
readonly values: ValueEquality;
|
|
79
|
+
readonly clock: FrozenClock;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 모든 모델 변이의 원자. do/undo/coalesce/serialize 4대 계약(§2.1).
|
|
83
|
+
* DD-10 `IExtension` 정합: `kind` 가 확장 식별자(=IExtension.id 역할), `spi` 표식이 확장 계약군 소속을 나타냄.
|
|
84
|
+
* / The atom of every model mutation (do/undo/coalesce/serialize). Aligns with DD-10 IExtension:
|
|
85
|
+
* `kind` acts as the extension id and `spi` marks membership in the extension-contract family.
|
|
86
|
+
*/
|
|
87
|
+
export interface ICommand<T = any> {
|
|
88
|
+
/** DD-10 IExtension 정합 표식(SPI). / DD-10 IExtension alignment marker. */
|
|
89
|
+
readonly spi?: 'command';
|
|
90
|
+
/** 안정 커맨드 종류 id(레지스트리 키·직렬화 태그). 예: 'cell.write'. / Stable command-kind id. */
|
|
91
|
+
readonly kind: string;
|
|
92
|
+
/** 사람이 읽는 라벨(undo 메뉴/감사) — i18n 키. / Human-readable label (i18n key). */
|
|
93
|
+
readonly label: string;
|
|
94
|
+
/** 이 커맨드가 만지는 dirty 범위. / Dirty footprint this command touches. */
|
|
95
|
+
readonly footprint: CommandFootprint;
|
|
96
|
+
/** 정방향 적용. 되돌림에 필요한 역정보(inverse)를 do 시점에 포획(불변식 §2). / Apply forward; capture inverse at do-time. */
|
|
97
|
+
do(ctx: ICommandCtx<T>): void;
|
|
98
|
+
/** 역방향 적용. do 가 포획한 inverse 로 관측 상태를 do 직전으로 복원. / Apply inverse to restore pre-do state. */
|
|
99
|
+
undo(ctx: ICommandCtx<T>): void;
|
|
100
|
+
/** 인접 병합(선택). 하나의 undo 단위로 접을 수 있으면 병합 커맨드 반환, 아니면 null. / Optional adjacent coalesce. */
|
|
101
|
+
coalesce?(next: ICommand<T>): ICommand<T> | null;
|
|
102
|
+
/** 직렬화(매크로·감사·협업). schemaVersion 은 봉투의 몫 — 여기선 payload 만. / Serialize (payload only). */
|
|
103
|
+
serialize(): CommandDTO;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 기본 값 동치성 — 참조/Object.is + 값객체 `equals` 존재 시 위임(DD-01). / Default value equality.
|
|
107
|
+
*/
|
|
108
|
+
export declare const defaultValueEquality: ValueEquality;
|
|
109
|
+
/** 실제 시스템 시계(비테스트 기본). / Real system clock (default outside tests). */
|
|
110
|
+
export declare const systemClock: FrozenClock;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ICommand, ICommandCtx, CommandDTO, CommandFootprint } from '../ICommand.js';
|
|
2
|
+
/**
|
|
3
|
+
* 셀 하나에 값을 쓰는 커맨드. `old` 를 주면 이미 포획된 것으로 간주(coalesce 병합 산출물).
|
|
4
|
+
* / Writes a value to a single cell. If `old` is supplied it is treated as already captured
|
|
5
|
+
* (produced by a coalesce merge).
|
|
6
|
+
*/
|
|
7
|
+
export declare class CellWriteCommand<T = any> implements ICommand<T> {
|
|
8
|
+
readonly rowId: string;
|
|
9
|
+
readonly field: string;
|
|
10
|
+
readonly newValue: unknown;
|
|
11
|
+
readonly spi: "command";
|
|
12
|
+
readonly kind = "cell.write";
|
|
13
|
+
readonly label = "cmd.cellWrite";
|
|
14
|
+
private _old;
|
|
15
|
+
private _captured;
|
|
16
|
+
private _at;
|
|
17
|
+
constructor(rowId: string, field: string, newValue: unknown, old?: {
|
|
18
|
+
readonly value: unknown;
|
|
19
|
+
});
|
|
20
|
+
get footprint(): CommandFootprint;
|
|
21
|
+
do(ctx: ICommandCtx<T>): void;
|
|
22
|
+
undo(ctx: ICommandCtx<T>): void;
|
|
23
|
+
/**
|
|
24
|
+
* 같은 (rowId,field) CellWrite 면 병합: old 는 '나의 최초 old', new 는 'next 의 new'.
|
|
25
|
+
* undo 하면 최초 old 로 한 번에 복원(불변식 §2).
|
|
26
|
+
* / Merge with a next CellWrite on the same (rowId,field): keep my original old, take next's new.
|
|
27
|
+
*/
|
|
28
|
+
coalesce(next: ICommand<T>): ICommand<T> | null;
|
|
29
|
+
serialize(): CommandDTO;
|
|
30
|
+
}
|
|
31
|
+
/** DTO payload → CellWriteCommand(직렬화 복원). / Rehydrate a CellWriteCommand from a DTO payload. */
|
|
32
|
+
export declare function cellWriteFromPayload<T = any>(payload: unknown): CellWriteCommand<T>;
|