app-studio 0.2.8 → 0.2.11
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/dist/appstudio.cjs.development.js +38 -26
- package/dist/appstudio.cjs.development.js.map +1 -1
- package/dist/appstudio.cjs.production.min.js +1 -1
- package/dist/appstudio.cjs.production.min.js.map +1 -1
- package/dist/appstudio.esm.js +38 -26
- package/dist/appstudio.esm.js.map +1 -1
- package/dist/appstudio.umd.development.js +38 -26
- package/dist/appstudio.umd.development.js.map +1 -1
- package/dist/appstudio.umd.production.min.js +1 -1
- package/dist/appstudio.umd.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -722,16 +722,45 @@ const styleSheet = /*#__PURE__*/(() => {
|
|
|
722
722
|
}
|
|
723
723
|
return null;
|
|
724
724
|
})();
|
|
725
|
+
/**
|
|
726
|
+
* Fonction de hachage simple et rapide basée sur l'algorithme djb2.
|
|
727
|
+
* @param {string} str - La chaîne de caractères à hacher.
|
|
728
|
+
* @returns {number} - Le hachage sous forme d'entier non signé 32 bits.
|
|
729
|
+
*/
|
|
730
|
+
const hashString = str => {
|
|
731
|
+
let hash = 5381;
|
|
732
|
+
for (let i = 0; i < str.length; i++) {
|
|
733
|
+
// hash * 33 + c
|
|
734
|
+
hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
735
|
+
// Pour éviter les dépassements, on utilise l'opérateur >>> 0
|
|
736
|
+
hash = hash >>> 0;
|
|
737
|
+
}
|
|
738
|
+
return hash;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Fonction pour hacher un objet en utilisant JSON.stringify et hashString.
|
|
742
|
+
* @param {Object} obj - L'objet à hacher.
|
|
743
|
+
* @returns {number} - Le hachage de l'objet.
|
|
744
|
+
*/
|
|
745
|
+
const hashObject = obj => {
|
|
746
|
+
const str = JSON.stringify(obj);
|
|
747
|
+
return hashString(str).toString();
|
|
748
|
+
};
|
|
725
749
|
const classCache = /*#__PURE__*/new Map();
|
|
726
750
|
const cssRulesCache = /*#__PURE__*/new Map();
|
|
727
751
|
let classNameCounter = 0;
|
|
728
752
|
const generateClassName = styleProps => {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
753
|
+
// Extract only relevant, primitive style properties
|
|
754
|
+
console.log({
|
|
755
|
+
styleProps
|
|
756
|
+
});
|
|
757
|
+
// Generate a unique hash based on relevantProps
|
|
758
|
+
const hash = hashObject(styleProps);
|
|
759
|
+
if (classCache.has(hash)) {
|
|
760
|
+
return classCache.get(hash);
|
|
732
761
|
} else {
|
|
733
762
|
const className = 'clz-' + classNameCounter++;
|
|
734
|
-
classCache.set(
|
|
763
|
+
classCache.set(hash, className);
|
|
735
764
|
return className;
|
|
736
765
|
}
|
|
737
766
|
};
|
|
@@ -810,7 +839,7 @@ const generateCssRules = (selector, styles, getColor, mediaQueries) => {
|
|
|
810
839
|
return rules;
|
|
811
840
|
};
|
|
812
841
|
// Function to apply styles to a component
|
|
813
|
-
const computeStyleProps =
|
|
842
|
+
const computeStyleProps = props => {
|
|
814
843
|
const styleProps = {};
|
|
815
844
|
const keyframesList = [];
|
|
816
845
|
// Gestion de la taille de l'élément
|
|
@@ -869,22 +898,8 @@ const computeStyleProps = (props, getColor, mediaQueries, devices) => {
|
|
|
869
898
|
}
|
|
870
899
|
Object.keys(props).forEach(property => {
|
|
871
900
|
if (property !== 'style' && (isStyleProp(property) || extraKeys.has(property))) {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
// For other nested styles, exclude 'on' and 'media'
|
|
875
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
876
|
-
const {
|
|
877
|
-
on,
|
|
878
|
-
media,
|
|
879
|
-
...nestedProps
|
|
880
|
-
} = value;
|
|
881
|
-
const nestedResult = computeStyleProps(nestedProps);
|
|
882
|
-
styleProps[property] = nestedResult.styleProps;
|
|
883
|
-
keyframesList.push(...(nestedResult.keyframes || []));
|
|
884
|
-
} else {
|
|
885
|
-
// Simple style property
|
|
886
|
-
styleProps[property] = value;
|
|
887
|
-
}
|
|
901
|
+
// Simple style property
|
|
902
|
+
styleProps[property] = props[property];
|
|
888
903
|
}
|
|
889
904
|
});
|
|
890
905
|
return {
|
|
@@ -893,7 +908,7 @@ const computeStyleProps = (props, getColor, mediaQueries, devices) => {
|
|
|
893
908
|
};
|
|
894
909
|
};
|
|
895
910
|
// Function to apply styles to a component
|
|
896
|
-
const applyStyle = function (props,
|
|
911
|
+
const applyStyle = function (props, mediaQueries, devices, depth,
|
|
897
912
|
// Add a depth parameter
|
|
898
913
|
maxDepth // Set a maximum depth
|
|
899
914
|
) {
|
|
@@ -1023,9 +1038,6 @@ maxDepth // Set a maximum depth
|
|
|
1023
1038
|
}
|
|
1024
1039
|
}
|
|
1025
1040
|
});
|
|
1026
|
-
console.log({
|
|
1027
|
-
styleProps
|
|
1028
|
-
});
|
|
1029
1041
|
return {
|
|
1030
1042
|
styleProps,
|
|
1031
1043
|
keyframes: keyframesList
|
|
@@ -1035,7 +1047,7 @@ const getStyledProps = (props, getColor, mediaQueries, devices) => {
|
|
|
1035
1047
|
const {
|
|
1036
1048
|
styleProps,
|
|
1037
1049
|
keyframes
|
|
1038
|
-
} = applyStyle(props,
|
|
1050
|
+
} = applyStyle(props, mediaQueries, devices);
|
|
1039
1051
|
const className = generateClassName(styleProps);
|
|
1040
1052
|
let cssRules = [];
|
|
1041
1053
|
if (cssRulesCache.has(className)) {
|