@hanzogui/create-theme 8.3.0 → 8.3.2

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.
Files changed (140) hide show
  1. package/dist/cjs/applyMask.js +48 -0
  2. package/dist/cjs/applyMask.js.map +1 -0
  3. package/dist/cjs/combineMasks.js +26 -0
  4. package/dist/cjs/combineMasks.js.map +1 -0
  5. package/dist/cjs/createTheme.js +73 -0
  6. package/dist/cjs/createTheme.js.map +1 -0
  7. package/dist/cjs/createThemeTypes.js +3 -0
  8. package/dist/cjs/createThemeTypes.js.map +1 -0
  9. package/dist/cjs/helpers.js +14 -0
  10. package/dist/cjs/helpers.js.map +1 -0
  11. package/dist/cjs/index.js +10 -0
  12. package/dist/cjs/index.js.map +1 -0
  13. package/dist/cjs/isMinusZero.js +7 -0
  14. package/dist/cjs/isMinusZero.js.map +1 -0
  15. package/dist/cjs/masks.js +114 -0
  16. package/dist/cjs/masks.js.map +1 -0
  17. package/dist/cjs/package.json +1 -0
  18. package/dist/cjs/tests.js +33 -0
  19. package/dist/cjs/tests.js.map +1 -0
  20. package/dist/cjs/themeInfo.js +18 -0
  21. package/dist/cjs/themeInfo.js.map +1 -0
  22. package/dist/esm/applyMask.js +44 -0
  23. package/dist/esm/applyMask.js.map +1 -0
  24. package/dist/esm/combineMasks.js +22 -0
  25. package/dist/esm/combineMasks.js.map +1 -0
  26. package/dist/esm/createTheme.js +68 -0
  27. package/dist/esm/createTheme.js.map +1 -0
  28. package/dist/esm/createThemeTypes.js +2 -0
  29. package/dist/esm/createThemeTypes.js.map +1 -0
  30. package/dist/esm/helpers.js +8 -0
  31. package/dist/esm/helpers.js.map +1 -0
  32. package/dist/esm/index.js +7 -7
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/isMinusZero.js +4 -0
  35. package/dist/esm/isMinusZero.js.map +1 -0
  36. package/dist/esm/masks.js +105 -0
  37. package/dist/esm/masks.js.map +1 -0
  38. package/dist/esm/tests.js +31 -0
  39. package/dist/esm/tests.js.map +1 -0
  40. package/dist/esm/themeInfo.js +13 -0
  41. package/dist/esm/themeInfo.js.map +1 -0
  42. package/package.json +12 -12
  43. package/src/applyMask.tsx +9 -4
  44. package/src/combineMasks.tsx +3 -3
  45. package/src/createTheme.tsx +3 -3
  46. package/src/helpers.tsx +10 -3
  47. package/src/index.tsx +6 -6
  48. package/src/masks.tsx +3 -3
  49. package/src/tests.tsx +3 -3
  50. package/src/themeInfo.tsx +1 -1
  51. package/types/applyMask.d.ts +3 -4
  52. package/types/applyMask.d.ts.map +1 -11
  53. package/types/combineMasks.d.ts +1 -2
  54. package/types/combineMasks.d.ts.map +1 -11
  55. package/types/createTheme.d.ts +15 -25
  56. package/types/createTheme.d.ts.map +1 -11
  57. package/types/createThemeTypes.d.ts +31 -32
  58. package/types/createThemeTypes.d.ts.map +1 -11
  59. package/types/helpers.d.ts +15 -9
  60. package/types/helpers.d.ts.map +1 -11
  61. package/types/index.d.ts +6 -7
  62. package/types/index.d.ts.map +1 -11
  63. package/types/isMinusZero.d.ts +0 -1
  64. package/types/isMinusZero.d.ts.map +1 -11
  65. package/types/masks.d.ts +2 -3
  66. package/types/masks.d.ts.map +1 -11
  67. package/types/tests.d.ts +0 -1
  68. package/types/tests.d.ts.map +1 -11
  69. package/types/themeInfo.d.ts +7 -8
  70. package/types/themeInfo.d.ts.map +1 -11
  71. package/dist/cjs/applyMask.cjs +0 -67
  72. package/dist/cjs/applyMask.native.js +0 -76
  73. package/dist/cjs/applyMask.native.js.map +0 -1
  74. package/dist/cjs/combineMasks.cjs +0 -48
  75. package/dist/cjs/combineMasks.native.js +0 -73
  76. package/dist/cjs/combineMasks.native.js.map +0 -1
  77. package/dist/cjs/createTheme.cjs +0 -105
  78. package/dist/cjs/createTheme.native.js +0 -111
  79. package/dist/cjs/createTheme.native.js.map +0 -1
  80. package/dist/cjs/createThemeTypes.cjs +0 -18
  81. package/dist/cjs/createThemeTypes.native.js +0 -21
  82. package/dist/cjs/createThemeTypes.native.js.map +0 -1
  83. package/dist/cjs/helpers.cjs +0 -36
  84. package/dist/cjs/helpers.native.js +0 -41
  85. package/dist/cjs/helpers.native.js.map +0 -1
  86. package/dist/cjs/index.cjs +0 -25
  87. package/dist/cjs/index.native.js +0 -28
  88. package/dist/cjs/index.native.js.map +0 -1
  89. package/dist/cjs/isMinusZero.cjs +0 -30
  90. package/dist/cjs/isMinusZero.native.js +0 -33
  91. package/dist/cjs/isMinusZero.native.js.map +0 -1
  92. package/dist/cjs/masks.cjs +0 -146
  93. package/dist/cjs/masks.native.js +0 -192
  94. package/dist/cjs/masks.native.js.map +0 -1
  95. package/dist/cjs/tests.cjs +0 -26
  96. package/dist/cjs/tests.native.js +0 -29
  97. package/dist/cjs/tests.native.js.map +0 -1
  98. package/dist/cjs/themeInfo.cjs +0 -40
  99. package/dist/cjs/themeInfo.native.js +0 -43
  100. package/dist/cjs/themeInfo.native.js.map +0 -1
  101. package/dist/esm/applyMask.mjs +0 -41
  102. package/dist/esm/applyMask.mjs.map +0 -1
  103. package/dist/esm/applyMask.native.js +0 -47
  104. package/dist/esm/applyMask.native.js.map +0 -1
  105. package/dist/esm/combineMasks.mjs +0 -23
  106. package/dist/esm/combineMasks.mjs.map +0 -1
  107. package/dist/esm/combineMasks.native.js +0 -45
  108. package/dist/esm/combineMasks.native.js.map +0 -1
  109. package/dist/esm/createTheme.mjs +0 -78
  110. package/dist/esm/createTheme.mjs.map +0 -1
  111. package/dist/esm/createTheme.native.js +0 -81
  112. package/dist/esm/createTheme.native.js.map +0 -1
  113. package/dist/esm/createThemeTypes.mjs +0 -2
  114. package/dist/esm/createThemeTypes.mjs.map +0 -1
  115. package/dist/esm/createThemeTypes.native.js +0 -2
  116. package/dist/esm/createThemeTypes.native.js.map +0 -1
  117. package/dist/esm/helpers.mjs +0 -9
  118. package/dist/esm/helpers.mjs.map +0 -1
  119. package/dist/esm/helpers.native.js +0 -11
  120. package/dist/esm/helpers.native.js.map +0 -1
  121. package/dist/esm/index.mjs +0 -7
  122. package/dist/esm/index.mjs.map +0 -1
  123. package/dist/esm/index.native.js +0 -7
  124. package/dist/esm/index.native.js.map +0 -1
  125. package/dist/esm/isMinusZero.mjs +0 -5
  126. package/dist/esm/isMinusZero.mjs.map +0 -1
  127. package/dist/esm/isMinusZero.native.js +0 -5
  128. package/dist/esm/isMinusZero.native.js.map +0 -1
  129. package/dist/esm/masks.mjs +0 -114
  130. package/dist/esm/masks.mjs.map +0 -1
  131. package/dist/esm/masks.native.js +0 -157
  132. package/dist/esm/masks.native.js.map +0 -1
  133. package/dist/esm/tests.mjs +0 -27
  134. package/dist/esm/tests.mjs.map +0 -1
  135. package/dist/esm/tests.native.js +0 -27
  136. package/dist/esm/tests.native.js.map +0 -1
  137. package/dist/esm/themeInfo.mjs +0 -14
  138. package/dist/esm/themeInfo.mjs.map +0 -1
  139. package/dist/esm/themeInfo.native.js +0 -14
  140. package/dist/esm/themeInfo.native.js.map +0 -1
@@ -1,11 +1 @@
1
- {
2
- "mappings": "KAAK,aAAa,OAAO;KAEpB;CAAY;CAAO;IACtB,KAAK,UAAU,WAAW,SAAQ,MAAM,WAAW,UAAU,kBAAkB;KAE5E,cAAc,YACd,WAAW,gBAAe,YAAY,OAAO,MAAM,KAAK,MAAM,YAAY;AAE/E,OAAO,cAAM,aAAc,kBAAkB,KAAK,MAA0B,YAAY;AAExF,OAAO,iBAAS,cAAc,cAAc,YAC1C,KAAK,QACJ,cAAc;KAIZ,eACA,0BACD,wBAAwB;KAGvB,aAAa,sBAAsB,WAAW,SAAQ,aAAa,MAAM;KACzE,oBAAoB,YACtB,uBAAuB,GAAG,mCAAmC,SAAS,aACnE;KAID,4BAA4B,cAAc,eAC7C,aAAa,sBAAsB,OAC/B,iBAAiB,WAAW,UACvB,QAAQ,MAAM,eAAc;KAGlC,yBAAyB,WAAW,aAAa,QAAO,KAAK;KAC7D,gBAAgB,cAAc,eAAe,yBAChD,oBAAoB,4BAA4B;AAGlD,OAAO,iBAAS,kBAAkB,cAAc,aAC9C,KAAK,QACJ,gBAAgB",
3
- "names": [],
4
- "sources": [
5
- "src/helpers.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "type ObjectType = Record<PropertyKey, unknown>\n\ntype PickByValue<OBJ_T, VALUE_T> = // From https://stackoverflow.com/a/55153000\n Pick<OBJ_T, { [K in keyof OBJ_T]: OBJ_T[K] extends VALUE_T ? K : never }[keyof OBJ_T]>\n\ntype ObjectEntries<OBJ_T> = // From https://stackoverflow.com/a/60142095\n { [K in keyof OBJ_T]: [keyof PickByValue<OBJ_T, OBJ_T[K]>, OBJ_T[K]] }[keyof OBJ_T][]\n\nexport const objectKeys = <O extends object>(obj: O) => Object.keys(obj) as Array<keyof O>\n\nexport function objectEntries<OBJ_T extends ObjectType>(\n obj: OBJ_T\n): ObjectEntries<OBJ_T> {\n return Object.entries(obj) as ObjectEntries<OBJ_T>\n}\n\ntype EntriesType =\n | [PropertyKey, unknown][]\n | ReadonlyArray<readonly [PropertyKey, unknown]>\n\n// Existing Utils\ntype DeepWritable<OBJ_T> = { -readonly [P in keyof OBJ_T]: DeepWritable<OBJ_T[P]> }\ntype UnionToIntersection<UNION_T> = // From https://stackoverflow.com/a/50375286\n (UNION_T extends any ? (k: UNION_T) => void : never) extends (k: infer I) => void\n ? I\n : never\n\n// New Utils\ntype UnionObjectFromArrayOfPairs<ARR_T extends EntriesType> =\n DeepWritable<ARR_T> extends (infer R)[]\n ? R extends [infer key, infer val]\n ? { [prop in key & PropertyKey]: val }\n : never\n : never\ntype MergeIntersectingObjects<ObjT> = { [key in keyof ObjT]: ObjT[key] }\ntype EntriesToObject<ARR_T extends EntriesType> = MergeIntersectingObjects<\n UnionToIntersection<UnionObjectFromArrayOfPairs<ARR_T>>\n>\n\nexport function objectFromEntries<ARR_T extends EntriesType>(\n arr: ARR_T\n): EntriesToObject<ARR_T> {\n return Object.fromEntries(arr) as EntriesToObject<ARR_T>\n}\n"
10
- ]
11
- }
1
+ {"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AAGX,KAAK,2BAA2B,CAAC,KAAK,SAAS,WAAW,IACxD,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnC,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC,GAC9B;KAAG,IAAI,IAAI,GAAG,GAAG,WAAW,GAAG,GAAG;CAAE,GACpC,KAAK,GACP,KAAK,CAAA;AACX,KAAK,wBAAwB,CAAC,IAAI,IAAI;KAAG,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;CAAE,CAAA;AACxE,KAAK,eAAe,CAAC,KAAK,SAAS,WAAW,IAAI,wBAAwB,CACxE,mBAAmB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CACxD,CAAA;AAED,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,WAAW,EACzD,GAAG,EAAE,KAAK,GACT,eAAe,CAAC,KAAK,CAAC,CAExB"}
package/types/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- export * from "./createTheme";
2
- export * from "./masks";
3
- export * from "./combineMasks";
4
- export * from "./applyMask";
5
- export * from "./createThemeTypes";
6
- export * from "./helpers";
7
-
1
+ export * from './createTheme.tsx';
2
+ export * from './masks.tsx';
3
+ export * from './combineMasks.tsx';
4
+ export * from './applyMask.tsx';
5
+ export * from './createThemeTypes.tsx';
6
+ export * from './helpers.tsx';
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc",
3
- "names": [],
4
- "sources": [
5
- "src/index.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "export * from './createTheme'\nexport * from './masks'\nexport * from './combineMasks'\nexport * from './applyMask'\nexport * from './createThemeTypes'\nexport * from './helpers'\n"
10
- ]
11
- }
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA"}
@@ -1,3 +1,2 @@
1
1
  export declare function isMinusZero(value: number): boolean;
2
-
3
2
  //# sourceMappingURL=isMinusZero.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AAAA,OAAO,iBAAS,YAAY",
3
- "names": [],
4
- "sources": [
5
- "src/isMinusZero.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "export function isMinusZero(value: number): boolean {\n return 1 / value === Number.NEGATIVE_INFINITY\n}\n"
10
- ]
11
- }
1
+ {"version":3,"file":"isMinusZero.d.ts","sourceRoot":"","sources":["../src/isMinusZero.tsx"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD"}
package/types/masks.d.ts CHANGED
@@ -1,15 +1,14 @@
1
- import type { CreateMask, MaskFunction, MaskOptions } from "./createThemeTypes";
1
+ import type { CreateMask, MaskFunction, MaskOptions } from './createThemeTypes.tsx';
2
2
  export declare const createMask: <C extends CreateMask | MaskFunction>(createMask: C) => CreateMask;
3
3
  export declare const skipMask: CreateMask;
4
4
  export declare const createIdentityMask: () => CreateMask;
5
5
  export declare const createInverseMask: () => CreateMask;
6
6
  type ShiftMaskOptions = {
7
- inverse?: boolean;
7
+ inverse?: boolean;
8
8
  };
9
9
  export declare const createShiftMask: ({ inverse }?: ShiftMaskOptions, defaultOptions?: MaskOptions) => CreateMask;
10
10
  export declare const createWeakenMask: (defaultOptions?: MaskOptions) => CreateMask;
11
11
  export declare const createSoftenMask: (defaultOptions?: MaskOptions) => CreateMask;
12
12
  export declare const createStrengthenMask: (defaultOptions?: MaskOptions) => CreateMask;
13
13
  export {};
14
-
15
14
  //# sourceMappingURL=masks.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AAAA,cAAc,YAAY,cAAc,mBAAmB;AAI3D,OAAO,cAAM,aAAc,UAAU,aAAa,cAChD,YAAY,MACX;AAKH,OAAO,cAAM,UAAU;AA8CvB,OAAO,cAAM,0BAAyB;AAKtC,OAAO,cAAM,yBAAwB;KAahC,mBAAmB;CAAE;;AAE1B,OAAO,cAAM,kBACX,EAAE,YAAW,kBACb,iBAAiB,gBAChB;AA6CH,OAAO,cAAM,mBAAoB,iBAAiB,gBAAc;AAKhE,OAAO,cAAM,mBAAmB,iBAAiB,gBAAgB;AAGjE,OAAO,cAAM,uBAAwB,iBAAiB,gBAAc",
3
- "names": [],
4
- "sources": [
5
- "src/masks.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "import type { CreateMask, MaskFunction, MaskOptions } from './createThemeTypes'\nimport { objectEntries, objectFromEntries } from './helpers'\nimport { isMinusZero } from './isMinusZero'\n\nexport const createMask = <C extends CreateMask | MaskFunction>(\n createMask: C\n): CreateMask =>\n typeof createMask === 'function'\n ? { name: createMask.name || 'unnamed', mask: createMask }\n : createMask\n\nexport const skipMask: CreateMask = {\n name: 'skip-mask',\n mask: (template, opts) => {\n const { skip } = opts\n const result = Object.fromEntries(\n Object.entries(template)\n .filter(([k]) => !skip || !(k in skip))\n .map(([k, v]) => [k, applyOverrides(k, v, opts)])\n ) as typeof template\n\n return result\n },\n}\n\nfunction applyOverrides(key: string, value: number | string, opts: MaskOptions) {\n let override: string | number | undefined\n let strategy = opts.overrideStrategy\n\n const overrideSwap = opts.overrideSwap?.[key]\n if (typeof overrideSwap !== 'undefined') {\n override = overrideSwap\n strategy = 'swap'\n } else {\n const overrideShift = opts.overrideShift?.[key]\n if (typeof overrideShift !== 'undefined') {\n override = overrideShift\n strategy = 'shift'\n } else {\n const overrideDefault = opts.override?.[key]\n if (typeof overrideDefault !== 'undefined') {\n override = overrideDefault\n strategy = opts.overrideStrategy\n }\n }\n }\n\n if (typeof override === 'undefined') return value\n if (typeof override === 'string') return value\n\n if (strategy === 'swap') {\n return override\n }\n\n return value\n}\n\nexport const createIdentityMask = (): CreateMask => ({\n name: 'identity-mask',\n mask: (template, opts) => skipMask.mask(template, opts),\n})\n\nexport const createInverseMask = (): CreateMask => {\n const mask: CreateMask = {\n name: 'inverse-mask',\n mask: (template, opts) => {\n const inversed = objectFromEntries(\n objectEntries(template).map(([k, v]) => [k, -v])\n ) as any\n return skipMask.mask(inversed, opts)\n },\n }\n return mask\n}\n\ntype ShiftMaskOptions = { inverse?: boolean }\n\nexport const createShiftMask = (\n { inverse }: ShiftMaskOptions = {},\n defaultOptions?: MaskOptions\n): CreateMask => {\n const mask: CreateMask = {\n name: 'shift-mask',\n mask: (template, opts) => {\n const {\n override,\n overrideStrategy = 'shift',\n max: maxIn,\n palette,\n min = 0,\n strength = 1,\n } = { ...defaultOptions, ...opts }\n const values = Object.entries(template)\n const max =\n maxIn ?? (palette ? Object.values(palette).length - 1 : Number.POSITIVE_INFINITY)\n const out = {}\n for (const [key, value] of values) {\n if (typeof value === 'string') continue\n if (typeof override?.[key] === 'number') {\n const overrideVal = override[key] as number\n out[key] = overrideStrategy === 'shift' ? value + overrideVal : overrideVal\n continue\n }\n if (typeof override?.[key] === 'string') {\n out[key] = override[key]\n continue\n }\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const direction = isPositive ? 1 : -1\n const invert = inverse ? -1 : 1\n const next = value + strength * direction * invert\n const clamped = isPositive\n ? Math.max(min, Math.min(max, next))\n : Math.min(-min, Math.max(-max, next))\n\n out[key] = clamped\n }\n\n const skipped = skipMask.mask(out, opts) as typeof template\n return skipped\n },\n }\n return mask\n}\n\nexport const createWeakenMask = (defaultOptions?: MaskOptions): CreateMask => ({\n name: 'soften-mask',\n mask: createShiftMask({}, defaultOptions).mask,\n})\n\nexport const createSoftenMask: (defaultOptions?: MaskOptions) => CreateMask =\n createWeakenMask\n\nexport const createStrengthenMask = (defaultOptions?: MaskOptions): CreateMask => ({\n name: 'strengthen-mask',\n mask: createShiftMask({ inverse: true }, defaultOptions).mask,\n})\n"
10
- ]
11
- }
1
+ {"version":3,"file":"masks.d.ts","sourceRoot":"","sources":["../src/masks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAInF,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,UAAU,GAAG,YAAY,cAChD,CAAC,KACZ,UAGa,CAAA;AAEhB,eAAO,MAAM,QAAQ,EAAE,UAYtB,CAAA;AAkCD,eAAO,MAAM,kBAAkB,QAAO,UAGpC,CAAA;AAEF,eAAO,MAAM,iBAAiB,QAAO,UAWpC,CAAA;AAED,KAAK,gBAAgB,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE7C,eAAO,MAAM,eAAe,iBACb,gBAAgB,mBACZ,WAAW,KAC3B,UA2CF,CAAA;AAED,eAAO,MAAM,gBAAgB,oBAAqB,WAAW,KAAG,UAG9D,CAAA;AAEF,eAAO,MAAM,gBAAgB,EAAE,CAAC,cAAc,CAAC,EAAE,WAAW,KAAK,UAC/C,CAAA;AAElB,eAAO,MAAM,oBAAoB,oBAAqB,WAAW,KAAG,UAGlE,CAAA"}
package/types/tests.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export {};
2
-
3
2
  //# sourceMappingURL=tests.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "",
3
- "names": [],
4
- "sources": [
5
- "src/tests.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "import { applyMask } from './applyMask'\nimport { createTheme } from './createTheme'\nimport { createStrengthenMask, createWeakenMask } from './masks'\n\n// --- tests ---\nif (process.env.NODE_ENV === 'development') {\n const palette = ['0', '1', '2', '3', '-3', '-2', '-1', '-0']\n const template = { bg: 1, fg: -1 }\n\n const stongerMask = createStrengthenMask()\n const weakerMask = createWeakenMask()\n\n const theme = createTheme(palette, template)\n if (theme.bg !== '1') throw `❌`\n if (theme.fg !== '-1') throw `❌`\n\n const str = applyMask(theme, stongerMask)\n if (str.bg !== '0') throw `❌`\n if (str.fg !== '-0') throw `❌`\n\n const weak = applyMask(theme, weakerMask)\n if (weak.bg !== '2') throw `❌`\n if (weak.fg !== '-2') throw `❌`\n\n const weak2 = applyMask(theme, weakerMask, { strength: 2 })\n if (weak2.bg !== '3') throw `❌`\n if (weak2.fg !== '-3') throw `❌`\n}\n"
10
- ]
11
- }
1
+ {"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../src/tests.tsx"],"names":[],"mappings":""}
@@ -1,13 +1,12 @@
1
- import type { CreateThemeOptions, CreateThemePalette, GenericTheme, ThemeMask } from "./createThemeTypes";
1
+ import type { CreateThemeOptions, CreateThemePalette, GenericTheme, ThemeMask } from './createThemeTypes.tsx';
2
2
  export type ThemeInfo = {
3
- palette: CreateThemePalette;
4
- definition: ThemeMask;
5
- options?: CreateThemeOptions;
6
- cache: Map<any, any>;
3
+ palette: CreateThemePalette;
4
+ definition: ThemeMask;
5
+ options?: CreateThemeOptions;
6
+ cache: Map<any, any>;
7
7
  };
8
8
  export declare const getThemeInfo: (theme: GenericTheme | ThemeMask, name?: string) => ThemeInfo | undefined;
9
- export declare const setThemeInfo: (theme: GenericTheme | ThemeMask, info: Pick<ThemeInfo, "palette" | "definition" | "options"> & {
10
- name?: string;
9
+ export declare const setThemeInfo: (theme: GenericTheme | ThemeMask, info: Pick<ThemeInfo, 'palette' | 'definition' | 'options'> & {
10
+ name?: string;
11
11
  }) => void;
12
-
13
12
  //# sourceMappingURL=themeInfo.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AAAA,cACE,oBACA,oBACA,cACA,iBACK;AAEP,YAAY,YAAY;CACtB,SAAS;CACT,YAAY;CACZ,UAAU;CACV,OAAO;;AAKT,OAAO,cAAM,eACX,OAAO,eAAe,WACtB,kBACC;AAIH,OAAO,cAAM,eACX,OAAO,eAAe,WACtB,MAAM,KAAK,WAAW,YAAY,eAAe,aAAa;CAC5D",
3
- "names": [],
4
- "sources": [
5
- "src/themeInfo.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "import type {\n CreateThemeOptions,\n CreateThemePalette,\n GenericTheme,\n ThemeMask,\n} from './createThemeTypes'\n\nexport type ThemeInfo = {\n palette: CreateThemePalette\n definition: ThemeMask\n options?: CreateThemeOptions\n cache: Map<any, any>\n}\n\nconst THEME_INFO = new Map<string, ThemeInfo>()\n\nexport const getThemeInfo = (\n theme: GenericTheme | ThemeMask,\n name?: string\n): ThemeInfo | undefined => {\n return THEME_INFO.get(name || JSON.stringify(theme))\n}\n\nexport const setThemeInfo = (\n theme: GenericTheme | ThemeMask,\n info: Pick<ThemeInfo, 'palette' | 'definition' | 'options'> & {\n name?: string\n }\n): void => {\n const next = {\n ...info,\n cache: new Map(),\n }\n THEME_INFO.set(info.name || JSON.stringify(theme), next)\n THEME_INFO.set(JSON.stringify(info.definition), next)\n}\n"
10
- ]
11
- }
1
+ {"version":3,"file":"themeInfo.d.ts","sourceRoot":"","sources":["../src/themeInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACV,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,kBAAkB,CAAA;IAC3B,UAAU,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,kBAAkB,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CACrB,CAAA;AAID,eAAO,MAAM,YAAY,UAChB,YAAY,GAAG,SAAS,SACxB,MAAM,KACZ,SAAS,GAAG,SAEd,CAAA;AAED,eAAO,MAAM,YAAY,UAChB,YAAY,GAAG,SAAS,QACzB,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC,GAAG;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,KACA,IAOF,CAAA"}
@@ -1,67 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var applyMask_exports = {};
24
- __export(applyMask_exports, {
25
- applyMask: () => applyMask,
26
- applyMaskStateless: () => applyMaskStateless
27
- });
28
- module.exports = __toCommonJS(applyMask_exports);
29
- var import_createTheme = require("./createTheme.cjs");
30
- var import_themeInfo = require("./themeInfo.cjs");
31
- function applyMask(theme, mask, options = {}, parentName, nextName) {
32
- const info = (0, import_themeInfo.getThemeInfo)(theme, parentName);
33
- if (!info) {
34
- throw new Error(process.env.NODE_ENV !== "production" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\u274C Err2`);
35
- }
36
- const next = applyMaskStateless(info, mask, options, parentName);
37
- (0, import_themeInfo.setThemeInfo)(next.theme, {
38
- definition: next.definition,
39
- palette: info.palette,
40
- name: nextName
41
- });
42
- return next.theme;
43
- }
44
- function applyMaskStateless(info, mask, options = {}, parentName) {
45
- const skip = {
46
- ...options.skip
47
- };
48
- if (info.options?.nonInheritedValues) {
49
- for (const key in info.options.nonInheritedValues) {
50
- skip[key] = 1;
51
- }
52
- }
53
- const maskOptions = {
54
- parentName,
55
- palette: info.palette,
56
- ...options,
57
- skip
58
- };
59
- const template = mask.mask(info.definition, maskOptions);
60
- const theme = (0, import_createTheme.createTheme)(info.palette, template);
61
- return {
62
- ...info,
63
- cache: /* @__PURE__ */new Map(),
64
- definition: template,
65
- theme
66
- };
67
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
25
- var applyMask_exports = {};
26
- __export(applyMask_exports, {
27
- applyMask: () => applyMask,
28
- applyMaskStateless: () => applyMaskStateless
29
- });
30
- module.exports = __toCommonJS(applyMask_exports);
31
- var import_createTheme = require("./createTheme.native.js");
32
- var import_themeInfo = require("./themeInfo.native.js");
33
- function applyMask(theme, mask) {
34
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {},
35
- parentName = arguments.length > 3 ? arguments[3] : void 0,
36
- nextName = arguments.length > 4 ? arguments[4] : void 0;
37
- var info = (0, import_themeInfo.getThemeInfo)(theme, parentName);
38
- if (!info) {
39
- throw new Error(process.env.NODE_ENV !== "production" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\u274C Err2`);
40
- }
41
- var next = applyMaskStateless(info, mask, options, parentName);
42
- (0, import_themeInfo.setThemeInfo)(next.theme, {
43
- definition: next.definition,
44
- palette: info.palette,
45
- name: nextName
46
- });
47
- return next.theme;
48
- }
49
- function applyMaskStateless(info, mask) {
50
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {},
51
- parentName = arguments.length > 3 ? arguments[3] : void 0;
52
- var _info_options;
53
- var skip = {
54
- ...options.skip
55
- };
56
- if ((_info_options = info.options) === null || _info_options === void 0 ? void 0 : _info_options.nonInheritedValues) {
57
- for (var key in info.options.nonInheritedValues) {
58
- skip[key] = 1;
59
- }
60
- }
61
- var maskOptions = {
62
- parentName,
63
- palette: info.palette,
64
- ...options,
65
- skip
66
- };
67
- var template = mask.mask(info.definition, maskOptions);
68
- var theme = (0, import_createTheme.createTheme)(info.palette, template);
69
- return {
70
- ...info,
71
- cache: /* @__PURE__ */new Map(),
72
- definition: template,
73
- theme
74
- };
75
- }
76
- //# sourceMappingURL=applyMask.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","applyMask_exports","applyMask","applyMaskStateless","module","exports","import_createTheme","require","import_themeInfo","theme","mask","options","arguments","length","parentName","nextName","info","getThemeInfo","Error","process","env","NODE_ENV","next","setThemeInfo","definition","palette","_info_options","skip","nonInheritedValues","maskOptions","template","createTheme","cache","Map"],"sources":["applyMask.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar applyMask_exports = {};\n__export(applyMask_exports, {\n applyMask: () => applyMask,\n applyMaskStateless: () => applyMaskStateless\n});\nmodule.exports = __toCommonJS(applyMask_exports);\nvar import_createTheme = require(\"./createTheme\");\nvar import_themeInfo = require(\"./themeInfo\");\nfunction applyMask(theme, mask) {\n var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, parentName = arguments.length > 3 ? arguments[3] : void 0, nextName = arguments.length > 4 ? arguments[4] : void 0;\n var info = (0, import_themeInfo.getThemeInfo)(theme, parentName);\n if (!info) {\n throw new Error(process.env.NODE_ENV !== \"production\" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\\u274C Err2`);\n }\n var next = applyMaskStateless(info, mask, options, parentName);\n (0, import_themeInfo.setThemeInfo)(next.theme, {\n definition: next.definition,\n palette: info.palette,\n name: nextName\n });\n return next.theme;\n}\nfunction applyMaskStateless(info, mask) {\n var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, parentName = arguments.length > 3 ? arguments[3] : void 0;\n var _info_options;\n var skip = {\n ...options.skip\n };\n if ((_info_options = info.options) === null || _info_options === void 0 ? void 0 : _info_options.nonInheritedValues) {\n for (var key in info.options.nonInheritedValues) {\n skip[key] = 1;\n }\n }\n var maskOptions = {\n parentName,\n palette: info.palette,\n ...options,\n skip\n };\n var template = mask.mask(info.definition, maskOptions);\n var theme = (0, import_createTheme.createTheme)(info.palette, template);\n return {\n ...info,\n cache: /* @__PURE__ */ new Map(),\n definition: template,\n theme\n };\n}\n//# sourceMappingURL=applyMask.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc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A,CAACa,IAAI,EAAEN,IAAI,EAAE;EACtC,IAAIC,OAAO,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAGA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAAEE,UAAU,GAAGF,SAAS,CAACC,MAAM,GAAG,CAAC,GAAGD,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;EAC5I,IAAIc,aAAa;EACjB,IAAIC,IAAI,GAAG;IACT,GAAGhB,OAAO,CAACgB;EACb,CAAC;EACD,IAAI,CAACD,aAAa,GAAGV,IAAI,CAACL,OAAO,MAAM,IAAI,IAAIe,aAAa,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,aAAa,CAACE,kBAAkB,EAAE;IACnH,KAAK,IAAIhC,GAAG,IAAIoB,IAAI,CAACL,OAAO,CAACiB,kBAAkB,EAAE;MAC/CD,IAAI,CAAC/B,GAAG,CAAC,GAAG,CAAC;IACf;EACF;EACA,IAAIiC,WAAW,GAAG;IAChBf,UAAU;IACVW,OAAO,EAAET,IAAI,CAACS,OAAO;IACrB,GAAGd,OAAO;IACVgB;EACF,CAAC;EACD,IAAIG,QAAQ,GAAGpB,IAAI,CAACA,IAAI,CAACM,IAAI,CAACQ,UAAU,EAAEK,WAAW,CAAC;EACtD,IAAIpB,KAAK,GAAG,CAAC,CAAC,EAAEH,kBAAkB,CAACyB,WAAW,EAAEf,IAAI,CAACS,OAAO,EAAEK,QAAQ,CAAC;EACvE,OAAO;IACL,GAAGd,IAAI;IACPgB,KAAK,EAAE,eAAgB,IAAIC,GAAG,CAAC,CAAC;IAChCT,UAAU,EAAEM,QAAQ;IACpBrB;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,48 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var combineMasks_exports = {};
24
- __export(combineMasks_exports, {
25
- combineMasks: () => combineMasks
26
- });
27
- module.exports = __toCommonJS(combineMasks_exports);
28
- var import_applyMask = require("./applyMask.cjs");
29
- var import_themeInfo = require("./themeInfo.cjs");
30
- const combineMasks = (...masks) => {
31
- const mask = {
32
- name: "combine-mask",
33
- mask: (template, opts) => {
34
- let current = (0, import_themeInfo.getThemeInfo)(template, opts.parentName);
35
- let theme;
36
- for (const mask2 of masks) {
37
- if (!current) {
38
- throw new Error(`Nothing returned from mask: ${current}, for template: ${template} and mask: ${mask2.toString()}, given opts ${JSON.stringify(opts, null, 2)}`);
39
- }
40
- const next = (0, import_applyMask.applyMaskStateless)(current, mask2, opts);
41
- current = next;
42
- theme = next.theme;
43
- }
44
- return theme;
45
- }
46
- };
47
- return mask;
48
- };
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
25
- var combineMasks_exports = {};
26
- __export(combineMasks_exports, {
27
- combineMasks: () => combineMasks
28
- });
29
- module.exports = __toCommonJS(combineMasks_exports);
30
- var import_applyMask = require("./applyMask.native.js");
31
- var import_themeInfo = require("./themeInfo.native.js");
32
- var combineMasks = function () {
33
- for (var _len = arguments.length, masks = new Array(_len), _key = 0; _key < _len; _key++) {
34
- masks[_key] = arguments[_key];
35
- }
36
- var mask = {
37
- name: "combine-mask",
38
- mask: function (template, opts) {
39
- var current = (0, import_themeInfo.getThemeInfo)(template, opts.parentName);
40
- var theme;
41
- var _iteratorNormalCompletion = true,
42
- _didIteratorError = false,
43
- _iteratorError = void 0;
44
- try {
45
- for (var _iterator = masks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
46
- var mask2 = _step.value;
47
- if (!current) {
48
- throw new Error(`Nothing returned from mask: ${current}, for template: ${template} and mask: ${mask2.toString()}, given opts ${JSON.stringify(opts, null, 2)}`);
49
- }
50
- var next = (0, import_applyMask.applyMaskStateless)(current, mask2, opts);
51
- current = next;
52
- theme = next.theme;
53
- }
54
- } catch (err) {
55
- _didIteratorError = true;
56
- _iteratorError = err;
57
- } finally {
58
- try {
59
- if (!_iteratorNormalCompletion && _iterator.return != null) {
60
- _iterator.return();
61
- }
62
- } finally {
63
- if (_didIteratorError) {
64
- throw _iteratorError;
65
- }
66
- }
67
- }
68
- return theme;
69
- }
70
- };
71
- return mask;
72
- };
73
- //# sourceMappingURL=combineMasks.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","combineMasks_exports","combineMasks","module","exports","import_applyMask","require","import_themeInfo","_len","arguments","length","masks","Array","_key","mask","template","opts","current","getThemeInfo","parentName","theme","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","mask2","Error","toString","JSON","stringify","applyMaskStateless","err","return"],"sources":["combineMasks.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar combineMasks_exports = {};\n__export(combineMasks_exports, {\n combineMasks: () => combineMasks\n});\nmodule.exports = __toCommonJS(combineMasks_exports);\nvar import_applyMask = require(\"./applyMask\");\nvar import_themeInfo = require(\"./themeInfo\");\nvar combineMasks = function() {\n for (var _len = arguments.length, masks = new Array(_len), _key = 0; _key < _len; _key++) {\n masks[_key] = arguments[_key];\n }\n var mask = {\n name: \"combine-mask\",\n mask: function(template, opts) {\n var current = (0, import_themeInfo.getThemeInfo)(template, opts.parentName);\n var theme;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = masks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var mask2 = _step.value;\n if (!current) {\n throw new Error(`Nothing returned from mask: ${current}, for template: ${template} and mask: ${mask2.toString()}, given opts ${JSON.stringify(opts, null, 2)}`);\n }\n var next = (0, import_applyMask.applyMaskStateless)(current, mask2, opts);\n current = next;\n theme = next.theme;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return theme;\n }\n };\n return mask;\n};\n//# sourceMappingURL=combineMasks.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;IAClE,KAAK,IAAIG,GAAG,IAAIhB,iBAAiB,CAACa,IAAI,CAAC,EACrC,IAAI,CAACX,YAAY,CAACe,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,EAC/CnB,SAAS,CAACiB,EAAE,EAAEI,GAAG,EAAE;MAAEP,GAAG,EAAEA,CAAA,KAAM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;QAAEC,cAAc,GAAG,KAAK,CAAC;MACxF,IAAI;QACF,KAAK,IAAIC,SAAS,GAAGb,KAAK,CAACc,MAAM,CAACC,QAAQ,CAAC,CAAC,CAAC,EAAEC,KAAK,EAAE,EAAEN,yBAAyB,GAAG,CAACM,KAAK,GAAGH,SAAS,CAACI,IAAI,CAAC,CAAC,EAAEC,IAAI,CAAC,EAAER,yBAAyB,GAAG,IAAI,EAAE;UACtJ,IAAIS,KAAK,GAAGH,KAAK,CAAC3B,KAAK;UACvB,IAAI,CAACiB,OAAO,EAAE;YACZ,MAAM,IAAIc,KAAK,CAAC,+BAA+Bd,OAAO,mBAAmBF,QAAQ,cAAce,KAAK,CAACE,QAAQ,CAAC,CAAC,gBAAgBC,IAAI,CAACC,SAAS,CAAClB,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;UACjK;UACA,IAAIY,IAAI,GAAG,CAAC,CAAC,EAAEvB,gBAAgB,CAAC8B,kBAAkB,EAAElB,OAAO,EAAEa,KAAK,EAAEd,IAAI,CAAC;UACzEC,OAAO,GAAGW,IAAI;UACdR,KAAK,GAAGQ,IAAI,CAACR,KAAK;QACpB;MACF,CAAC,CAAC,OAAOgB,GAAG,EAAE;QACZd,iBAAiB,GAAG,IAAI;QACxBC,cAAc,GAAGa,GAAG;MACtB,CAAC,SAAS;QACR,IAAI;UACF,IAAI,CAACf,yBAAyB,IAAIG,SAAS,CAACa,MAAM,IAAI,IAAI,EAAE;YAC1Db,SAAS,CAACa,MAAM,CAAC,CAAC;UACpB;QACF,CAAC,SAAS;UACR,IAAIf,iBAAiB,EAAE;YACrB,MAAMC,cAAc;UACtB;QACF;MACF;MACA,OAAOH,KAAK;IACd;EACF,CAAC;EACD,OAAON,IAAI;AACb,CAAC","ignoreList":[]}
@@ -1,105 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var createTheme_exports = {};
24
- __export(createTheme_exports, {
25
- addChildren: () => addChildren,
26
- createTheme: () => createTheme,
27
- createThemeWithPalettes: () => createThemeWithPalettes
28
- });
29
- module.exports = __toCommonJS(createTheme_exports);
30
- var import_isMinusZero = require("./isMinusZero.cjs");
31
- var import_themeInfo = require("./themeInfo.cjs");
32
- const identityCache = /* @__PURE__ */new Map();
33
- function createThemeWithPalettes(palettes, defaultPalette, definition, options, name, skipCache = false) {
34
- if (!palettes[defaultPalette]) {
35
- throw new Error(`No palette: ${defaultPalette}`);
36
- }
37
- const newDef = {
38
- ...definition
39
- };
40
- for (const key in definition) {
41
- let val = definition[key];
42
- if (typeof val === "string" && val[0] === "$") {
43
- const [altPaletteName$, altPaletteIndex] = val.split(".");
44
- const altPaletteName = altPaletteName$.slice(1);
45
- const parentName = defaultPalette.split("_")[0];
46
- const altPalette = palettes[altPaletteName] || palettes[`${parentName}_${altPaletteName}`];
47
- if (altPalette) {
48
- const next = getValue(altPalette, +altPaletteIndex);
49
- if (typeof next !== "undefined") {
50
- newDef[key] = next;
51
- }
52
- }
53
- }
54
- }
55
- return createTheme(palettes[defaultPalette], newDef, options, name, skipCache);
56
- }
57
- function createTheme(palette, definition, options, name, skipCache = false) {
58
- const cacheKey = skipCache ? "" : JSON.stringify([name, palette, definition, options]);
59
- if (!skipCache) {
60
- if (identityCache.has(cacheKey)) {
61
- return identityCache.get(cacheKey);
62
- }
63
- }
64
- const theme = {
65
- ...Object.fromEntries(Object.entries(definition).map(([key, offset]) => {
66
- return [key, getValue(palette, offset)];
67
- })),
68
- ...options?.nonInheritedValues
69
- };
70
- (0, import_themeInfo.setThemeInfo)(theme, {
71
- palette,
72
- definition,
73
- options,
74
- name
75
- });
76
- if (cacheKey) {
77
- identityCache.set(cacheKey, theme);
78
- }
79
- return theme;
80
- }
81
- const getValue = (palette, value) => {
82
- if (!palette) {
83
- throw new Error(`No palette!`);
84
- }
85
- if (typeof value === "string") {
86
- return value;
87
- }
88
- const max = palette.length - 1;
89
- const isPositive = value === 0 ? !(0, import_isMinusZero.isMinusZero)(value) : value >= 0;
90
- const next = isPositive ? value : max + value;
91
- const index = Math.min(Math.max(0, next), max);
92
- return palette[index];
93
- };
94
- function addChildren(themes, getChildren) {
95
- const out = {
96
- ...themes
97
- };
98
- for (const key in themes) {
99
- const subThemes = getChildren(key, themes[key]);
100
- for (const sKey in subThemes) {
101
- out[`${key}_${sKey}`] = subThemes[sKey];
102
- }
103
- }
104
- return out;
105
- }