css-calipers 0.9.3 → 0.9.4
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/README.md +100 -0
- package/dist/cjs/comparisons/index.js +25 -0
- package/dist/cjs/containerQueries/containerQueries.js +115 -0
- package/dist/cjs/containerQueries/factory.js +123 -0
- package/dist/cjs/containerQueries/helpers.js +95 -0
- package/dist/cjs/containerQueries/index.js +16 -0
- package/dist/cjs/containerQueries/linting/aspectRatio.js +24 -0
- package/dist/cjs/containerQueries/linting/block.js +23 -0
- package/dist/cjs/containerQueries/linting/core.js +25 -0
- package/dist/cjs/containerQueries/linting/custom.js +11 -0
- package/dist/cjs/containerQueries/linting/inline.js +23 -0
- package/dist/cjs/containerQueries/linting/resolution.js +12 -0
- package/dist/cjs/containerQueries/linting/style.js +28 -0
- package/dist/cjs/containerQueries/linting.js +24 -0
- package/dist/cjs/containerQueries/moduleRegistry.js +5 -0
- package/dist/cjs/containerQueries/modules/aspectRatio.js +51 -0
- package/dist/cjs/containerQueries/modules/block.js +53 -0
- package/dist/cjs/containerQueries/modules/custom.js +43 -0
- package/dist/cjs/containerQueries/modules/index.js +21 -0
- package/dist/cjs/containerQueries/modules/inline.js +53 -0
- package/dist/cjs/containerQueries/modules/size.js +2 -0
- package/dist/cjs/containerQueries/modules/style.js +36 -0
- package/dist/cjs/containerQueries/types.js +2 -0
- package/dist/cjs/containerQueries/validation.js +191 -0
- package/dist/cjs/core.js +5 -278
- package/dist/cjs/factory.js +21 -0
- package/dist/cjs/fraction.js +139 -0
- package/dist/cjs/internal/buildMeasurementCreationError.js +16 -0
- package/dist/cjs/internal/buildMeasurementCreationError.tests.js +5 -0
- package/dist/cjs/internal/createComponentQueriesApi.js +56 -0
- package/dist/cjs/internal/createCoreApi.js +336 -0
- package/dist/cjs/internal/createMediaQueriesApi.js +74 -0
- package/dist/cjs/internal/createUnitsApi.js +18 -0
- package/dist/cjs/internal/errors.js +118 -5
- package/dist/cjs/internal/normalizeToArray.js +9 -0
- package/dist/cjs/libraryHelpers/vanilla-extract.js +6 -2
- package/dist/cjs/logicalOperators/index.js +18 -0
- package/dist/cjs/mediaQueries/factory.js +5 -4
- package/dist/cjs/mediaQueries/mediaQueries.js +7 -5
- package/dist/cjs/mediaQueries/modules/dimensions.js +10 -8
- package/dist/cjs/mediaQueries/modules/resolution.js +6 -4
- package/dist/cjs/mediaQueries/validation.js +128 -116
- package/dist/cjs/ratio.js +141 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/validation.js +20 -0
- package/dist/esm/comparisons/index.d.ts +23 -0
- package/dist/esm/comparisons/index.d.ts.map +1 -0
- package/dist/esm/comparisons/index.js +22 -0
- package/dist/esm/containerQueries/containerQueries.d.ts +36 -0
- package/dist/esm/containerQueries/containerQueries.d.ts.map +1 -0
- package/dist/esm/containerQueries/containerQueries.js +109 -0
- package/dist/esm/containerQueries/factory.d.ts +20 -0
- package/dist/esm/containerQueries/factory.d.ts.map +1 -0
- package/dist/esm/containerQueries/factory.js +119 -0
- package/dist/esm/containerQueries/helpers.d.ts +53 -0
- package/dist/esm/containerQueries/helpers.d.ts.map +1 -0
- package/dist/esm/containerQueries/helpers.js +82 -0
- package/dist/esm/containerQueries/index.d.ts +10 -0
- package/dist/esm/containerQueries/index.d.ts.map +1 -0
- package/dist/esm/containerQueries/index.js +4 -0
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts +4 -0
- package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/aspectRatio.js +19 -0
- package/dist/esm/containerQueries/linting/block.d.ts +4 -0
- package/dist/esm/containerQueries/linting/block.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/block.js +18 -0
- package/dist/esm/containerQueries/linting/core.d.ts +4 -0
- package/dist/esm/containerQueries/linting/core.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/core.js +20 -0
- package/dist/esm/containerQueries/linting/custom.d.ts +3 -0
- package/dist/esm/containerQueries/linting/custom.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/custom.js +7 -0
- package/dist/esm/containerQueries/linting/inline.d.ts +4 -0
- package/dist/esm/containerQueries/linting/inline.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/inline.js +18 -0
- package/dist/esm/containerQueries/linting/resolution.d.ts +1 -0
- package/dist/esm/containerQueries/linting/resolution.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/resolution.js +12 -0
- package/dist/esm/containerQueries/linting/style.d.ts +3 -0
- package/dist/esm/containerQueries/linting/style.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting/style.js +24 -0
- package/dist/esm/containerQueries/linting.d.ts +4 -0
- package/dist/esm/containerQueries/linting.d.ts.map +1 -0
- package/dist/esm/containerQueries/linting.js +20 -0
- package/dist/esm/containerQueries/moduleRegistry.d.ts +25 -0
- package/dist/esm/containerQueries/moduleRegistry.d.ts.map +1 -0
- package/dist/esm/containerQueries/moduleRegistry.js +1 -0
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts +17 -0
- package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/aspectRatio.js +47 -0
- package/dist/esm/containerQueries/modules/block.d.ts +20 -0
- package/dist/esm/containerQueries/modules/block.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/block.js +49 -0
- package/dist/esm/containerQueries/modules/custom.d.ts +13 -0
- package/dist/esm/containerQueries/modules/custom.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/custom.js +39 -0
- package/dist/esm/containerQueries/modules/index.d.ts +6 -0
- package/dist/esm/containerQueries/modules/index.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/index.js +5 -0
- package/dist/esm/containerQueries/modules/inline.d.ts +20 -0
- package/dist/esm/containerQueries/modules/inline.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/inline.js +49 -0
- package/dist/esm/containerQueries/modules/size.d.ts +41 -0
- package/dist/esm/containerQueries/modules/size.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/size.js +1 -0
- package/dist/esm/containerQueries/modules/style.d.ts +11 -0
- package/dist/esm/containerQueries/modules/style.d.ts.map +1 -0
- package/dist/esm/containerQueries/modules/style.js +32 -0
- package/dist/esm/containerQueries/types.d.ts +81 -0
- package/dist/esm/containerQueries/types.d.ts.map +1 -0
- package/dist/esm/containerQueries/types.js +1 -0
- package/dist/esm/containerQueries/validation.d.ts +41 -0
- package/dist/esm/containerQueries/validation.d.ts.map +1 -0
- package/dist/esm/containerQueries/validation.js +187 -0
- package/dist/esm/core.d.ts +27 -26
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/core.js +5 -266
- package/dist/esm/factory.d.ts +13 -0
- package/dist/esm/factory.d.ts.map +1 -0
- package/dist/esm/factory.js +17 -0
- package/dist/esm/fraction.d.ts +23 -0
- package/dist/esm/fraction.d.ts.map +1 -0
- package/dist/esm/fraction.js +129 -0
- package/dist/esm/internal/buildMeasurementCreationError.d.ts +12 -0
- package/dist/esm/internal/buildMeasurementCreationError.d.ts.map +1 -0
- package/dist/esm/internal/buildMeasurementCreationError.js +12 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts +3 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.d.ts.map +1 -0
- package/dist/esm/internal/buildMeasurementCreationError.tests.js +1 -0
- package/dist/esm/internal/createComponentQueriesApi.d.ts +34 -0
- package/dist/esm/internal/createComponentQueriesApi.d.ts.map +1 -0
- package/dist/esm/internal/createComponentQueriesApi.js +52 -0
- package/dist/esm/internal/createCoreApi.d.ts +289 -0
- package/dist/esm/internal/createCoreApi.d.ts.map +1 -0
- package/dist/esm/internal/createCoreApi.js +332 -0
- package/dist/esm/internal/createMediaQueriesApi.d.ts +35 -0
- package/dist/esm/internal/createMediaQueriesApi.d.ts.map +1 -0
- package/dist/esm/internal/createMediaQueriesApi.js +70 -0
- package/dist/esm/internal/createUnitsApi.d.ts +13 -0
- package/dist/esm/internal/createUnitsApi.d.ts.map +1 -0
- package/dist/esm/internal/createUnitsApi.js +14 -0
- package/dist/esm/internal/errors.d.ts +30 -0
- package/dist/esm/internal/errors.d.ts.map +1 -1
- package/dist/esm/internal/errors.js +113 -4
- package/dist/esm/internal/normalizeToArray.d.ts +2 -0
- package/dist/esm/internal/normalizeToArray.d.ts.map +1 -0
- package/dist/esm/internal/normalizeToArray.js +5 -0
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts +2 -1
- package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +1 -1
- package/dist/esm/libraryHelpers/vanilla-extract.js +4 -1
- package/dist/esm/logicalOperators/index.d.ts +2 -0
- package/dist/esm/logicalOperators/index.d.ts.map +1 -0
- package/dist/esm/logicalOperators/index.js +17 -0
- package/dist/esm/mediaQueries/factory.d.ts +16 -1
- package/dist/esm/mediaQueries/factory.d.ts.map +1 -1
- package/dist/esm/mediaQueries/factory.js +3 -2
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +2 -2
- package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +1 -1
- package/dist/esm/mediaQueries/mediaQueries.d.ts +2 -0
- package/dist/esm/mediaQueries/mediaQueries.d.ts.map +1 -1
- package/dist/esm/mediaQueries/mediaQueries.js +4 -2
- package/dist/esm/mediaQueries/modules/dimensions.d.ts +2 -0
- package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +1 -1
- package/dist/esm/mediaQueries/modules/dimensions.js +4 -2
- package/dist/esm/mediaQueries/modules/resolution.d.ts +2 -0
- package/dist/esm/mediaQueries/modules/resolution.d.ts.map +1 -1
- package/dist/esm/mediaQueries/modules/resolution.js +4 -2
- package/dist/esm/mediaQueries/validation.d.ts +28 -8
- package/dist/esm/mediaQueries/validation.d.ts.map +1 -1
- package/dist/esm/mediaQueries/validation.js +126 -107
- package/dist/esm/ratio.d.ts +22 -0
- package/dist/esm/ratio.d.ts.map +1 -0
- package/dist/esm/ratio.js +131 -0
- package/dist/esm/types.d.ts +35 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/validation.d.ts +10 -0
- package/dist/esm/validation.d.ts.map +1 -0
- package/dist/esm/validation.js +15 -0
- package/dist/examples/containerQueries.example.js +54 -0
- package/dist/examples/examples/containerQueries.example.js +54 -0
- package/dist/examples/examples/factory-wrapper.example.js +33 -0
- package/dist/examples/examples/lineHeight-normalizer.example.js +81 -0
- package/dist/examples/examples/mediaQueries-multipleInstances.example.js +127 -0
- package/dist/examples/examples/mixedQueries.example.js +55 -0
- package/dist/examples/examples/validation-and-runtime-checks.example.js +85 -0
- package/dist/examples/examples/validation-unit-tests.example.js +35 -0
- package/dist/examples/factory-wrapper.example.js +33 -0
- package/dist/examples/lineHeight-normalizer.example.js +81 -0
- package/dist/examples/mediaQueries-multipleInstances.example.js +127 -0
- package/dist/examples/mixedQueries.example.js +60 -0
- package/dist/examples/src/comparisons/index.js +25 -0
- package/dist/examples/src/containerQueries/containerQueries.js +96 -0
- package/dist/examples/src/containerQueries/factory.js +123 -0
- package/dist/examples/src/containerQueries/helpers.js +94 -0
- package/dist/examples/src/containerQueries/index.js +16 -0
- package/dist/examples/src/containerQueries/linting/aspectRatio.js +20 -0
- package/dist/examples/src/containerQueries/linting/block.js +20 -0
- package/dist/examples/src/containerQueries/linting/core.js +19 -0
- package/dist/examples/src/containerQueries/linting/custom.js +11 -0
- package/dist/examples/src/containerQueries/linting/inline.js +20 -0
- package/dist/examples/src/containerQueries/linting/style.js +28 -0
- package/dist/examples/src/containerQueries/linting.js +24 -0
- package/dist/examples/src/containerQueries/moduleRegistry.js +5 -0
- package/dist/examples/src/containerQueries/modules/aspectRatio.js +33 -0
- package/dist/examples/src/containerQueries/modules/block.js +44 -0
- package/dist/examples/src/containerQueries/modules/custom.js +31 -0
- package/dist/examples/src/containerQueries/modules/index.js +21 -0
- package/dist/examples/src/containerQueries/modules/inline.js +44 -0
- package/dist/examples/src/containerQueries/modules/style.js +36 -0
- package/dist/examples/src/containerQueries/types.js +2 -0
- package/dist/examples/src/containerQueries/validation.js +177 -0
- package/dist/examples/src/core.js +16 -0
- package/dist/examples/src/factory.js +21 -0
- package/dist/examples/src/index.js +30 -0
- package/dist/examples/src/internal/buildMeasurementCreationError.js +16 -0
- package/dist/examples/src/internal/createCoreApi.js +336 -0
- package/dist/examples/src/internal/createMediaQueriesApi.js +74 -0
- package/dist/examples/src/internal/createUnitsApi.js +18 -0
- package/dist/examples/src/internal/errors.js +130 -0
- package/dist/examples/src/libraryHelpers/vanilla-extract.js +11 -0
- package/dist/examples/src/mediaQueries/factory.js +163 -0
- package/dist/examples/src/mediaQueries/helpers.js +88 -0
- package/dist/examples/src/mediaQueries/index.js +23 -0
- package/dist/examples/src/mediaQueries/linting/core.js +19 -0
- package/dist/examples/src/mediaQueries/linting/resolution.js +11 -0
- package/dist/examples/src/mediaQueries/linting.js +24 -0
- package/dist/examples/src/mediaQueries/mediaQueries.js +53 -0
- package/dist/examples/src/mediaQueries/moduleRegistry.js +5 -0
- package/dist/examples/src/mediaQueries/modules/custom.js +26 -0
- package/dist/examples/src/mediaQueries/modules/dimensions.js +61 -0
- package/dist/examples/src/mediaQueries/modules/display.js +20 -0
- package/dist/examples/src/mediaQueries/modules/environment.js +20 -0
- package/dist/examples/src/mediaQueries/modules/index.js +23 -0
- package/dist/examples/src/mediaQueries/modules/interaction.js +26 -0
- package/dist/examples/src/mediaQueries/modules/preferences.js +26 -0
- package/dist/examples/src/mediaQueries/modules/resolution.js +31 -0
- package/dist/examples/src/mediaQueries/types.js +2 -0
- package/dist/examples/src/mediaQueries/validation.js +128 -0
- package/dist/examples/src/ratio.js +141 -0
- package/dist/examples/src/types.js +2 -0
- package/dist/examples/src/unitDefinitions.js +67 -0
- package/dist/examples/src/units/absolute.js +11 -0
- package/dist/examples/src/units/angle.js +8 -0
- package/dist/examples/src/units/container.js +10 -0
- package/dist/examples/src/units/font-relative.js +16 -0
- package/dist/examples/src/units/frequency.js +6 -0
- package/dist/examples/src/units/grid.js +5 -0
- package/dist/examples/src/units/percent.js +7 -0
- package/dist/examples/src/units/resolution.js +7 -0
- package/dist/examples/src/units/time.js +6 -0
- package/dist/examples/src/units/viewport-dynamic.js +10 -0
- package/dist/examples/src/units/viewport-large.js +10 -0
- package/dist/examples/src/units/viewport-small.js +10 -0
- package/dist/examples/src/units/viewport.js +10 -0
- package/dist/examples/src/validation.js +20 -0
- package/dist/examples/validation-and-runtime-checks.example.js +85 -0
- package/dist/examples/validation-unit-tests.example.js +35 -0
- package/package.json +16 -5
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitDimensionsFeatures = exports.createEmitDimensionsFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const validation_1 = require("../validation");
|
|
6
|
+
const linting_1 = require("../linting");
|
|
7
|
+
const core_1 = require("../linting/core");
|
|
8
|
+
const createEmitDimensionsFeatures = (validation) => (props, helpers, validate) => {
|
|
9
|
+
const { runMediaQueryValidation, validateMinMaxHeight, validateHeightValuesPositive, validateMinMaxAspectRatio, validateAspectRatioValuesPositive, validateWidthValuesPositive, } = validation;
|
|
10
|
+
if (!runMediaQueryValidation(props, helpers, validateMinMaxHeight, 'dimensions', 'minHeight must be less than or equal to maxHeight')) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!runMediaQueryValidation(props, helpers, validateHeightValuesPositive, 'dimensions', 'height values must be greater than 0')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!(0, linting_1.runMediaQueryLint)(props, helpers, core_1.lintWidthRedundancy, 'width should not be combined with minWidth or maxWidth')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!(0, linting_1.runMediaQueryLint)(props, helpers, core_1.lintHeightRedundancy, 'height should not be combined with minHeight or maxHeight')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!runMediaQueryValidation(props, helpers, validateWidthValuesPositive, 'dimensions', 'width values must be greater than 0')) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!runMediaQueryValidation(props, helpers, validateMinMaxAspectRatio, 'dimensions', 'minAspectRatio must be less than or equal to maxAspectRatio')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!runMediaQueryValidation(props, helpers, validateAspectRatioValuesPositive, 'dimensions', 'aspect ratio values must be greater than 0')) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'dimensions')) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const { addFeature } = helpers;
|
|
35
|
+
if (props.width) {
|
|
36
|
+
addFeature('width', props.width);
|
|
37
|
+
}
|
|
38
|
+
if (props.height) {
|
|
39
|
+
addFeature('height', props.height);
|
|
40
|
+
}
|
|
41
|
+
if (props.minHeight) {
|
|
42
|
+
addFeature('min-height', props.minHeight);
|
|
43
|
+
}
|
|
44
|
+
if (props.maxHeight) {
|
|
45
|
+
addFeature('max-height', props.maxHeight);
|
|
46
|
+
}
|
|
47
|
+
if (props.aspectRatio) {
|
|
48
|
+
addFeature('aspect-ratio', props.aspectRatio);
|
|
49
|
+
}
|
|
50
|
+
if (props.minAspectRatio) {
|
|
51
|
+
addFeature('min-aspect-ratio', props.minAspectRatio);
|
|
52
|
+
}
|
|
53
|
+
if (props.maxAspectRatio) {
|
|
54
|
+
addFeature('max-aspect-ratio', props.maxAspectRatio);
|
|
55
|
+
}
|
|
56
|
+
if (props.orientation) {
|
|
57
|
+
addFeature('orientation', props.orientation);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.createEmitDimensionsFeatures = createEmitDimensionsFeatures;
|
|
61
|
+
exports.emitDimensionsFeatures = (0, exports.createEmitDimensionsFeatures)(validation_1.defaultMediaQueryValidation);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitDisplayFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const emitDisplayFeatures = (props, helpers, validate) => {
|
|
6
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'display')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { addFeature } = helpers;
|
|
10
|
+
if (props.colorGamut) {
|
|
11
|
+
addFeature('color-gamut', props.colorGamut);
|
|
12
|
+
}
|
|
13
|
+
if (props.dynamicRange) {
|
|
14
|
+
addFeature('dynamic-range', props.dynamicRange);
|
|
15
|
+
}
|
|
16
|
+
if (props.invertedColors) {
|
|
17
|
+
addFeature('inverted-colors', props.invertedColors);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.emitDisplayFeatures = emitDisplayFeatures;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitEnvironmentFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const emitEnvironmentFeatures = (props, helpers, validate) => {
|
|
6
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'environment')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { addFeature } = helpers;
|
|
10
|
+
if (props.scripting) {
|
|
11
|
+
addFeature('scripting', props.scripting);
|
|
12
|
+
}
|
|
13
|
+
if (props.overflowBlock) {
|
|
14
|
+
addFeature('overflow-block', props.overflowBlock);
|
|
15
|
+
}
|
|
16
|
+
if (props.overflowInline) {
|
|
17
|
+
addFeature('overflow-inline', props.overflowInline);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.emitEnvironmentFeatures = emitEnvironmentFeatures;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./custom"), exports);
|
|
18
|
+
__exportStar(require("./dimensions"), exports);
|
|
19
|
+
__exportStar(require("./display"), exports);
|
|
20
|
+
__exportStar(require("./environment"), exports);
|
|
21
|
+
__exportStar(require("./interaction"), exports);
|
|
22
|
+
__exportStar(require("./preferences"), exports);
|
|
23
|
+
__exportStar(require("./resolution"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitInteractionFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const emitInteractionFeatures = (props, helpers, validate) => {
|
|
6
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'interaction')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { addFeature } = helpers;
|
|
10
|
+
if (props.hover) {
|
|
11
|
+
addFeature('hover', props.hover);
|
|
12
|
+
}
|
|
13
|
+
if (props.anyHover) {
|
|
14
|
+
addFeature('any-hover', props.anyHover);
|
|
15
|
+
}
|
|
16
|
+
if (props.pointer) {
|
|
17
|
+
addFeature('pointer', props.pointer);
|
|
18
|
+
}
|
|
19
|
+
if (props.anyPointer) {
|
|
20
|
+
addFeature('any-pointer', props.anyPointer);
|
|
21
|
+
}
|
|
22
|
+
if (props.update) {
|
|
23
|
+
addFeature('update', props.update);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.emitInteractionFeatures = emitInteractionFeatures;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitPreferencesFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const emitPreferencesFeatures = (props, helpers, validate) => {
|
|
6
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'preferences')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { addFeature } = helpers;
|
|
10
|
+
if (props.colorScheme) {
|
|
11
|
+
addFeature('prefers-color-scheme', props.colorScheme);
|
|
12
|
+
}
|
|
13
|
+
if (props.reducedMotion) {
|
|
14
|
+
addFeature('prefers-reduced-motion', props.reducedMotion);
|
|
15
|
+
}
|
|
16
|
+
if (props.reducedData) {
|
|
17
|
+
addFeature('prefers-reduced-data', props.reducedData);
|
|
18
|
+
}
|
|
19
|
+
if (props.contrast) {
|
|
20
|
+
addFeature('prefers-contrast', props.contrast);
|
|
21
|
+
}
|
|
22
|
+
if (props.forcedColors) {
|
|
23
|
+
addFeature('forced-colors', props.forcedColors);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.emitPreferencesFeatures = emitPreferencesFeatures;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitResolutionFeatures = exports.createEmitResolutionFeatures = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const validation_1 = require("../validation");
|
|
6
|
+
const linting_1 = require("../linting");
|
|
7
|
+
const resolution_1 = require("../linting/resolution");
|
|
8
|
+
const createEmitResolutionFeatures = (validation) => (props, helpers, validate) => {
|
|
9
|
+
const { runMediaQueryValidation, validateResolutionValues } = validation;
|
|
10
|
+
if (!runMediaQueryValidation(props, helpers, validateResolutionValues, 'resolution', 'resolution values must be greater than 0')) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!(0, linting_1.runMediaQueryLint)(props, helpers, resolution_1.lintResolutionRedundancy, 'resolution should not be combined with minResolution or maxResolution')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!(0, helpers_1.applyMediaQueryValidation)(props, helpers, validate, 'resolution')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { addFeature } = helpers;
|
|
20
|
+
if (props.resolutionValue) {
|
|
21
|
+
addFeature('resolution', props.resolutionValue);
|
|
22
|
+
}
|
|
23
|
+
if (props.minResolution) {
|
|
24
|
+
addFeature('min-resolution', props.minResolution);
|
|
25
|
+
}
|
|
26
|
+
if (props.maxResolution) {
|
|
27
|
+
addFeature('max-resolution', props.maxResolution);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.createEmitResolutionFeatures = createEmitResolutionFeatures;
|
|
31
|
+
exports.emitResolutionFeatures = (0, exports.createEmitResolutionFeatures)(validation_1.defaultMediaQueryValidation);
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultMediaQueryValidation = exports.validateResolutionValues = exports.validateAspectRatioValuesPositive = exports.validateMinMaxAspectRatio = exports.validateHeightValuesPositive = exports.validateMinMaxHeight = exports.validateWidthValuesPositive = exports.validateMinMaxWidth = exports.runMediaQueryValidation = exports.createMediaQueryValidation = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
const toValidationResult = (error, fallback) => {
|
|
7
|
+
if (error instanceof Error && error.message)
|
|
8
|
+
return error.message;
|
|
9
|
+
return fallback;
|
|
10
|
+
};
|
|
11
|
+
const createMediaQueryValidation = (core) => {
|
|
12
|
+
const { assertCondition, assertMatchingUnits } = core;
|
|
13
|
+
const runMediaQueryValidation = (config, helpers, check, context, fallbackMessage = "Invalid media query configuration") => {
|
|
14
|
+
if (!check)
|
|
15
|
+
return true;
|
|
16
|
+
try {
|
|
17
|
+
check(config);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const result = toValidationResult(error, fallbackMessage);
|
|
22
|
+
return (0, helpers_1.applyMediaQueryValidation)(config, helpers, () => result, context);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const validateMinMaxWidth = (props) => {
|
|
26
|
+
if (!props.minWidth || !props.maxWidth)
|
|
27
|
+
return;
|
|
28
|
+
assertMatchingUnits(props.minWidth, props.maxWidth, "mediaQueries.minMaxWidth");
|
|
29
|
+
assertCondition(props.minWidth.getValue() <= props.maxWidth.getValue(), "minWidth must be less than or equal to maxWidth");
|
|
30
|
+
};
|
|
31
|
+
const validateWidthValuesPositive = (props) => {
|
|
32
|
+
const assertPositive = (value, label) => {
|
|
33
|
+
assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
|
|
34
|
+
};
|
|
35
|
+
if (props.width) {
|
|
36
|
+
assertPositive(props.width, "width");
|
|
37
|
+
}
|
|
38
|
+
if (props.minWidth) {
|
|
39
|
+
assertPositive(props.minWidth, "minWidth");
|
|
40
|
+
}
|
|
41
|
+
if (props.maxWidth) {
|
|
42
|
+
assertPositive(props.maxWidth, "maxWidth");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const validateMinMaxHeight = (props) => {
|
|
46
|
+
if (!props.minHeight || !props.maxHeight)
|
|
47
|
+
return;
|
|
48
|
+
assertMatchingUnits(props.minHeight, props.maxHeight, "mediaQueries.minMaxHeight");
|
|
49
|
+
assertCondition(props.minHeight.getValue() <= props.maxHeight.getValue(), "minHeight must be less than or equal to maxHeight");
|
|
50
|
+
};
|
|
51
|
+
const validateHeightValuesPositive = (props) => {
|
|
52
|
+
const assertPositive = (value, label) => {
|
|
53
|
+
assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
|
|
54
|
+
};
|
|
55
|
+
if (props.height) {
|
|
56
|
+
assertPositive(props.height, "height");
|
|
57
|
+
}
|
|
58
|
+
if (props.minHeight) {
|
|
59
|
+
assertPositive(props.minHeight, "minHeight");
|
|
60
|
+
}
|
|
61
|
+
if (props.maxHeight) {
|
|
62
|
+
assertPositive(props.maxHeight, "maxHeight");
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const assertRatio = (value, label) => {
|
|
66
|
+
assertCondition((0, core_1.isRatio)(value), `${label} must be a ratio created with r()`);
|
|
67
|
+
};
|
|
68
|
+
const assertRatioPositive = (value, label) => {
|
|
69
|
+
assertCondition(value.numerator() > 0 && value.denominator() > 0, `${label} must be a valid ratio greater than 0`);
|
|
70
|
+
};
|
|
71
|
+
const validateMinMaxAspectRatio = (props) => {
|
|
72
|
+
if (!props.minAspectRatio || !props.maxAspectRatio)
|
|
73
|
+
return;
|
|
74
|
+
assertRatio(props.minAspectRatio, "minAspectRatio");
|
|
75
|
+
assertRatio(props.maxAspectRatio, "maxAspectRatio");
|
|
76
|
+
const minRatio = (0, core_1.ratioToFloat)(props.minAspectRatio);
|
|
77
|
+
const maxRatio = (0, core_1.ratioToFloat)(props.maxAspectRatio);
|
|
78
|
+
assertCondition(minRatio <= maxRatio, "minAspectRatio must be less than or equal to maxAspectRatio");
|
|
79
|
+
};
|
|
80
|
+
const validateAspectRatioValuesPositive = (props) => {
|
|
81
|
+
if (props.aspectRatio !== undefined) {
|
|
82
|
+
assertRatio(props.aspectRatio, "aspectRatio");
|
|
83
|
+
assertRatioPositive(props.aspectRatio, "aspectRatio");
|
|
84
|
+
}
|
|
85
|
+
if (props.minAspectRatio !== undefined) {
|
|
86
|
+
assertRatio(props.minAspectRatio, "minAspectRatio");
|
|
87
|
+
assertRatioPositive(props.minAspectRatio, "minAspectRatio");
|
|
88
|
+
}
|
|
89
|
+
if (props.maxAspectRatio !== undefined) {
|
|
90
|
+
assertRatio(props.maxAspectRatio, "maxAspectRatio");
|
|
91
|
+
assertRatioPositive(props.maxAspectRatio, "maxAspectRatio");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const validateResolutionValues = (props) => {
|
|
95
|
+
const assertPositive = (value, label) => {
|
|
96
|
+
assertCondition(value.getValue() > 0, `${label} must be greater than 0`);
|
|
97
|
+
};
|
|
98
|
+
if (props.resolutionValue) {
|
|
99
|
+
assertPositive(props.resolutionValue, "resolution");
|
|
100
|
+
}
|
|
101
|
+
if (props.minResolution) {
|
|
102
|
+
assertPositive(props.minResolution, "minResolution");
|
|
103
|
+
}
|
|
104
|
+
if (props.maxResolution) {
|
|
105
|
+
assertPositive(props.maxResolution, "maxResolution");
|
|
106
|
+
}
|
|
107
|
+
if (props.minResolution && props.maxResolution) {
|
|
108
|
+
assertMatchingUnits(props.minResolution, props.maxResolution, "mediaQueries.resolutionUnits");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
runMediaQueryValidation,
|
|
113
|
+
validateMinMaxWidth,
|
|
114
|
+
validateWidthValuesPositive,
|
|
115
|
+
validateMinMaxHeight,
|
|
116
|
+
validateHeightValuesPositive,
|
|
117
|
+
validateMinMaxAspectRatio,
|
|
118
|
+
validateAspectRatioValuesPositive,
|
|
119
|
+
validateResolutionValues,
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
exports.createMediaQueryValidation = createMediaQueryValidation;
|
|
123
|
+
const defaultMediaQueryValidation = (0, exports.createMediaQueryValidation)({
|
|
124
|
+
assertCondition: core_1.assertCondition,
|
|
125
|
+
assertMatchingUnits: core_1.assertMatchingUnits,
|
|
126
|
+
});
|
|
127
|
+
exports.defaultMediaQueryValidation = defaultMediaQueryValidation;
|
|
128
|
+
exports.runMediaQueryValidation = defaultMediaQueryValidation.runMediaQueryValidation, exports.validateMinMaxWidth = defaultMediaQueryValidation.validateMinMaxWidth, exports.validateWidthValuesPositive = defaultMediaQueryValidation.validateWidthValuesPositive, exports.validateMinMaxHeight = defaultMediaQueryValidation.validateMinMaxHeight, exports.validateHeightValuesPositive = defaultMediaQueryValidation.validateHeightValuesPositive, exports.validateMinMaxAspectRatio = defaultMediaQueryValidation.validateMinMaxAspectRatio, exports.validateAspectRatioValuesPositive = defaultMediaQueryValidation.validateAspectRatioValuesPositive, exports.validateResolutionValues = defaultMediaQueryValidation.validateResolutionValues;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _RatioImpl_numerator, _RatioImpl_denominator, _RatioImpl_omitDenominatorWhenOne;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ratioToFloat = exports.simplifyRatio = exports.reduceRatio = exports.normalizeRatio = exports.parseRatio = exports.isRatio = void 0;
|
|
16
|
+
exports.r = r;
|
|
17
|
+
class RatioImpl {
|
|
18
|
+
constructor(numerator, denominator, options = {}) {
|
|
19
|
+
var _a;
|
|
20
|
+
_RatioImpl_numerator.set(this, void 0);
|
|
21
|
+
_RatioImpl_denominator.set(this, void 0);
|
|
22
|
+
_RatioImpl_omitDenominatorWhenOne.set(this, void 0);
|
|
23
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
|
|
24
|
+
throw new Error("Ratio values must be finite numbers.");
|
|
25
|
+
}
|
|
26
|
+
if (denominator === 0) {
|
|
27
|
+
throw new Error("Ratio denominator cannot be zero.");
|
|
28
|
+
}
|
|
29
|
+
__classPrivateFieldSet(this, _RatioImpl_numerator, numerator, "f");
|
|
30
|
+
__classPrivateFieldSet(this, _RatioImpl_denominator, denominator, "f");
|
|
31
|
+
__classPrivateFieldSet(this, _RatioImpl_omitDenominatorWhenOne, (_a = options.omitDenominatorWhenOne) !== null && _a !== void 0 ? _a : false, "f");
|
|
32
|
+
}
|
|
33
|
+
numerator() {
|
|
34
|
+
return __classPrivateFieldGet(this, _RatioImpl_numerator, "f");
|
|
35
|
+
}
|
|
36
|
+
denominator() {
|
|
37
|
+
return __classPrivateFieldGet(this, _RatioImpl_denominator, "f");
|
|
38
|
+
}
|
|
39
|
+
withNumerator(numerator) {
|
|
40
|
+
return new RatioImpl(numerator, __classPrivateFieldGet(this, _RatioImpl_denominator, "f"));
|
|
41
|
+
}
|
|
42
|
+
withDenominator(denominator) {
|
|
43
|
+
return new RatioImpl(__classPrivateFieldGet(this, _RatioImpl_numerator, "f"), denominator);
|
|
44
|
+
}
|
|
45
|
+
valueOf() {
|
|
46
|
+
return __classPrivateFieldGet(this, _RatioImpl_numerator, "f") / __classPrivateFieldGet(this, _RatioImpl_denominator, "f");
|
|
47
|
+
}
|
|
48
|
+
css() {
|
|
49
|
+
if (__classPrivateFieldGet(this, _RatioImpl_omitDenominatorWhenOne, "f") && __classPrivateFieldGet(this, _RatioImpl_denominator, "f") === 1) {
|
|
50
|
+
return String(__classPrivateFieldGet(this, _RatioImpl_numerator, "f"));
|
|
51
|
+
}
|
|
52
|
+
return `${__classPrivateFieldGet(this, _RatioImpl_numerator, "f")}/${__classPrivateFieldGet(this, _RatioImpl_denominator, "f")}`;
|
|
53
|
+
}
|
|
54
|
+
toString() {
|
|
55
|
+
return this.css();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_RatioImpl_numerator = new WeakMap(), _RatioImpl_denominator = new WeakMap(), _RatioImpl_omitDenominatorWhenOne = new WeakMap();
|
|
59
|
+
function r(numeratorOrDenominator, denominator) {
|
|
60
|
+
const numerator = denominator === undefined ? numeratorOrDenominator : numeratorOrDenominator;
|
|
61
|
+
const resolvedDenominator = denominator === undefined ? 1 : denominator;
|
|
62
|
+
return new RatioImpl(numerator, resolvedDenominator);
|
|
63
|
+
}
|
|
64
|
+
const isRatio = (value) => {
|
|
65
|
+
return (typeof value === "object" &&
|
|
66
|
+
value !== null &&
|
|
67
|
+
"css" in value &&
|
|
68
|
+
"numerator" in value &&
|
|
69
|
+
"denominator" in value &&
|
|
70
|
+
typeof value.css === "function" &&
|
|
71
|
+
typeof value.numerator === "function" &&
|
|
72
|
+
typeof value.denominator === "function");
|
|
73
|
+
};
|
|
74
|
+
exports.isRatio = isRatio;
|
|
75
|
+
const parseRatio = (value) => {
|
|
76
|
+
if (typeof value === "number") {
|
|
77
|
+
return Number.isFinite(value) ? { numerator: value, denominator: 1 } : null;
|
|
78
|
+
}
|
|
79
|
+
if ((0, exports.isRatio)(value)) {
|
|
80
|
+
return { numerator: value.numerator(), denominator: value.denominator() };
|
|
81
|
+
}
|
|
82
|
+
const trimmed = value.trim();
|
|
83
|
+
if (!trimmed)
|
|
84
|
+
return null;
|
|
85
|
+
if (trimmed.includes("/")) {
|
|
86
|
+
const [left, right] = trimmed.split("/");
|
|
87
|
+
if (left === undefined || right === undefined)
|
|
88
|
+
return null;
|
|
89
|
+
const numerator = Number(left.trim());
|
|
90
|
+
const denominator = Number(right.trim());
|
|
91
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator))
|
|
92
|
+
return null;
|
|
93
|
+
if (denominator === 0)
|
|
94
|
+
return null;
|
|
95
|
+
return { numerator, denominator };
|
|
96
|
+
}
|
|
97
|
+
const parsed = Number(trimmed);
|
|
98
|
+
return Number.isFinite(parsed) ? { numerator: parsed, denominator: 1 } : null;
|
|
99
|
+
};
|
|
100
|
+
exports.parseRatio = parseRatio;
|
|
101
|
+
const normalizeRatio = (ratio) => {
|
|
102
|
+
let numerator = ratio.numerator();
|
|
103
|
+
let denominator = ratio.denominator();
|
|
104
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) {
|
|
105
|
+
throw new Error("Ratio values must be finite numbers.");
|
|
106
|
+
}
|
|
107
|
+
if (denominator === 0) {
|
|
108
|
+
throw new Error("Ratio denominator cannot be zero.");
|
|
109
|
+
}
|
|
110
|
+
if (!Number.isInteger(numerator) || !Number.isInteger(denominator)) {
|
|
111
|
+
return new RatioImpl(numerator, denominator);
|
|
112
|
+
}
|
|
113
|
+
if (denominator < 0) {
|
|
114
|
+
numerator = -numerator;
|
|
115
|
+
denominator = Math.abs(denominator);
|
|
116
|
+
}
|
|
117
|
+
const gcd = (a, b) => {
|
|
118
|
+
let x = Math.abs(a);
|
|
119
|
+
let y = Math.abs(b);
|
|
120
|
+
while (y !== 0) {
|
|
121
|
+
const next = x % y;
|
|
122
|
+
x = y;
|
|
123
|
+
y = next;
|
|
124
|
+
}
|
|
125
|
+
return x === 0 ? 1 : x;
|
|
126
|
+
};
|
|
127
|
+
const divisor = gcd(numerator, denominator);
|
|
128
|
+
return new RatioImpl(numerator / divisor, denominator / divisor);
|
|
129
|
+
};
|
|
130
|
+
exports.normalizeRatio = normalizeRatio;
|
|
131
|
+
const reduceRatio = (ratio) => (0, exports.normalizeRatio)(ratio);
|
|
132
|
+
exports.reduceRatio = reduceRatio;
|
|
133
|
+
const simplifyRatio = (ratio) => {
|
|
134
|
+
const reduced = (0, exports.normalizeRatio)(ratio);
|
|
135
|
+
return new RatioImpl(reduced.numerator(), reduced.denominator(), {
|
|
136
|
+
omitDenominatorWhenOne: true,
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
exports.simplifyRatio = simplifyRatio;
|
|
140
|
+
const ratioToFloat = (ratio) => ratio.numerator() / ratio.denominator();
|
|
141
|
+
exports.ratioToFloat = ratioToFloat;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNIT_DEFINITIONS = void 0;
|
|
4
|
+
exports.UNIT_DEFINITIONS = {
|
|
5
|
+
mPercent: { unit: '%', category: 'percent' },
|
|
6
|
+
mPx: { unit: 'px', category: 'length-absolute' },
|
|
7
|
+
mCm: { unit: 'cm', category: 'length-absolute' },
|
|
8
|
+
mMm: { unit: 'mm', category: 'length-absolute' },
|
|
9
|
+
mQ: { unit: 'q', category: 'length-absolute' },
|
|
10
|
+
mIn: { unit: 'in', category: 'length-absolute' },
|
|
11
|
+
mPc: { unit: 'pc', category: 'length-absolute' },
|
|
12
|
+
mPt: { unit: 'pt', category: 'length-absolute' },
|
|
13
|
+
mEm: { unit: 'em', category: 'length-font-relative' },
|
|
14
|
+
mRem: { unit: 'rem', category: 'length-font-relative' },
|
|
15
|
+
mEx: { unit: 'ex', category: 'length-font-relative' },
|
|
16
|
+
mRex: { unit: 'rex', category: 'length-font-relative' },
|
|
17
|
+
mCh: { unit: 'ch', category: 'length-font-relative' },
|
|
18
|
+
mRch: { unit: 'rch', category: 'length-font-relative' },
|
|
19
|
+
mCap: { unit: 'cap', category: 'length-font-relative' },
|
|
20
|
+
mRcap: { unit: 'rcap', category: 'length-font-relative' },
|
|
21
|
+
mIc: { unit: 'ic', category: 'length-font-relative' },
|
|
22
|
+
mRic: { unit: 'ric', category: 'length-font-relative' },
|
|
23
|
+
mLh: { unit: 'lh', category: 'length-font-relative' },
|
|
24
|
+
mRlh: { unit: 'rlh', category: 'length-font-relative' },
|
|
25
|
+
mVw: { unit: 'vw', category: 'length-viewport' },
|
|
26
|
+
mVh: { unit: 'vh', category: 'length-viewport' },
|
|
27
|
+
mVi: { unit: 'vi', category: 'length-viewport' },
|
|
28
|
+
mVb: { unit: 'vb', category: 'length-viewport' },
|
|
29
|
+
mVmin: { unit: 'vmin', category: 'length-viewport' },
|
|
30
|
+
mVmax: { unit: 'vmax', category: 'length-viewport' },
|
|
31
|
+
mSvw: { unit: 'svw', category: 'length-viewport-small' },
|
|
32
|
+
mSvh: { unit: 'svh', category: 'length-viewport-small' },
|
|
33
|
+
mSvi: { unit: 'svi', category: 'length-viewport-small' },
|
|
34
|
+
mSvb: { unit: 'svb', category: 'length-viewport-small' },
|
|
35
|
+
mSvmin: { unit: 'svmin', category: 'length-viewport-small' },
|
|
36
|
+
mSvmax: { unit: 'svmax', category: 'length-viewport-small' },
|
|
37
|
+
mLvw: { unit: 'lvw', category: 'length-viewport-large' },
|
|
38
|
+
mLvh: { unit: 'lvh', category: 'length-viewport-large' },
|
|
39
|
+
mLvi: { unit: 'lvi', category: 'length-viewport-large' },
|
|
40
|
+
mLvb: { unit: 'lvb', category: 'length-viewport-large' },
|
|
41
|
+
mLvmin: { unit: 'lvmin', category: 'length-viewport-large' },
|
|
42
|
+
mLvmax: { unit: 'lvmax', category: 'length-viewport-large' },
|
|
43
|
+
mDvw: { unit: 'dvw', category: 'length-viewport-dynamic' },
|
|
44
|
+
mDvh: { unit: 'dvh', category: 'length-viewport-dynamic' },
|
|
45
|
+
mDvi: { unit: 'dvi', category: 'length-viewport-dynamic' },
|
|
46
|
+
mDvb: { unit: 'dvb', category: 'length-viewport-dynamic' },
|
|
47
|
+
mDvmin: { unit: 'dvmin', category: 'length-viewport-dynamic' },
|
|
48
|
+
mDvmax: { unit: 'dvmax', category: 'length-viewport-dynamic' },
|
|
49
|
+
mCqw: { unit: 'cqw', category: 'length-container' },
|
|
50
|
+
mCqh: { unit: 'cqh', category: 'length-container' },
|
|
51
|
+
mCqi: { unit: 'cqi', category: 'length-container' },
|
|
52
|
+
mCqb: { unit: 'cqb', category: 'length-container' },
|
|
53
|
+
mCqmin: { unit: 'cqmin', category: 'length-container' },
|
|
54
|
+
mCqmax: { unit: 'cqmax', category: 'length-container' },
|
|
55
|
+
mDeg: { unit: 'deg', category: 'angle' },
|
|
56
|
+
mRad: { unit: 'rad', category: 'angle' },
|
|
57
|
+
mGrad: { unit: 'grad', category: 'angle' },
|
|
58
|
+
mTurn: { unit: 'turn', category: 'angle' },
|
|
59
|
+
mS: { unit: 's', category: 'time' },
|
|
60
|
+
mMs: { unit: 'ms', category: 'time' },
|
|
61
|
+
mHz: { unit: 'hz', category: 'frequency' },
|
|
62
|
+
mKhz: { unit: 'khz', category: 'frequency' },
|
|
63
|
+
mDpi: { unit: 'dpi', category: 'resolution' },
|
|
64
|
+
mDpcm: { unit: 'dpcm', category: 'resolution' },
|
|
65
|
+
mDppx: { unit: 'dppx', category: 'resolution' },
|
|
66
|
+
mFr: { unit: 'fr', category: 'flex' },
|
|
67
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mPt = exports.mPc = exports.mIn = exports.mQ = exports.mMm = exports.mCm = exports.mPx = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mPx = (0, core_1.makeUnitHelperFromDefinition)('mPx');
|
|
6
|
+
exports.mCm = (0, core_1.makeUnitHelperFromDefinition)('mCm');
|
|
7
|
+
exports.mMm = (0, core_1.makeUnitHelperFromDefinition)('mMm');
|
|
8
|
+
exports.mQ = (0, core_1.makeUnitHelperFromDefinition)('mQ');
|
|
9
|
+
exports.mIn = (0, core_1.makeUnitHelperFromDefinition)('mIn');
|
|
10
|
+
exports.mPc = (0, core_1.makeUnitHelperFromDefinition)('mPc');
|
|
11
|
+
exports.mPt = (0, core_1.makeUnitHelperFromDefinition)('mPt');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mTurn = exports.mGrad = exports.mRad = exports.mDeg = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mDeg = (0, core_1.makeUnitHelperFromDefinition)('mDeg');
|
|
6
|
+
exports.mRad = (0, core_1.makeUnitHelperFromDefinition)('mRad');
|
|
7
|
+
exports.mGrad = (0, core_1.makeUnitHelperFromDefinition)('mGrad');
|
|
8
|
+
exports.mTurn = (0, core_1.makeUnitHelperFromDefinition)('mTurn');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mCqmax = exports.mCqmin = exports.mCqb = exports.mCqi = exports.mCqh = exports.mCqw = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mCqw = (0, core_1.makeUnitHelperFromDefinition)('mCqw');
|
|
6
|
+
exports.mCqh = (0, core_1.makeUnitHelperFromDefinition)('mCqh');
|
|
7
|
+
exports.mCqi = (0, core_1.makeUnitHelperFromDefinition)('mCqi');
|
|
8
|
+
exports.mCqb = (0, core_1.makeUnitHelperFromDefinition)('mCqb');
|
|
9
|
+
exports.mCqmin = (0, core_1.makeUnitHelperFromDefinition)('mCqmin');
|
|
10
|
+
exports.mCqmax = (0, core_1.makeUnitHelperFromDefinition)('mCqmax');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mRlh = exports.mLh = exports.mRic = exports.mIc = exports.mRcap = exports.mCap = exports.mRch = exports.mCh = exports.mRex = exports.mEx = exports.mRem = exports.mEm = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mEm = (0, core_1.makeUnitHelperFromDefinition)('mEm');
|
|
6
|
+
exports.mRem = (0, core_1.makeUnitHelperFromDefinition)('mRem');
|
|
7
|
+
exports.mEx = (0, core_1.makeUnitHelperFromDefinition)('mEx');
|
|
8
|
+
exports.mRex = (0, core_1.makeUnitHelperFromDefinition)('mRex');
|
|
9
|
+
exports.mCh = (0, core_1.makeUnitHelperFromDefinition)('mCh');
|
|
10
|
+
exports.mRch = (0, core_1.makeUnitHelperFromDefinition)('mRch');
|
|
11
|
+
exports.mCap = (0, core_1.makeUnitHelperFromDefinition)('mCap');
|
|
12
|
+
exports.mRcap = (0, core_1.makeUnitHelperFromDefinition)('mRcap');
|
|
13
|
+
exports.mIc = (0, core_1.makeUnitHelperFromDefinition)('mIc');
|
|
14
|
+
exports.mRic = (0, core_1.makeUnitHelperFromDefinition)('mRic');
|
|
15
|
+
exports.mLh = (0, core_1.makeUnitHelperFromDefinition)('mLh');
|
|
16
|
+
exports.mRlh = (0, core_1.makeUnitHelperFromDefinition)('mRlh');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mKhz = exports.mHz = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mHz = (0, core_1.makeUnitHelperFromDefinition)('mHz');
|
|
6
|
+
exports.mKhz = (0, core_1.makeUnitHelperFromDefinition)('mKhz');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertPercentMeasurement = exports.isPercentMeasurement = exports.mPercent = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mPercent = (0, core_1.makeUnitHelperFromDefinition)('mPercent');
|
|
6
|
+
exports.isPercentMeasurement = (0, core_1.makeUnitGuard)(exports.mPercent);
|
|
7
|
+
exports.assertPercentMeasurement = (0, core_1.makeUnitAssert)(exports.mPercent);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mDppx = exports.mDpcm = exports.mDpi = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mDpi = (0, core_1.makeUnitHelperFromDefinition)('mDpi');
|
|
6
|
+
exports.mDpcm = (0, core_1.makeUnitHelperFromDefinition)('mDpcm');
|
|
7
|
+
exports.mDppx = (0, core_1.makeUnitHelperFromDefinition)('mDppx');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mMs = exports.mS = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
exports.mS = (0, core_1.makeUnitHelperFromDefinition)('mS');
|
|
6
|
+
exports.mMs = (0, core_1.makeUnitHelperFromDefinition)('mMs');
|