@nikkory/vibe-engine 4.0.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/PUBLISH-GUIDE.md +250 -0
- package/README.md +1267 -0
- package/bin/vibe.js +22 -0
- package/dist/adapters/index.d.ts +19 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +15083 -0
- package/dist/browser.mjs +15000 -0
- package/dist/cli/batch-command.d.ts +142 -0
- package/dist/cli/generate-command.d.ts +119 -0
- package/dist/cli/index.d.ts +34 -0
- package/dist/constants/ComponentTypes.d.ts +65 -0
- package/dist/constants/DesignSystems.d.ts +64 -0
- package/dist/constants/Frameworks.d.ts +71 -0
- package/dist/constants/Tiers.d.ts +72 -0
- package/dist/constants/index.d.ts +10 -0
- package/dist/converters/index.d.ts +12 -0
- package/dist/converters/section-converter.d.ts +176 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +19819 -0
- package/dist/index.mjs +19496 -0
- package/dist/resolution/basic/groups-basic.d.ts +80 -0
- package/dist/resolution/basic/index.d.ts +21 -0
- package/dist/resolution/basic/intents-basic.d.ts +195 -0
- package/dist/resolution/basic/presets-basic.d.ts +96 -0
- package/dist/resolution/basic/resolver-basic.d.ts +127 -0
- package/dist/resolution/basic/shorthands-basic.d.ts +88 -0
- package/dist/resolution/core/groups-core.d.ts +160 -0
- package/dist/resolution/core/index.d.ts +21 -0
- package/dist/resolution/core/intents-core.d.ts +355 -0
- package/dist/resolution/core/presets-core.d.ts +160 -0
- package/dist/resolution/core/resolver-core.d.ts +207 -0
- package/dist/resolution/core/shorthands-core.d.ts +144 -0
- package/dist/resolution/core/types-core.d.ts +167 -0
- package/dist/resolution/debugger.d.ts +183 -0
- package/dist/resolution/demo.d.ts +57 -0
- package/dist/resolution/enterprise/index.d.ts +22 -0
- package/dist/resolution/enterprise/metrics.d.ts +152 -0
- package/dist/resolution/enterprise/resolver-enterprise.d.ts +108 -0
- package/dist/resolution/examples.d.ts +486 -0
- package/dist/resolution/groups/experience-group.d.ts +197 -0
- package/dist/resolution/groups/index.d.ts +196 -0
- package/dist/resolution/groups/layout-group.d.ts +192 -0
- package/dist/resolution/groups/motion-group.d.ts +127 -0
- package/dist/resolution/groups/visual-group.d.ts +146 -0
- package/dist/resolution/index.d.ts +41 -0
- package/dist/resolution/intents/button-intents.d.ts +231 -0
- package/dist/resolution/intents/card-intents.d.ts +177 -0
- package/dist/resolution/intents/feedback-intents.d.ts +222 -0
- package/dist/resolution/intents/index.d.ts +189 -0
- package/dist/resolution/intents/input-intents.d.ts +231 -0
- package/dist/resolution/intents/mood-modifiers.d.ts +154 -0
- package/dist/resolution/performance.d.ts +264 -0
- package/dist/resolution/presets/button-presets.d.ts +243 -0
- package/dist/resolution/presets/card-presets.d.ts +216 -0
- package/dist/resolution/presets/data-display-presets.d.ts +290 -0
- package/dist/resolution/presets/feedback-presets.d.ts +335 -0
- package/dist/resolution/presets/form-presets.d.ts +308 -0
- package/dist/resolution/presets/index.d.ts +22 -0
- package/dist/resolution/presets/input-presets.d.ts +207 -0
- package/dist/resolution/presets/nav-presets.d.ts +235 -0
- package/dist/resolution/presets/overlay-presets.d.ts +216 -0
- package/dist/resolution/presets/preset-registry.d.ts +212 -0
- package/dist/resolution/resolveProps.d.ts +235 -0
- package/dist/resolution/shorthand/feel-mappings.d.ts +140 -0
- package/dist/resolution/shorthand/index.d.ts +172 -0
- package/dist/resolution/shorthand/look-mappings.d.ts +107 -0
- package/dist/resolution/shorthand/spacing-mappings.d.ts +164 -0
- package/dist/resolution/shorthand/surface-mappings.d.ts +139 -0
- package/dist/resolution/standard/groups-standard.d.ts +98 -0
- package/dist/resolution/standard/index.d.ts +28 -0
- package/dist/resolution/standard/intents-standard.d.ts +232 -0
- package/dist/resolution/standard/presets-standard.d.ts +123 -0
- package/dist/resolution/standard/resolver-standard.d.ts +204 -0
- package/dist/resolution/standard/shorthands-standard.d.ts +98 -0
- package/dist/resolution/standard/validators.d.ts +141 -0
- package/dist/resolution/types.d.ts +461 -0
- package/dist/resolution/validators/factor24-validator.d.ts +418 -0
- package/dist/resolution/validators/index.d.ts +14 -0
- package/dist/scripts/generate-react-library.d.ts +15 -0
- package/dist/scripts/write-react-library.d.ts +18 -0
- package/dist/storage/cloud-sync.d.ts +182 -0
- package/dist/storage/index.d.ts +69 -0
- package/dist/storage/local-storage.d.ts +131 -0
- package/dist/storage/section-storage.d.ts +191 -0
- package/dist/styling/StyleGenerator.d.ts +76 -0
- package/dist/styling/TokenStyleResolver.d.ts +163 -0
- package/dist/styling/factor-migration.d.ts +192 -0
- package/dist/styling/factor-validators.d.ts +327 -0
- package/dist/styling/factors-1-6.d.ts +674 -0
- package/dist/styling/factors-12-16.d.ts +700 -0
- package/dist/styling/factors-17-24.d.ts +668 -0
- package/dist/styling/factors-all.d.ts +348 -0
- package/dist/styling/factors.d.ts +291 -0
- package/dist/styling/index.d.ts +31 -0
- package/dist/styling/types.d.ts +400 -0
- package/dist/tokens/schema.d.ts +486 -0
- package/dist/types/Option.d.ts +178 -0
- package/dist/types/Result.d.ts +148 -0
- package/dist/types/algorithm-engine.types.d.ts +298 -0
- package/dist/types/granularity/base.types.d.ts +268 -0
- package/dist/types/granularity/config.types.d.ts +177 -0
- package/dist/types/granularity/factors.types.d.ts +194 -0
- package/dist/types/granularity/index.d.ts +57 -0
- package/dist/types/granularity/slot.types.d.ts +128 -0
- package/dist/types/granularity/template.types.d.ts +179 -0
- package/dist/types/granularity-levels/atom.config.d.ts +151 -0
- package/dist/types/granularity-levels/component.config.d.ts +175 -0
- package/dist/types/granularity-levels/index.d.ts +47 -0
- package/dist/types/granularity-levels/layout.config.d.ts +278 -0
- package/dist/types/granularity-levels/page.config.d.ts +210 -0
- package/dist/types/granularity-levels/section.config.d.ts +188 -0
- package/dist/types/granularity-levels/template.config.d.ts +340 -0
- package/dist/types/index.d.ts +152 -0
- package/dist/types/section-slot.types.d.ts +169 -0
- package/dist/types/section-storage.types.d.ts +298 -0
- package/dist/types/section-template.types.d.ts +170 -0
- package/dist/types/section.types.d.ts +326 -0
- package/dist/ui-studio/ComponentGenerator.d.ts +219 -0
- package/dist/ui-studio/composition/FactorPropagator.d.ts +268 -0
- package/dist/ui-studio/composition/PageGenerator.d.ts +176 -0
- package/dist/ui-studio/composition/SectionGenerator.d.ts +312 -0
- package/dist/ui-studio/composition/SlotResolver.d.ts +295 -0
- package/dist/ui-studio/composition/section-orchestrator.d.ts +306 -0
- package/dist/ui-studio/granularity/FactorCascade.d.ts +328 -0
- package/dist/ui-studio/granularity/GranularityGenerator.d.ts +266 -0
- package/dist/ui-studio/granularity/RecursiveGenerator.d.ts +328 -0
- package/dist/ui-studio/index.d.ts +94 -0
- package/dist/ui-studio/matrix/ClassMapper.d.ts +128 -0
- package/dist/ui-studio/matrix/MatrixResolver.d.ts +203 -0
- package/dist/ui-studio/matrix/types.d.ts +96 -0
- package/dist/ui-studio/presets/IndustryDetector.d.ts +183 -0
- package/dist/ui-studio/presets/component-registry.d.ts +213 -0
- package/dist/ui-studio/presets/factor-registry.d.ts +364 -0
- package/dist/ui-studio/presets/granularity-registry.d.ts +252 -0
- package/dist/ui-studio/presets/index.d.ts +32 -0
- package/dist/ui-studio/presets/industries.d.ts +143 -0
- package/dist/ui-studio/presets/layout-registry.d.ts +21 -0
- package/dist/ui-studio/presets/matrix-groups.d.ts +195 -0
- package/dist/ui-studio/presets/page-registry.d.ts +24 -0
- package/dist/ui-studio/presets/registry.constants.d.ts +69 -0
- package/dist/ui-studio/presets/registry.types.d.ts +166 -0
- package/dist/ui-studio/presets/section-defaults.d.ts +175 -0
- package/dist/ui-studio/presets/section-registry.d.ts +83 -0
- package/dist/ui-studio/presets/section-registry.defaults.d.ts +106 -0
- package/dist/ui-studio/presets/section-registry.helpers.d.ts +112 -0
- package/dist/ui-studio/presets/section-registry.types.d.ts +181 -0
- package/dist/ui-studio/presets/template-registry.d.ts +23 -0
- package/dist/ui-studio/presets/variants.d.ts +1038 -0
- package/dist/ui-studio/registries/components-registry.d.ts +193 -0
- package/dist/ui-studio/registries/design-systems-registry.d.ts +153 -0
- package/dist/ui-studio/registries/factors-registry.d.ts +145 -0
- package/dist/ui-studio/registries/tiers-registry.d.ts +150 -0
- package/dist/ui-studio/resolution/FactorResolver.d.ts +201 -0
- package/dist/ui-studio/templates/TestGenerator.d.ts +55 -0
- package/dist/ui-studio/templates/TierGenerator.d.ts +153 -0
- package/dist/ui-studio/templates/TypesGenerator.d.ts +51 -0
- package/dist/ui-studio/types/granularity/base.types.d.ts +268 -0
- package/dist/ui-studio/types/granularity/config.types.d.ts +177 -0
- package/dist/ui-studio/types/granularity/factors.types.d.ts +194 -0
- package/dist/ui-studio/types/granularity/index.d.ts +57 -0
- package/dist/ui-studio/types/granularity/slot.types.d.ts +128 -0
- package/dist/ui-studio/types/granularity/template.types.d.ts +179 -0
- package/dist/ui-studio/types/granularity-levels/atom.config.d.ts +151 -0
- package/dist/ui-studio/types/granularity-levels/component.config.d.ts +175 -0
- package/dist/ui-studio/types/granularity-levels/index.d.ts +47 -0
- package/dist/ui-studio/types/granularity-levels/layout.config.d.ts +278 -0
- package/dist/ui-studio/types/granularity-levels/page.config.d.ts +210 -0
- package/dist/ui-studio/types/granularity-levels/section.config.d.ts +188 -0
- package/dist/ui-studio/types/granularity-levels/template.config.d.ts +340 -0
- package/dist/ui-studio/types.d.ts +323 -0
- package/dist/utils/CodeUtils.d.ts +103 -0
- package/dist/utils/GenerateComponentValidator.d.ts +35 -0
- package/dist/utils/Logger.d.ts +101 -0
- package/dist/utils/StringUtils.d.ts +120 -0
- package/dist/utils/ValidationUtils.d.ts +71 -0
- package/dist/utils/errors/BaseError.d.ts +23 -0
- package/dist/utils/errors/GenerationError.d.ts +14 -0
- package/dist/utils/errors/TemplateNotFoundError.d.ts +13 -0
- package/dist/utils/errors/ValidationError.d.ts +13 -0
- package/dist/utils/errors/index.d.ts +12 -0
- package/dist/utils/factor-resolver.d.ts +294 -0
- package/dist/utils/granularity-helpers.d.ts +359 -0
- package/dist/utils/index.d.ts +20 -0
- package/dist/utils/performance.d.ts +26 -0
- package/dist/utils/stringify.d.ts +28 -0
- package/dist/validators/component-validator.d.ts +86 -0
- package/dist/validators/design-system-validator.d.ts +95 -0
- package/dist/validators/factor-validator.d.ts +101 -0
- package/dist/validators/index.d.ts +263 -0
- package/dist/validators/section-validator.d.ts +120 -0
- package/dist/validators/slot-validator.d.ts +161 -0
- package/dist/validators/tier-validator.d.ts +102 -0
- package/package.json +67 -0
- package/tests/16-factor-integration.test.d.ts +14 -0
- package/tests/16-factor-visual.test.d.ts +14 -0
- package/tests/5-level-integration.test.d.ts +14 -0
- package/tests/CodeUtils.test.d.ts +7 -0
- package/tests/DesignSystems.test.d.ts +7 -0
- package/tests/GenerateComponentValidator.test.d.ts +7 -0
- package/tests/Logger.test.d.ts +7 -0
- package/tests/StringUtils.test.d.ts +7 -0
- package/tests/StyleGenerator.test.d.ts +13 -0
- package/tests/Tiers.test.d.ts +7 -0
- package/tests/TokenRegistry.test.d.ts +14 -0
- package/tests/TokenStyleResolver.test.d.ts +13 -0
- package/tests/ValidationUtils.test.d.ts +7 -0
- package/tests/_pending_fix/Accordion.test.d.ts +13 -0
- package/tests/_pending_fix/Alert.test.d.ts +13 -0
- package/tests/_pending_fix/AlertDialog.test.d.ts +13 -0
- package/tests/_pending_fix/AspectRatio.test.d.ts +13 -0
- package/tests/_pending_fix/Autocomplete.test.d.ts +13 -0
- package/tests/_pending_fix/Avatar.test.d.ts +13 -0
- package/tests/_pending_fix/Badge.test.d.ts +13 -0
- package/tests/_pending_fix/Banner.test.d.ts +13 -0
- package/tests/_pending_fix/Box.test.d.ts +13 -0
- package/tests/_pending_fix/Breadcrumb.test.d.ts +13 -0
- package/tests/_pending_fix/Callout.test.d.ts +13 -0
- package/tests/_pending_fix/Card.test.d.ts +13 -0
- package/tests/_pending_fix/Center.test.d.ts +13 -0
- package/tests/_pending_fix/Checkbox.test.d.ts +13 -0
- package/tests/_pending_fix/Chip.test.d.ts +13 -0
- package/tests/_pending_fix/ColorPicker.test.d.ts +13 -0
- package/tests/_pending_fix/Combobox.test.d.ts +13 -0
- package/tests/_pending_fix/CommandPalette.test.d.ts +13 -0
- package/tests/_pending_fix/ConfirmationModal.test.d.ts +13 -0
- package/tests/_pending_fix/Container.test.d.ts +13 -0
- package/tests/_pending_fix/DataTable.test.d.ts +13 -0
- package/tests/_pending_fix/DatePicker.test.d.ts +13 -0
- package/tests/_pending_fix/DateRangePicker.test.d.ts +13 -0
- package/tests/_pending_fix/DateTimePicker.test.d.ts +13 -0
- package/tests/_pending_fix/Divider.test.d.ts +13 -0
- package/tests/_pending_fix/Drawer.test.d.ts +13 -0
- package/tests/_pending_fix/Dropdown.test.d.ts +13 -0
- package/tests/_pending_fix/EmptyState.test.d.ts +13 -0
- package/tests/_pending_fix/ErrorState.test.d.ts +13 -0
- package/tests/_pending_fix/FileDropzone.test.d.ts +13 -0
- package/tests/_pending_fix/FileUpload.test.d.ts +13 -0
- package/tests/_pending_fix/Flex.test.d.ts +13 -0
- package/tests/_pending_fix/Grid.test.d.ts +13 -0
- package/tests/_pending_fix/GridItem.test.d.ts +13 -0
- package/tests/_pending_fix/HStack.test.d.ts +13 -0
- package/tests/_pending_fix/Input.test.d.ts +13 -0
- package/tests/_pending_fix/InputCurrency.test.d.ts +13 -0
- package/tests/_pending_fix/InputGroup.test.d.ts +13 -0
- package/tests/_pending_fix/InputOTP.test.d.ts +13 -0
- package/tests/_pending_fix/InputPassword.test.d.ts +13 -0
- package/tests/_pending_fix/InputPhone.test.d.ts +13 -0
- package/tests/_pending_fix/InputSearch.test.d.ts +13 -0
- package/tests/_pending_fix/Link.test.d.ts +13 -0
- package/tests/_pending_fix/List.test.d.ts +13 -0
- package/tests/_pending_fix/LoadingOverlay.test.d.ts +13 -0
- package/tests/_pending_fix/Menu.test.d.ts +13 -0
- package/tests/_pending_fix/Modal.test.d.ts +13 -0
- package/tests/_pending_fix/MultiSelect.test.d.ts +13 -0
- package/tests/_pending_fix/NavGroup.test.d.ts +13 -0
- package/tests/_pending_fix/NavItem.test.d.ts +13 -0
- package/tests/_pending_fix/NavLink.test.d.ts +13 -0
- package/tests/_pending_fix/Navbar.test.d.ts +13 -0
- package/tests/_pending_fix/Notification.test.d.ts +13 -0
- package/tests/_pending_fix/NotificationBadge.test.d.ts +13 -0
- package/tests/_pending_fix/NumberInput.test.d.ts +13 -0
- package/tests/_pending_fix/Pagination.test.d.ts +13 -0
- package/tests/_pending_fix/Popover.test.d.ts +13 -0
- package/tests/_pending_fix/Progress.test.d.ts +13 -0
- package/tests/_pending_fix/ProgressCircle.test.d.ts +13 -0
- package/tests/_pending_fix/ProgressSteps.test.d.ts +13 -0
- package/tests/_pending_fix/Radio.test.d.ts +13 -0
- package/tests/_pending_fix/RangeSlider.test.d.ts +13 -0
- package/tests/_pending_fix/ResizablePanel.test.d.ts +13 -0
- package/tests/_pending_fix/ResultState.test.d.ts +13 -0
- package/tests/_pending_fix/ScrollArea.test.d.ts +13 -0
- package/tests/_pending_fix/Select.test.d.ts +14 -0
- package/tests/_pending_fix/Sheet.test.d.ts +13 -0
- package/tests/_pending_fix/Sidebar.test.d.ts +13 -0
- package/tests/_pending_fix/SimpleGrid.test.d.ts +13 -0
- package/tests/_pending_fix/Skeleton.test.d.ts +13 -0
- package/tests/_pending_fix/Slider.test.d.ts +13 -0
- package/tests/_pending_fix/Spacer.test.d.ts +13 -0
- package/tests/_pending_fix/Spinner.test.d.ts +13 -0
- package/tests/_pending_fix/Stack.test.d.ts +13 -0
- package/tests/_pending_fix/Stat.test.d.ts +13 -0
- package/tests/_pending_fix/Stepper.test.d.ts +14 -0
- package/tests/_pending_fix/Switch.test.d.ts +13 -0
- package/tests/_pending_fix/Table.test.d.ts +13 -0
- package/tests/_pending_fix/Tabs.test.d.ts +13 -0
- package/tests/_pending_fix/Textarea.test.d.ts +13 -0
- package/tests/_pending_fix/Timeline.test.d.ts +13 -0
- package/tests/_pending_fix/Toast.test.d.ts +14 -0
- package/tests/_pending_fix/Tooltip.test.d.ts +14 -0
- package/tests/_pending_fix/VStack.test.d.ts +13 -0
- package/tests/alert.test.d.ts +13 -0
- package/tests/badge.test.d.ts +13 -0
- package/tests/benchmarks/factor-resolution.bench.d.ts +41 -0
- package/tests/button.test.d.ts +16 -0
- package/tests/card.test.d.ts +19 -0
- package/tests/checkbox.test.d.ts +13 -0
- package/tests/component-16-factor-types.test.d.ts +13 -0
- package/tests/component-5level-integration.test.d.ts +14 -0
- package/tests/component-registry-ui.test.d.ts +13 -0
- package/tests/e2e/16-factor-visual.test.d.ts +14 -0
- package/tests/edge-cases.test.d.ts +14 -0
- package/tests/factor-17-24-integration.test.d.ts +14 -0
- package/tests/factor-17-24-performance.test.d.ts +14 -0
- package/tests/factor-validators.test.d.ts +13 -0
- package/tests/factors-1-6.test.d.ts +13 -0
- package/tests/factors-12-16.test.d.ts +13 -0
- package/tests/factors-17-24.test.d.ts +21 -0
- package/tests/factors-all.test.d.ts +13 -0
- package/tests/factors-registry.test.d.ts +11 -0
- package/tests/factors.test.d.ts +13 -0
- package/tests/granularity-types.test.d.ts +18 -0
- package/tests/groups.test.d.ts +14 -0
- package/tests/input.test.d.ts +16 -0
- package/tests/intents.test.d.ts +14 -0
- package/tests/memory-leak.test.d.ts +14 -0
- package/tests/modal.test.d.ts +19 -0
- package/tests/presets.test.d.ts +14 -0
- package/tests/radio.test.d.ts +13 -0
- package/tests/resolution-intents.test.d.ts +13 -0
- package/tests/resolution-presets.test.d.ts +13 -0
- package/tests/resolveProps.test.d.ts +14 -0
- package/tests/section-integration.test.d.ts +16 -0
- package/tests/section-types.test.d.ts +11 -0
- package/tests/setup.d.ts +13 -0
- package/tests/shorthands.test.d.ts +14 -0
- package/tests/switch.test.d.ts +13 -0
- package/tests/tabs.test.d.ts +13 -0
- package/tests/tiers-registry.test.d.ts +11 -0
- package/tests/useComponentStyles.test.d.ts +11 -0
- package/tests/useFactors.test.d.ts +13 -0
- package/tests/validators-invalid-input.test.d.ts +13 -0
- package/tsup.config.d.ts +11 -0
- package/vitest.config.d.ts +3 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factor Resolver - Dynamic Factor Resolution for Granularity Levels
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to dynamically resolve which factors
|
|
5
|
+
* apply at each granularity level based on factor definitions with
|
|
6
|
+
* `level` and `cascadeDown` fields.
|
|
7
|
+
*
|
|
8
|
+
* Key Functions:
|
|
9
|
+
* - `getFactorsForLevel()` - Get all applicable factors for a level
|
|
10
|
+
* - `getFactorDefinition()` - Get a single factor by ID
|
|
11
|
+
* - `resolveFactorValue()` - Resolve a factor's value with cascade logic
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
* @module utils/factor-resolver
|
|
15
|
+
* @since 4.0.0
|
|
16
|
+
*
|
|
17
|
+
* Powered by Nikkory
|
|
18
|
+
*/
|
|
19
|
+
import type { DesignSystem } from '../types';
|
|
20
|
+
import type { GranularityFactorCategory, GranularityFactorDefinition, GranularityFactorValues, GranularityLevel } from '../types/granularity';
|
|
21
|
+
/**
|
|
22
|
+
* Get all factors applicable at a given granularity level
|
|
23
|
+
*
|
|
24
|
+
* This function dynamically resolves which factors apply at a level by:
|
|
25
|
+
* 1. Including factors defined at the exact level
|
|
26
|
+
* 2. Including factors from higher levels that have `cascadeDown: true`
|
|
27
|
+
*
|
|
28
|
+
* This REPLACES hardcoded 8/13/24 factor arrays with dynamic resolution.
|
|
29
|
+
*
|
|
30
|
+
* @category utils
|
|
31
|
+
* @since 4.0.0
|
|
32
|
+
*
|
|
33
|
+
* @param level - The granularity level to query
|
|
34
|
+
* @returns Array of factor definitions applicable at this level
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Template level gets 8 factors (defined at template level)
|
|
39
|
+
* const templateFactors = getFactorsForLevel('template');
|
|
40
|
+
* console.log(templateFactors.length); // 8
|
|
41
|
+
*
|
|
42
|
+
* // Page level gets template factors + page-specific = 13
|
|
43
|
+
* const pageFactors = getFactorsForLevel('page');
|
|
44
|
+
* console.log(pageFactors.length); // 13
|
|
45
|
+
*
|
|
46
|
+
* // Section level gets cascading + section-specific = 18
|
|
47
|
+
* const sectionFactors = getFactorsForLevel('section');
|
|
48
|
+
* console.log(sectionFactors.length); // 18
|
|
49
|
+
*
|
|
50
|
+
* // Component level gets all 24 factors
|
|
51
|
+
* const componentFactors = getFactorsForLevel('component');
|
|
52
|
+
* console.log(componentFactors.length); // 24
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Powered by Nikkory
|
|
56
|
+
*/
|
|
57
|
+
export declare function getFactorsForLevel(level: GranularityLevel): readonly GranularityFactorDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Get factor IDs applicable at a given granularity level
|
|
60
|
+
*
|
|
61
|
+
* @category utils
|
|
62
|
+
* @since 4.0.0
|
|
63
|
+
*
|
|
64
|
+
* @param level - The granularity level to query
|
|
65
|
+
* @returns Array of factor IDs applicable at this level
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const pageFactorIds = getFactorIdsForLevel('page');
|
|
70
|
+
* console.log(pageFactorIds); // ['colorPrimary', 'spacing', ...]
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Powered by Nikkory
|
|
74
|
+
*/
|
|
75
|
+
export declare function getFactorIdsForLevel(level: GranularityLevel): readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Get a factor definition by ID
|
|
78
|
+
*
|
|
79
|
+
* @category utils
|
|
80
|
+
* @since 4.0.0
|
|
81
|
+
*
|
|
82
|
+
* @param factorId - The factor ID to look up
|
|
83
|
+
* @returns The factor definition
|
|
84
|
+
* @throws Error if factor not found
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const factor = getFactorDefinition('spacing');
|
|
89
|
+
* console.log(factor.level); // 'template'
|
|
90
|
+
* console.log(factor.cascadeDown); // true
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* Powered by Nikkory
|
|
94
|
+
*/
|
|
95
|
+
export declare function getFactorDefinition(factorId: string): GranularityFactorDefinition;
|
|
96
|
+
/**
|
|
97
|
+
* Safely get a factor definition by ID (returns undefined if not found)
|
|
98
|
+
*
|
|
99
|
+
* @category utils
|
|
100
|
+
* @since 4.0.0
|
|
101
|
+
*
|
|
102
|
+
* @param factorId - The factor ID to look up
|
|
103
|
+
* @returns The factor definition or undefined
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const factor = tryGetFactorDefinition('spacing');
|
|
108
|
+
* if (factor) {
|
|
109
|
+
* console.log(factor.name);
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* Powered by Nikkory
|
|
114
|
+
*/
|
|
115
|
+
export declare function tryGetFactorDefinition(factorId: string): GranularityFactorDefinition | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Get all factor IDs in the registry
|
|
118
|
+
*
|
|
119
|
+
* @category utils
|
|
120
|
+
* @since 4.0.0
|
|
121
|
+
*
|
|
122
|
+
* @returns Array of all registered factor IDs
|
|
123
|
+
*
|
|
124
|
+
* Powered by Nikkory
|
|
125
|
+
*/
|
|
126
|
+
export declare function getAllFactorIds(): readonly string[];
|
|
127
|
+
/**
|
|
128
|
+
* Options for resolving factor values
|
|
129
|
+
*
|
|
130
|
+
* @category types
|
|
131
|
+
* @since 4.0.0
|
|
132
|
+
*
|
|
133
|
+
* Powered by Nikkory
|
|
134
|
+
*/
|
|
135
|
+
export interface ResolveFactorOptions {
|
|
136
|
+
/** Design system for default values */
|
|
137
|
+
readonly designSystem: DesignSystem;
|
|
138
|
+
/** Parent factor values (for cascade) */
|
|
139
|
+
readonly parentFactors?: GranularityFactorValues;
|
|
140
|
+
/** Explicit overrides (highest priority) */
|
|
141
|
+
readonly overrides?: GranularityFactorValues;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Resolve a single factor's value with cascade priority
|
|
145
|
+
*
|
|
146
|
+
* Priority order (highest to lowest):
|
|
147
|
+
* 1. Explicit overrides
|
|
148
|
+
* 2. Parent cascaded values
|
|
149
|
+
* 3. Design system defaults
|
|
150
|
+
*
|
|
151
|
+
* @category utils
|
|
152
|
+
* @since 4.0.0
|
|
153
|
+
*
|
|
154
|
+
* @param factorId - The factor ID to resolve
|
|
155
|
+
* @param options - Resolution options
|
|
156
|
+
* @returns The resolved value
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const value = resolveFactorValue('spacing', {
|
|
161
|
+
* designSystem: 'material-design',
|
|
162
|
+
* parentFactors: { spacing: 'lg' },
|
|
163
|
+
* overrides: { spacing: 'xl' }
|
|
164
|
+
* });
|
|
165
|
+
* console.log(value); // 'xl' (override wins)
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* Powered by Nikkory
|
|
169
|
+
*/
|
|
170
|
+
export declare function resolveFactorValue(factorId: string, options: ResolveFactorOptions): unknown;
|
|
171
|
+
/**
|
|
172
|
+
* Resolve all factors for a level with cascade
|
|
173
|
+
*
|
|
174
|
+
* @category utils
|
|
175
|
+
* @since 4.0.0
|
|
176
|
+
*
|
|
177
|
+
* @param level - The granularity level
|
|
178
|
+
* @param options - Resolution options
|
|
179
|
+
* @returns Object with all resolved factor values
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const values = resolveAllFactors('section', {
|
|
184
|
+
* designSystem: 'material-design',
|
|
185
|
+
* parentFactors: { spacing: 'lg', theme: 'dark' }
|
|
186
|
+
* });
|
|
187
|
+
* console.log(values.spacing); // 'lg' (cascaded from parent)
|
|
188
|
+
* console.log(values.gridColumns); // 12 (default)
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* Powered by Nikkory
|
|
192
|
+
*/
|
|
193
|
+
export declare function resolveAllFactors(level: GranularityLevel, options: ResolveFactorOptions): GranularityFactorValues;
|
|
194
|
+
/**
|
|
195
|
+
* Filter factors by category for a given level
|
|
196
|
+
*
|
|
197
|
+
* @category utils
|
|
198
|
+
* @since 4.0.0
|
|
199
|
+
*
|
|
200
|
+
* @param level - The granularity level
|
|
201
|
+
* @param categories - Categories to include
|
|
202
|
+
* @returns Filtered factors
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const visualFactors = filterFactorsByCategory('section', ['visual']);
|
|
207
|
+
* console.log(visualFactors.length); // Visual factors applicable at section level
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* Powered by Nikkory
|
|
211
|
+
*/
|
|
212
|
+
export declare function filterFactorsByCategory(level: GranularityLevel, categories: readonly GranularityFactorCategory[]): readonly GranularityFactorDefinition[];
|
|
213
|
+
/**
|
|
214
|
+
* Filter factors that cascade down
|
|
215
|
+
*
|
|
216
|
+
* @category utils
|
|
217
|
+
* @since 4.0.0
|
|
218
|
+
*
|
|
219
|
+
* @param level - The granularity level
|
|
220
|
+
* @returns Only factors that cascade to child levels
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const cascading = getCascadingFactors('page');
|
|
225
|
+
* // Returns page-level factors that will cascade to sections
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* Powered by Nikkory
|
|
229
|
+
*/
|
|
230
|
+
export declare function getCascadingFactors(level: GranularityLevel): readonly GranularityFactorDefinition[];
|
|
231
|
+
/**
|
|
232
|
+
* Filter factors that do NOT cascade down
|
|
233
|
+
*
|
|
234
|
+
* @category utils
|
|
235
|
+
* @since 4.0.0
|
|
236
|
+
*
|
|
237
|
+
* @param level - The granularity level
|
|
238
|
+
* @returns Only factors that are local to this level
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* const local = getLocalFactors('section');
|
|
243
|
+
* // Returns section-specific factors that don't cascade
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* Powered by Nikkory
|
|
247
|
+
*/
|
|
248
|
+
export declare function getLocalFactors(level: GranularityLevel): readonly GranularityFactorDefinition[];
|
|
249
|
+
/**
|
|
250
|
+
* Get factor count for a level (for debugging/display)
|
|
251
|
+
*
|
|
252
|
+
* @category utils
|
|
253
|
+
* @since 4.0.0
|
|
254
|
+
*
|
|
255
|
+
* @param level - The granularity level
|
|
256
|
+
* @returns Number of applicable factors
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* getFactorCountForLevel('template'); // 8
|
|
261
|
+
* getFactorCountForLevel('page'); // 13
|
|
262
|
+
* getFactorCountForLevel('section'); // 18
|
|
263
|
+
* getFactorCountForLevel('component'); // 24
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* Powered by Nikkory
|
|
267
|
+
*/
|
|
268
|
+
export declare function getFactorCountForLevel(level: GranularityLevel): number;
|
|
269
|
+
/**
|
|
270
|
+
* Get factor count breakdown by level
|
|
271
|
+
*
|
|
272
|
+
* @category utils
|
|
273
|
+
* @since 4.0.0
|
|
274
|
+
*
|
|
275
|
+
* @returns Object with factor counts per level
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* const counts = getFactorCountsByLevel();
|
|
280
|
+
* console.log(counts);
|
|
281
|
+
* // {
|
|
282
|
+
* // template: 8,
|
|
283
|
+
* // layout: 8,
|
|
284
|
+
* // page: 13,
|
|
285
|
+
* // section: 18,
|
|
286
|
+
* // component: 24,
|
|
287
|
+
* // atom: 24
|
|
288
|
+
* // }
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* Powered by Nikkory
|
|
292
|
+
*/
|
|
293
|
+
export declare function getFactorCountsByLevel(): Record<GranularityLevel, number>;
|
|
294
|
+
//# sourceMappingURL=factor-resolver.d.ts.map
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Granularity Helpers - Utility Functions for Granularity Level Operations
|
|
3
|
+
*
|
|
4
|
+
* This module provides helper functions for working with the 6-level
|
|
5
|
+
* granularity hierarchy:
|
|
6
|
+
* - Comparing levels (isHigherGranularity, isLowerGranularity)
|
|
7
|
+
* - Finding child/parent levels (getChildGranularities, getParentGranularity)
|
|
8
|
+
* - Level validation and lookup
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
* @module utils/granularity-helpers
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*
|
|
14
|
+
* Powered by Nikkory
|
|
15
|
+
*/
|
|
16
|
+
import type { GranularityLevel } from '../types/granularity';
|
|
17
|
+
/**
|
|
18
|
+
* Check if level A is higher than level B in the hierarchy
|
|
19
|
+
*
|
|
20
|
+
* Template (6) > Layout (5) > Page (4) > Section (3) > Component (2) > Atom (1)
|
|
21
|
+
*
|
|
22
|
+
* @category utils
|
|
23
|
+
* @since 4.0.0
|
|
24
|
+
*
|
|
25
|
+
* @param levelA - First granularity level
|
|
26
|
+
* @param levelB - Second granularity level
|
|
27
|
+
* @returns True if levelA is higher than levelB
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* isHigherGranularity('template', 'page'); // true
|
|
32
|
+
* isHigherGranularity('section', 'page'); // false
|
|
33
|
+
* isHigherGranularity('page', 'page'); // false
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Powered by Nikkory
|
|
37
|
+
*/
|
|
38
|
+
export declare function isHigherGranularity(levelA: GranularityLevel, levelB: GranularityLevel): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if level A is lower than level B in the hierarchy
|
|
41
|
+
*
|
|
42
|
+
* Atom (1) < Component (2) < Section (3) < Page (4) < Layout (5) < Template (6)
|
|
43
|
+
*
|
|
44
|
+
* @category utils
|
|
45
|
+
* @since 4.0.0
|
|
46
|
+
*
|
|
47
|
+
* @param levelA - First granularity level
|
|
48
|
+
* @param levelB - Second granularity level
|
|
49
|
+
* @returns True if levelA is lower than levelB
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* isLowerGranularity('atom', 'component'); // true
|
|
54
|
+
* isLowerGranularity('page', 'section'); // false
|
|
55
|
+
* isLowerGranularity('page', 'page'); // false
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* Powered by Nikkory
|
|
59
|
+
*/
|
|
60
|
+
export declare function isLowerGranularity(levelA: GranularityLevel, levelB: GranularityLevel): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Check if two levels are at the same rank
|
|
63
|
+
*
|
|
64
|
+
* @category utils
|
|
65
|
+
* @since 4.0.0
|
|
66
|
+
*
|
|
67
|
+
* @param levelA - First granularity level
|
|
68
|
+
* @param levelB - Second granularity level
|
|
69
|
+
* @returns True if levels are the same
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* isSameGranularity('page', 'page'); // true
|
|
74
|
+
* isSameGranularity('page', 'section'); // false
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Powered by Nikkory
|
|
78
|
+
*/
|
|
79
|
+
export declare function isSameGranularity(levelA: GranularityLevel, levelB: GranularityLevel): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check if level A is higher than or equal to level B
|
|
82
|
+
*
|
|
83
|
+
* @category utils
|
|
84
|
+
* @since 4.0.0
|
|
85
|
+
*
|
|
86
|
+
* @param levelA - First granularity level
|
|
87
|
+
* @param levelB - Second granularity level
|
|
88
|
+
* @returns True if levelA is >= levelB
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* isHigherOrEqualGranularity('page', 'section'); // true
|
|
93
|
+
* isHigherOrEqualGranularity('page', 'page'); // true
|
|
94
|
+
* isHigherOrEqualGranularity('section', 'page'); // false
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* Powered by Nikkory
|
|
98
|
+
*/
|
|
99
|
+
export declare function isHigherOrEqualGranularity(levelA: GranularityLevel, levelB: GranularityLevel): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Check if level A is lower than or equal to level B
|
|
102
|
+
*
|
|
103
|
+
* @category utils
|
|
104
|
+
* @since 4.0.0
|
|
105
|
+
*
|
|
106
|
+
* @param levelA - First granularity level
|
|
107
|
+
* @param levelB - Second granularity level
|
|
108
|
+
* @returns True if levelA is <= levelB
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* isLowerOrEqualGranularity('section', 'page'); // true
|
|
113
|
+
* isLowerOrEqualGranularity('page', 'page'); // true
|
|
114
|
+
* isLowerOrEqualGranularity('page', 'section'); // false
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* Powered by Nikkory
|
|
118
|
+
*/
|
|
119
|
+
export declare function isLowerOrEqualGranularity(levelA: GranularityLevel, levelB: GranularityLevel): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Get all granularity levels that can be children of a given level
|
|
122
|
+
*
|
|
123
|
+
* Children are all levels LOWER than the parent level.
|
|
124
|
+
*
|
|
125
|
+
* @category utils
|
|
126
|
+
* @since 4.0.0
|
|
127
|
+
*
|
|
128
|
+
* @param parentLevel - The parent granularity level
|
|
129
|
+
* @returns Array of child granularity levels (lower levels)
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* getChildGranularities('page');
|
|
134
|
+
* // ['section', 'component', 'atom']
|
|
135
|
+
*
|
|
136
|
+
* getChildGranularities('section');
|
|
137
|
+
* // ['component', 'atom']
|
|
138
|
+
*
|
|
139
|
+
* getChildGranularities('atom');
|
|
140
|
+
* // [] (atom has no children)
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* Powered by Nikkory
|
|
144
|
+
*/
|
|
145
|
+
export declare function getChildGranularities(parentLevel: GranularityLevel): readonly GranularityLevel[];
|
|
146
|
+
/**
|
|
147
|
+
* Get the immediate child level (one level down)
|
|
148
|
+
*
|
|
149
|
+
* @category utils
|
|
150
|
+
* @since 4.0.0
|
|
151
|
+
*
|
|
152
|
+
* @param level - The current granularity level
|
|
153
|
+
* @returns The immediate child level, or undefined if at lowest level
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* getImmediateChildLevel('page'); // 'section'
|
|
158
|
+
* getImmediateChildLevel('section'); // 'component'
|
|
159
|
+
* getImmediateChildLevel('atom'); // undefined
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* Powered by Nikkory
|
|
163
|
+
*/
|
|
164
|
+
export declare function getImmediateChildLevel(level: GranularityLevel): GranularityLevel | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Get the parent level (one level up)
|
|
167
|
+
*
|
|
168
|
+
* @category utils
|
|
169
|
+
* @since 4.0.0
|
|
170
|
+
*
|
|
171
|
+
* @param level - The current granularity level
|
|
172
|
+
* @returns The parent level, or undefined if at highest level
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* getParentGranularity('section'); // 'page'
|
|
177
|
+
* getParentGranularity('page'); // 'layout'
|
|
178
|
+
* getParentGranularity('template'); // undefined
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* Powered by Nikkory
|
|
182
|
+
*/
|
|
183
|
+
export declare function getParentGranularity(level: GranularityLevel): GranularityLevel | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Get all ancestor levels (all levels higher than the given level)
|
|
186
|
+
*
|
|
187
|
+
* @category utils
|
|
188
|
+
* @since 4.0.0
|
|
189
|
+
*
|
|
190
|
+
* @param level - The current granularity level
|
|
191
|
+
* @returns Array of ancestor levels (higher levels)
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* getAncestorGranularities('section');
|
|
196
|
+
* // ['template', 'layout', 'page']
|
|
197
|
+
*
|
|
198
|
+
* getAncestorGranularities('template');
|
|
199
|
+
* // [] (template has no ancestors)
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* Powered by Nikkory
|
|
203
|
+
*/
|
|
204
|
+
export declare function getAncestorGranularities(level: GranularityLevel): readonly GranularityLevel[];
|
|
205
|
+
/**
|
|
206
|
+
* Check if a string is a valid granularity level
|
|
207
|
+
*
|
|
208
|
+
* @category utils
|
|
209
|
+
* @since 4.0.0
|
|
210
|
+
*
|
|
211
|
+
* @param value - The value to check
|
|
212
|
+
* @returns True if the value is a valid GranularityLevel
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* isValidGranularityLevel('page'); // true
|
|
217
|
+
* isValidGranularityLevel('invalid'); // false
|
|
218
|
+
* isValidGranularityLevel(123); // false
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* Powered by Nikkory
|
|
222
|
+
*/
|
|
223
|
+
export declare function isValidGranularityLevel(value: unknown): value is GranularityLevel;
|
|
224
|
+
/**
|
|
225
|
+
* Assert that a value is a valid granularity level
|
|
226
|
+
*
|
|
227
|
+
* @category utils
|
|
228
|
+
* @since 4.0.0
|
|
229
|
+
*
|
|
230
|
+
* @param value - The value to check
|
|
231
|
+
* @throws Error if not a valid granularity level
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* assertGranularityLevel('page'); // OK
|
|
236
|
+
* assertGranularityLevel('invalid'); // throws Error
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* Powered by Nikkory
|
|
240
|
+
*/
|
|
241
|
+
export declare function assertGranularityLevel(value: unknown): asserts value is GranularityLevel;
|
|
242
|
+
/**
|
|
243
|
+
* Get all granularity levels
|
|
244
|
+
*
|
|
245
|
+
* @category utils
|
|
246
|
+
* @since 4.0.0
|
|
247
|
+
*
|
|
248
|
+
* @returns All 6 granularity levels in hierarchy order (highest to lowest)
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* getAllGranularityLevels();
|
|
253
|
+
* // ['template', 'layout', 'page', 'section', 'component', 'atom']
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* Powered by Nikkory
|
|
257
|
+
*/
|
|
258
|
+
export declare function getAllGranularityLevels(): readonly GranularityLevel[];
|
|
259
|
+
/**
|
|
260
|
+
* Get the distance between two levels in the hierarchy
|
|
261
|
+
*
|
|
262
|
+
* @category utils
|
|
263
|
+
* @since 4.0.0
|
|
264
|
+
*
|
|
265
|
+
* @param levelA - First granularity level
|
|
266
|
+
* @param levelB - Second granularity level
|
|
267
|
+
* @returns Number of levels between (positive if A > B, negative if A < B)
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* getLevelDistance('page', 'section'); // 1
|
|
272
|
+
* getLevelDistance('template', 'atom'); // 5
|
|
273
|
+
* getLevelDistance('section', 'page'); // -1
|
|
274
|
+
* getLevelDistance('page', 'page'); // 0
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* Powered by Nikkory
|
|
278
|
+
*/
|
|
279
|
+
export declare function getLevelDistance(levelA: GranularityLevel, levelB: GranularityLevel): number;
|
|
280
|
+
/**
|
|
281
|
+
* Check if a child level can be placed in a parent level
|
|
282
|
+
*
|
|
283
|
+
* A child can be placed in a parent if the child is at a LOWER level.
|
|
284
|
+
*
|
|
285
|
+
* @category utils
|
|
286
|
+
* @since 4.0.0
|
|
287
|
+
*
|
|
288
|
+
* @param parentLevel - The parent granularity level
|
|
289
|
+
* @param childLevel - The child granularity level
|
|
290
|
+
* @returns True if child can be placed in parent
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* canContain('page', 'section'); // true
|
|
295
|
+
* canContain('section', 'page'); // false
|
|
296
|
+
* canContain('section', 'section'); // false
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* Powered by Nikkory
|
|
300
|
+
*/
|
|
301
|
+
export declare function canContain(parentLevel: GranularityLevel, childLevel: GranularityLevel): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Get the highest level in the hierarchy
|
|
304
|
+
*
|
|
305
|
+
* @category utils
|
|
306
|
+
* @since 4.0.0
|
|
307
|
+
*
|
|
308
|
+
* @returns The highest granularity level ('template')
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* getHighestLevel(); // 'template'
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* Powered by Nikkory
|
|
316
|
+
*/
|
|
317
|
+
export declare function getHighestLevel(): GranularityLevel;
|
|
318
|
+
/**
|
|
319
|
+
* Get the lowest level in the hierarchy
|
|
320
|
+
*
|
|
321
|
+
* @category utils
|
|
322
|
+
* @since 4.0.0
|
|
323
|
+
*
|
|
324
|
+
* @returns The lowest granularity level ('atom')
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* getLowestLevel(); // 'atom'
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* Powered by Nikkory
|
|
332
|
+
*/
|
|
333
|
+
export declare function getLowestLevel(): GranularityLevel;
|
|
334
|
+
/**
|
|
335
|
+
* Get levels between two levels (exclusive)
|
|
336
|
+
*
|
|
337
|
+
* @category utils
|
|
338
|
+
* @since 4.0.0
|
|
339
|
+
*
|
|
340
|
+
* @param higherLevel - The higher level
|
|
341
|
+
* @param lowerLevel - The lower level
|
|
342
|
+
* @returns Levels between (not including the endpoints)
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* getLevelsBetween('template', 'section');
|
|
347
|
+
* // ['layout', 'page']
|
|
348
|
+
*
|
|
349
|
+
* getLevelsBetween('page', 'component');
|
|
350
|
+
* // ['section']
|
|
351
|
+
*
|
|
352
|
+
* getLevelsBetween('page', 'section');
|
|
353
|
+
* // [] (adjacent levels)
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* Powered by Nikkory
|
|
357
|
+
*/
|
|
358
|
+
export declare function getLevelsBetween(higherLevel: GranularityLevel, lowerLevel: GranularityLevel): readonly GranularityLevel[];
|
|
359
|
+
//# sourceMappingURL=granularity-helpers.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Utilities
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module utils
|
|
6
|
+
* @since 4.0.0
|
|
7
|
+
*
|
|
8
|
+
* Powered by Nikkory
|
|
9
|
+
*/
|
|
10
|
+
export * from './StringUtils';
|
|
11
|
+
export * from './CodeUtils';
|
|
12
|
+
export * from './ValidationUtils';
|
|
13
|
+
export * from './Logger';
|
|
14
|
+
export * from './GenerateComponentValidator';
|
|
15
|
+
export * from './performance';
|
|
16
|
+
export * from './stringify';
|
|
17
|
+
export { getFactorsForLevel, getFactorIdsForLevel, getFactorDefinition as getGranularityFactorDefinition, tryGetFactorDefinition, getAllFactorIds as getAllResolverFactorIds, resolveFactorValue, resolveAllFactors, filterFactorsByCategory, getCascadingFactors, getLocalFactors, getFactorCountForLevel, getFactorCountsByLevel, } from './factor-resolver';
|
|
18
|
+
export type { ResolveFactorOptions } from './factor-resolver';
|
|
19
|
+
export { isHigherGranularity, isLowerGranularity, isSameGranularity, isHigherOrEqualGranularity, isLowerOrEqualGranularity, getChildGranularities, getImmediateChildLevel, getParentGranularity, getAncestorGranularities, isValidGranularityLevel, assertGranularityLevel, getAllGranularityLevels, getLevelDistance, canContain, getHighestLevel, getLowestLevel, getLevelsBetween, } from './granularity-helpers';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Utilities
|
|
3
|
+
*
|
|
4
|
+
* Cross-platform performance measurement utilities.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module utils/performance
|
|
8
|
+
* @since 4.0.0
|
|
9
|
+
*
|
|
10
|
+
* Powered by Nikkory
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Get high-resolution timestamp.
|
|
14
|
+
* Uses performance.now() in browsers, Date.now() in Node.js.
|
|
15
|
+
*
|
|
16
|
+
* @returns Timestamp in milliseconds
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const start = now();
|
|
21
|
+
* // ... operations ...
|
|
22
|
+
* const duration = now() - start;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function now(): number;
|
|
26
|
+
//# sourceMappingURL=performance.d.ts.map
|