expo-image-theme-colors 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/build/ExpoImageThemeColors.types.d.ts +25 -0
- package/build/ExpoImageThemeColors.types.d.ts.map +1 -0
- package/build/ExpoImageThemeColors.types.js +2 -0
- package/build/ExpoImageThemeColors.types.js.map +1 -0
- package/build/ExpoImageThemeColorsModule.d.ts +9 -0
- package/build/ExpoImageThemeColorsModule.d.ts.map +1 -0
- package/build/ExpoImageThemeColorsModule.js +3 -0
- package/build/ExpoImageThemeColorsModule.js.map +1 -0
- package/build/ImageRef.d.ts +17 -0
- package/build/ImageRef.d.ts.map +1 -0
- package/build/ImageRef.js +3 -0
- package/build/ImageRef.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +6 -0
- package/package.json +58 -0
- package/src/ExpoImageThemeColors.types.ts +36 -0
- package/src/ExpoImageThemeColorsModule.ts +9 -0
- package/src/ImageRef.ts +20 -0
- package/src/index.ts +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 代表一个 swatch 的所有信息
|
|
3
|
+
*/
|
|
4
|
+
export interface ColorInfo {
|
|
5
|
+
/** 颜色的 6 位 Hex 值 (e.g., "#FF0000") */
|
|
6
|
+
hex: string;
|
|
7
|
+
/** 推荐的标题文本颜色 (e.g., "#FFFFFF") */
|
|
8
|
+
titleTextColor: string;
|
|
9
|
+
/** 推荐的正文文本颜色 (e.g., "#000000") */
|
|
10
|
+
bodyTextColor: string;
|
|
11
|
+
/** 这个颜色在图片中占了多少像素点 */
|
|
12
|
+
population: number;
|
|
13
|
+
}
|
|
14
|
+
type SwatchName = 'dominant' | 'vibrant' | 'lightVibrant' | 'darkVibrant' | 'muted' | 'lightMuted' | 'darkMuted';
|
|
15
|
+
type PaletteSwatches = {
|
|
16
|
+
[K in SwatchName]: ColorInfo | null;
|
|
17
|
+
};
|
|
18
|
+
export type ExtractedPalette = {
|
|
19
|
+
/** 图片宽度 (px) */
|
|
20
|
+
width: number;
|
|
21
|
+
/** 图片高度 (px) */
|
|
22
|
+
height: number;
|
|
23
|
+
} & PaletteSwatches;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=ExpoImageThemeColors.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoImageThemeColors.types.d.ts","sourceRoot":"","sources":["../src/ExpoImageThemeColors.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IAEZ,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC;IAEvB,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAC;IAEtB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,UAAU,GACX,UAAU,GACV,SAAS,GACT,cAAc,GACd,aAAa,GACb,OAAO,GACP,YAAY,GACZ,WAAW,CAAC;AAEhB,KAAK,eAAe,GAAG;KACpB,CAAC,IAAI,UAAU,GAAG,SAAS,GAAG,IAAI;CACpC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoImageThemeColors.types.js","sourceRoot":"","sources":["../src/ExpoImageThemeColors.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * 代表一个 swatch 的所有信息\n */\nexport interface ColorInfo {\n /** 颜色的 6 位 Hex 值 (e.g., \"#FF0000\") */\n hex: string;\n \n /** 推荐的标题文本颜色 (e.g., \"#FFFFFF\") */\n titleTextColor: string;\n \n /** 推荐的正文文本颜色 (e.g., \"#000000\") */\n bodyTextColor: string;\n \n /** 这个颜色在图片中占了多少像素点 */\n population: number;\n}\n\ntype SwatchName = \n | 'dominant'\n | 'vibrant'\n | 'lightVibrant'\n | 'darkVibrant'\n | 'muted'\n | 'lightMuted'\n | 'darkMuted';\n\ntype PaletteSwatches = {\n [K in SwatchName]: ColorInfo | null;\n};\n\nexport type ExtractedPalette = {\n /** 图片宽度 (px) */\n width: number;\n /** 图片高度 (px) */\n height: number;\n} & PaletteSwatches;"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NativeModule, SharedRef } from 'expo';
|
|
2
|
+
import { ExtractedPalette } from './ExpoImageThemeColors.types';
|
|
3
|
+
import { ImageRef } from './ImageRef';
|
|
4
|
+
declare class ExpoImageThemeColorsModule extends NativeModule {
|
|
5
|
+
extractThemeColorAsync(source: string | SharedRef<'image'> | ImageRef): Promise<ExtractedPalette>;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: ExpoImageThemeColorsModule;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=ExpoImageThemeColorsModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoImageThemeColorsModule.d.ts","sourceRoot":"","sources":["../src/ExpoImageThemeColorsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,SAAS,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,OAAO,0BAA2B,SAAQ,YAAY;IAC3D,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAClG;;AAED,wBAAuF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoImageThemeColorsModule.js","sourceRoot":"","sources":["../src/ExpoImageThemeColorsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAa,MAAM,MAAM,CAAC;AAQpE,eAAe,mBAAmB,CAA6B,sBAAsB,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule, SharedRef } from 'expo';\nimport { ExtractedPalette } from './ExpoImageThemeColors.types';\nimport { ImageRef } from './ImageRef';\n\ndeclare class ExpoImageThemeColorsModule extends NativeModule {\n extractThemeColorAsync(source: string | SharedRef<'image'> | ImageRef): Promise<ExtractedPalette>;\n}\n\nexport default requireNativeModule<ExpoImageThemeColorsModule>('ExpoImageThemeColors');\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SharedRef } from 'expo';
|
|
2
|
+
/**
|
|
3
|
+
* A reference to a native instance of the image.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ImageRef extends SharedRef<'image'> {
|
|
6
|
+
/**
|
|
7
|
+
* Width of the image.
|
|
8
|
+
*/
|
|
9
|
+
width: number;
|
|
10
|
+
/**
|
|
11
|
+
* Height of the image.
|
|
12
|
+
*/
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: typeof ImageRef;
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=ImageRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageRef.d.ts","sourceRoot":"","sources":["../src/ImageRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAIjC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS,CAAC,OAAO,CAAC;IACtD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;wBAE+C,OAAO,QAAQ;AAA/D,wBAAgE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageRef.js","sourceRoot":"","sources":["../src/ImageRef.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAiBhE,eAAe,oBAAoB,CAAC,QAA2B,CAAC","sourcesContent":["import { SharedRef } from 'expo';\n\nimport ExpoImageThemeColors from './ExpoImageThemeColorsModule';\n\n/**\n * A reference to a native instance of the image.\n */\nexport declare class ImageRef extends SharedRef<'image'> {\n /**\n * Width of the image.\n */\n width: number;\n\n /**\n * Height of the image.\n */\n height: number;\n}\n\nexport default ExpoImageThemeColors.ImageRef as typeof ImageRef;"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,cAAc,8BAA8B,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,cAAc,8BAA8B,CAAC","sourcesContent":["export { default } from './ExpoImageThemeColorsModule';\nexport * from './ExpoImageThemeColors.types';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-image-theme-colors",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A module to extract theme colors using expo ImageRef",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "expo-module build",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"test": "expo-module test",
|
|
12
|
+
"prepare": "expo-module prepare",
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
|
+
"expo-module": "expo-module",
|
|
15
|
+
"open:ios": "xed example/ios",
|
|
16
|
+
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"expo-image-theme-colors",
|
|
22
|
+
"ExpoImageThemeColors",
|
|
23
|
+
"theme-extraction",
|
|
24
|
+
"color-palette"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/bbplayer-app/expo-image-theme-colors.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/bbplayer-app/expo-image-theme-colors/issues"
|
|
32
|
+
},
|
|
33
|
+
"author": "Roitium <65794453+roitium@users.noreply.github.com> (https://github.com/roitium)",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"homepage": "https://github.com/bbplayer-app/expo-image-theme-colors#readme",
|
|
36
|
+
"dependencies": {},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "~19.1.0",
|
|
39
|
+
"expo-module-scripts": "^5.0.7",
|
|
40
|
+
"expo": "^54.0.18",
|
|
41
|
+
"react-native": "0.81.5"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"expo": "*",
|
|
45
|
+
"react": "*",
|
|
46
|
+
"react-native": "*"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"build",
|
|
50
|
+
"src",
|
|
51
|
+
"expo-module.config.json"
|
|
52
|
+
],
|
|
53
|
+
"sideEffects": false,
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 代表一个 swatch 的所有信息
|
|
3
|
+
*/
|
|
4
|
+
export interface ColorInfo {
|
|
5
|
+
/** 颜色的 6 位 Hex 值 (e.g., "#FF0000") */
|
|
6
|
+
hex: string;
|
|
7
|
+
|
|
8
|
+
/** 推荐的标题文本颜色 (e.g., "#FFFFFF") */
|
|
9
|
+
titleTextColor: string;
|
|
10
|
+
|
|
11
|
+
/** 推荐的正文文本颜色 (e.g., "#000000") */
|
|
12
|
+
bodyTextColor: string;
|
|
13
|
+
|
|
14
|
+
/** 这个颜色在图片中占了多少像素点 */
|
|
15
|
+
population: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type SwatchName =
|
|
19
|
+
| 'dominant'
|
|
20
|
+
| 'vibrant'
|
|
21
|
+
| 'lightVibrant'
|
|
22
|
+
| 'darkVibrant'
|
|
23
|
+
| 'muted'
|
|
24
|
+
| 'lightMuted'
|
|
25
|
+
| 'darkMuted';
|
|
26
|
+
|
|
27
|
+
type PaletteSwatches = {
|
|
28
|
+
[K in SwatchName]: ColorInfo | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ExtractedPalette = {
|
|
32
|
+
/** 图片宽度 (px) */
|
|
33
|
+
width: number;
|
|
34
|
+
/** 图片高度 (px) */
|
|
35
|
+
height: number;
|
|
36
|
+
} & PaletteSwatches;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NativeModule, requireNativeModule, SharedRef } from 'expo';
|
|
2
|
+
import { ExtractedPalette } from './ExpoImageThemeColors.types';
|
|
3
|
+
import { ImageRef } from './ImageRef';
|
|
4
|
+
|
|
5
|
+
declare class ExpoImageThemeColorsModule extends NativeModule {
|
|
6
|
+
extractThemeColorAsync(source: string | SharedRef<'image'> | ImageRef): Promise<ExtractedPalette>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default requireNativeModule<ExpoImageThemeColorsModule>('ExpoImageThemeColors');
|
package/src/ImageRef.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SharedRef } from 'expo';
|
|
2
|
+
|
|
3
|
+
import ExpoImageThemeColors from './ExpoImageThemeColorsModule';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A reference to a native instance of the image.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ImageRef extends SharedRef<'image'> {
|
|
9
|
+
/**
|
|
10
|
+
* Width of the image.
|
|
11
|
+
*/
|
|
12
|
+
width: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Height of the image.
|
|
16
|
+
*/
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default ExpoImageThemeColors.ImageRef as typeof ImageRef;
|
package/src/index.ts
ADDED