@pandacss/shared 0.0.0-dev-20240212114108 → 0.0.0-dev-20240212185235
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/index.d.mts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +17 -3
- package/dist/index.mjs +17 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -110,18 +110,21 @@ type MapToRecord<K extends Map<string, any>> = {
|
|
|
110
110
|
declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
|
|
111
111
|
|
|
112
112
|
type CallbackFn = (args: CallbackItem) => void;
|
|
113
|
-
|
|
113
|
+
interface CallbackItem {
|
|
114
114
|
value: any;
|
|
115
115
|
path: string;
|
|
116
|
+
paths: string[];
|
|
116
117
|
depth: number;
|
|
117
118
|
parent: any[] | Record<string, unknown>;
|
|
118
119
|
key: string;
|
|
119
|
-
}
|
|
120
|
+
}
|
|
120
121
|
declare const isObjectOrArray: (obj: unknown) => boolean;
|
|
121
|
-
|
|
122
|
-
separator
|
|
122
|
+
interface TraverseOptions {
|
|
123
|
+
separator?: string;
|
|
123
124
|
maxDepth?: number;
|
|
124
|
-
|
|
125
|
+
stop?: (args: CallbackItem) => boolean;
|
|
126
|
+
}
|
|
127
|
+
declare function traverse(obj: any, callback: CallbackFn, options?: TraverseOptions): void;
|
|
125
128
|
|
|
126
129
|
declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
|
|
127
130
|
|
package/dist/index.d.ts
CHANGED
|
@@ -110,18 +110,21 @@ type MapToRecord<K extends Map<string, any>> = {
|
|
|
110
110
|
declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
|
|
111
111
|
|
|
112
112
|
type CallbackFn = (args: CallbackItem) => void;
|
|
113
|
-
|
|
113
|
+
interface CallbackItem {
|
|
114
114
|
value: any;
|
|
115
115
|
path: string;
|
|
116
|
+
paths: string[];
|
|
116
117
|
depth: number;
|
|
117
118
|
parent: any[] | Record<string, unknown>;
|
|
118
119
|
key: string;
|
|
119
|
-
}
|
|
120
|
+
}
|
|
120
121
|
declare const isObjectOrArray: (obj: unknown) => boolean;
|
|
121
|
-
|
|
122
|
-
separator
|
|
122
|
+
interface TraverseOptions {
|
|
123
|
+
separator?: string;
|
|
123
124
|
maxDepth?: number;
|
|
124
|
-
|
|
125
|
+
stop?: (args: CallbackItem) => boolean;
|
|
126
|
+
}
|
|
127
|
+
declare function traverse(obj: any, callback: CallbackFn, options?: TraverseOptions): void;
|
|
125
128
|
|
|
126
129
|
declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
|
|
127
130
|
|
package/dist/index.js
CHANGED
|
@@ -847,23 +847,37 @@ function mapToJson(map) {
|
|
|
847
847
|
|
|
848
848
|
// src/traverse.ts
|
|
849
849
|
var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
|
|
850
|
-
var defaultOptions = {
|
|
850
|
+
var defaultOptions = {
|
|
851
|
+
separator: ".",
|
|
852
|
+
maxDepth: Infinity
|
|
853
|
+
};
|
|
851
854
|
function traverse(obj, callback2, options = defaultOptions) {
|
|
852
855
|
const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
|
|
853
856
|
const separator = options.separator ?? defaultOptions.separator;
|
|
854
|
-
const stack = [{ value: obj, path: "", depth: -1, parent: null, key: "" }];
|
|
857
|
+
const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
|
|
855
858
|
while (stack.length > 0) {
|
|
856
859
|
const currentItem = stack.pop();
|
|
857
860
|
if (currentItem.parent !== null) {
|
|
858
861
|
callback2(currentItem);
|
|
859
862
|
}
|
|
863
|
+
if (options.stop?.(currentItem)) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
860
866
|
if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
|
|
861
867
|
const keys = Object.keys(currentItem.value);
|
|
862
868
|
for (let i = keys.length - 1; i >= 0; i--) {
|
|
863
869
|
const key = keys[i];
|
|
864
870
|
const value = currentItem.value[key];
|
|
865
871
|
const path = currentItem.path ? currentItem.path + separator + key : key;
|
|
866
|
-
|
|
872
|
+
const paths = currentItem.paths.concat(key);
|
|
873
|
+
stack.push({
|
|
874
|
+
value,
|
|
875
|
+
path,
|
|
876
|
+
paths,
|
|
877
|
+
depth: currentItem.depth + 1,
|
|
878
|
+
parent: currentItem.value,
|
|
879
|
+
key
|
|
880
|
+
});
|
|
867
881
|
}
|
|
868
882
|
}
|
|
869
883
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -760,23 +760,37 @@ function mapToJson(map) {
|
|
|
760
760
|
|
|
761
761
|
// src/traverse.ts
|
|
762
762
|
var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
|
|
763
|
-
var defaultOptions = {
|
|
763
|
+
var defaultOptions = {
|
|
764
|
+
separator: ".",
|
|
765
|
+
maxDepth: Infinity
|
|
766
|
+
};
|
|
764
767
|
function traverse(obj, callback2, options = defaultOptions) {
|
|
765
768
|
const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
|
|
766
769
|
const separator = options.separator ?? defaultOptions.separator;
|
|
767
|
-
const stack = [{ value: obj, path: "", depth: -1, parent: null, key: "" }];
|
|
770
|
+
const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
|
|
768
771
|
while (stack.length > 0) {
|
|
769
772
|
const currentItem = stack.pop();
|
|
770
773
|
if (currentItem.parent !== null) {
|
|
771
774
|
callback2(currentItem);
|
|
772
775
|
}
|
|
776
|
+
if (options.stop?.(currentItem)) {
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
773
779
|
if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
|
|
774
780
|
const keys = Object.keys(currentItem.value);
|
|
775
781
|
for (let i = keys.length - 1; i >= 0; i--) {
|
|
776
782
|
const key = keys[i];
|
|
777
783
|
const value = currentItem.value[key];
|
|
778
784
|
const path = currentItem.path ? currentItem.path + separator + key : key;
|
|
779
|
-
|
|
785
|
+
const paths = currentItem.paths.concat(key);
|
|
786
|
+
stack.push({
|
|
787
|
+
value,
|
|
788
|
+
path,
|
|
789
|
+
paths,
|
|
790
|
+
depth: currentItem.depth + 1,
|
|
791
|
+
parent: currentItem.value,
|
|
792
|
+
key
|
|
793
|
+
});
|
|
780
794
|
}
|
|
781
795
|
}
|
|
782
796
|
}
|