react-native-store-version 1.4.2 → 2.0.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/CHANGELOG.md +28 -0
- package/README.md +514 -43
- package/dist/checkVersion.d.ts +73 -0
- package/dist/checkVersion.d.ts.map +1 -0
- package/dist/checkVersion.js +193 -0
- package/dist/cli/check.js +38 -0
- package/dist/cli/checks/ids.js +111 -0
- package/dist/cli/checks/installed.js +51 -0
- package/dist/cli/checks/peers.js +31 -0
- package/dist/cli/checks/rollout.js +141 -0
- package/dist/cli/checks/store.js +71 -0
- package/dist/cli/checks/versions.js +83 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/main.js +182 -0
- package/dist/cli/output.js +77 -0
- package/dist/cli/packages.js +40 -0
- package/dist/cli/project/android.js +60 -0
- package/dist/cli/project/expo.js +194 -0
- package/dist/cli/project/files.js +42 -0
- package/dist/cli/project/gradle.js +145 -0
- package/dist/cli/project/index.js +10 -0
- package/dist/cli/project/ios.js +190 -0
- package/dist/cli/project/jsx.js +327 -0
- package/dist/cli/project/plist.js +166 -0
- package/dist/cli/project/sources.js +86 -0
- package/dist/cli/result.js +12 -0
- package/dist/compare.d.ts +31 -0
- package/dist/compare.d.ts.map +1 -0
- package/dist/compare.js +68 -0
- package/dist/detect.d.ts +68 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +103 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/fetchers/android.d.ts +53 -0
- package/dist/fetchers/android.d.ts.map +1 -0
- package/dist/fetchers/android.js +91 -0
- package/dist/fetchers/custom.d.ts +29 -0
- package/dist/fetchers/custom.d.ts.map +1 -0
- package/dist/fetchers/custom.js +41 -0
- package/dist/fetchers/ios.d.ts +61 -0
- package/dist/fetchers/ios.d.ts.map +1 -0
- package/dist/fetchers/ios.js +79 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -58
- package/dist/openStore.d.ts +29 -0
- package/dist/openStore.d.ts.map +1 -0
- package/dist/openStore.js +46 -0
- package/dist/policy.d.ts +75 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +128 -0
- package/dist/react/DefaultForceModal.d.ts +26 -0
- package/dist/react/DefaultForceModal.d.ts.map +1 -0
- package/dist/react/DefaultForceModal.js +58 -0
- package/dist/react/DefaultWarningSheet.d.ts +26 -0
- package/dist/react/DefaultWarningSheet.d.ts.map +1 -0
- package/dist/react/DefaultWarningSheet.js +66 -0
- package/dist/react/StoreVersionModal.d.ts +52 -0
- package/dist/react/StoreVersionModal.d.ts.map +1 -0
- package/dist/react/StoreVersionModal.js +250 -0
- package/dist/react/StoreVersionProvider.d.ts +51 -0
- package/dist/react/StoreVersionProvider.d.ts.map +1 -0
- package/dist/react/StoreVersionProvider.js +69 -0
- package/dist/react/defaultUi.d.ts +72 -0
- package/dist/react/defaultUi.d.ts.map +1 -0
- package/dist/react/defaultUi.js +118 -0
- package/dist/react/engine.d.ts +146 -0
- package/dist/react/engine.d.ts.map +1 -0
- package/dist/react/engine.js +541 -0
- package/dist/react/texts.d.ts +43 -0
- package/dist/react/texts.d.ts.map +1 -0
- package/dist/react/texts.js +57 -0
- package/dist/react/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/react/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/dist/react/useIsomorphicLayoutEffect.js +6 -0
- package/dist/react/useStoreVersion.d.ts +121 -0
- package/dist/react/useStoreVersion.d.ts.map +1 -0
- package/dist/react/useStoreVersion.js +23 -0
- package/dist/request.d.ts +78 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +227 -0
- package/dist/resolve.d.ts +98 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +218 -0
- package/dist/texts/ja.d.ts +8 -0
- package/dist/texts/ja.d.ts.map +1 -0
- package/dist/texts/ja.js +18 -0
- package/dist/vendor/compare-versions.d.ts +52 -0
- package/dist/vendor/compare-versions.d.ts.map +1 -0
- package/dist/vendor/compare-versions.js +111 -0
- package/package.json +83 -44
- package/src/checkVersion.ts +273 -0
- package/src/cli/check.ts +59 -0
- package/src/cli/checks/ids.ts +163 -0
- package/src/cli/checks/installed.ts +75 -0
- package/src/cli/checks/peers.ts +34 -0
- package/src/cli/checks/rollout.ts +183 -0
- package/src/cli/checks/store.ts +105 -0
- package/src/cli/checks/versions.ts +108 -0
- package/src/cli/index.ts +51 -0
- package/src/cli/main.ts +229 -0
- package/src/cli/output.ts +122 -0
- package/src/cli/packages.ts +43 -0
- package/src/cli/project/android.ts +96 -0
- package/src/cli/project/expo.ts +232 -0
- package/src/cli/project/files.ts +56 -0
- package/src/cli/project/gradle.ts +181 -0
- package/src/cli/project/index.ts +18 -0
- package/src/cli/project/ios.ts +284 -0
- package/src/cli/project/jsx.ts +354 -0
- package/src/cli/project/plist.ts +179 -0
- package/src/cli/project/sources.ts +118 -0
- package/src/cli/result.ts +34 -0
- package/src/compare.ts +101 -0
- package/src/detect.ts +178 -0
- package/src/errors.ts +63 -0
- package/src/fetchers/android.ts +136 -0
- package/src/fetchers/custom.ts +84 -0
- package/src/fetchers/ios.ts +160 -0
- package/src/index.ts +37 -0
- package/src/openStore.ts +74 -0
- package/src/policy.ts +223 -0
- package/src/react/DefaultForceModal.tsx +100 -0
- package/src/react/DefaultWarningSheet.tsx +115 -0
- package/src/react/StoreVersionModal.tsx +365 -0
- package/src/react/StoreVersionProvider.tsx +149 -0
- package/src/react/defaultUi.tsx +205 -0
- package/src/react/engine.ts +768 -0
- package/src/react/texts.ts +119 -0
- package/src/react/useIsomorphicLayoutEffect.ts +8 -0
- package/src/react/useStoreVersion.ts +153 -0
- package/src/request.ts +328 -0
- package/src/resolve.ts +388 -0
- package/src/texts/ja.ts +26 -0
- package/src/vendor/compare-versions.ts +128 -0
- package/texts/ja.d.ts +2 -0
- package/texts/ja.js +3 -0
- package/.eslintrc.js +0 -51
- package/.github/FUNDING.yml +0 -3
- package/.github/workflows/pr.yml +0 -48
- package/.github/workflows/release.yml +0 -259
- package/.prettierrc.js +0 -6
- package/babel.config.js +0 -3
- package/dist/android.d.ts +0 -1
- package/dist/android.js +0 -17
- package/dist/ios.d.ts +0 -1
- package/dist/ios.js +0 -18
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// デフォルト UI(Force / Warning)が共有する部品: 配色、Context の読み取りと文言の解決、ボタン、文字のスタイル。
|
|
2
|
+
// 値は元のデザイン(Force / Warning)の style と配色の定義からそのまま写す(目分量で変えない)。
|
|
3
|
+
// RN 標準のコンポーネントだけで作り、依存は足さない。Modal の枠は StoreVersionModal.tsx
|
|
4
|
+
import { useContext, useMemo } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
type ColorValue,
|
|
7
|
+
type ImageSourcePropType,
|
|
8
|
+
Pressable,
|
|
9
|
+
StyleSheet,
|
|
10
|
+
Text,
|
|
11
|
+
type TextStyle,
|
|
12
|
+
useColorScheme,
|
|
13
|
+
} from 'react-native';
|
|
14
|
+
|
|
15
|
+
import { resolveTexts, type StoreVersionResolvedTexts } from './texts.ts';
|
|
16
|
+
import {
|
|
17
|
+
type StoreVersionDisplay,
|
|
18
|
+
StoreVersionDisplayContext,
|
|
19
|
+
StoreVersionStateContext,
|
|
20
|
+
type UseStoreVersionResult,
|
|
21
|
+
} from './useStoreVersion.ts';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* デザインの配色の定義のうち、UI に使う色。実装から外したキー: appBg / block はデザインの背景のダミー画面の色、
|
|
25
|
+
* iconText はプレースホルダーの "icon" という文字の色(実装では `icon` の画像に置き換わるので当てる先が無い)
|
|
26
|
+
*/
|
|
27
|
+
export type Palette = {
|
|
28
|
+
/** カード / シートの背景 */
|
|
29
|
+
card: string;
|
|
30
|
+
/** タイトル */
|
|
31
|
+
text: string;
|
|
32
|
+
/** 本文 */
|
|
33
|
+
sub: string;
|
|
34
|
+
/** 塗りのボタンの背景(Provider の `primaryColor` で変えられる) */
|
|
35
|
+
primary: ColorValue;
|
|
36
|
+
/** `icon` の背景(画像の読み込み中・透過部分に見える) */
|
|
37
|
+
iconBg: string;
|
|
38
|
+
/** Warning のハンドル */
|
|
39
|
+
handle: string;
|
|
40
|
+
/** Warning の「あとで」の文字(Provider の `primaryColor` で変えられる) */
|
|
41
|
+
secondaryText: ColorValue;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** ライト / ダークの配色(Force / Warning の配色の定義。両方のデザインで同じ値) */
|
|
45
|
+
export const PALETTES: Record<'light' | 'dark', Palette> = {
|
|
46
|
+
light: {
|
|
47
|
+
card: '#FFFFFF',
|
|
48
|
+
text: '#18181B',
|
|
49
|
+
sub: '#52525B',
|
|
50
|
+
primary: '#1D4ED8',
|
|
51
|
+
iconBg: '#DBEAFE',
|
|
52
|
+
handle: '#D4D4D8',
|
|
53
|
+
secondaryText: '#1D4ED8',
|
|
54
|
+
},
|
|
55
|
+
dark: {
|
|
56
|
+
card: '#27272A',
|
|
57
|
+
text: '#FAFAFA',
|
|
58
|
+
sub: '#D4D4D8',
|
|
59
|
+
primary: '#2563EB',
|
|
60
|
+
iconBg: '#1E3A8A',
|
|
61
|
+
handle: '#52525B',
|
|
62
|
+
secondaryText: '#93C5FD',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** 塗りのボタンの文字(デザインは `color: #FFFFFF` 固定。ライト / ダークで変わらない) */
|
|
67
|
+
export const BUTTON_TEXT_COLOR = '#FFFFFF';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* カード / シートの最大幅(デザインから意図的に変える点)。タブレットや横向きで画面いっぱいに広がらないようにする。
|
|
71
|
+
* スマホの縦向き(幅 480 未満)では効かないので見た目は変わらない
|
|
72
|
+
*/
|
|
73
|
+
export const MAX_CONTENT_WIDTH = 480;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `primaryColor` として使える値か。JS の利用者が false / '' / null などを渡しても(`isBrand && '#E11D48'` など)、
|
|
77
|
+
* 既定の配色に戻す(そのまま style に入れると塗りが透明になる。`icon` / `texts` と同じ扱い)
|
|
78
|
+
*/
|
|
79
|
+
const isUsableColor = (value: unknown): value is ColorValue =>
|
|
80
|
+
typeof value === 'string'
|
|
81
|
+
? value !== ''
|
|
82
|
+
: typeof value === 'number' ||
|
|
83
|
+
(typeof value === 'object' && value !== null);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 端末の配色に合わせた色(`useColorScheme`。null(未対応の環境)はライト)。
|
|
87
|
+
* Provider に `primaryColor` があれば、ボタンの塗りと「あとで」の文字をそれにする
|
|
88
|
+
*/
|
|
89
|
+
export const usePalette = (): Palette => {
|
|
90
|
+
const palette = PALETTES[useColorScheme() === 'dark' ? 'dark' : 'light'];
|
|
91
|
+
const primaryColor = useContext(StoreVersionDisplayContext)?.primaryColor;
|
|
92
|
+
return useMemo(
|
|
93
|
+
() =>
|
|
94
|
+
!isUsableColor(primaryColor)
|
|
95
|
+
? palette
|
|
96
|
+
: { ...palette, primary: primaryColor, secondaryText: primaryColor },
|
|
97
|
+
[palette, primaryColor]
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `icon` を描くかどうかの正規化。JS からの利用で null / false を渡されても「無し」として扱う
|
|
103
|
+
* (`components` に渡す `icon` も undefined にそろえる)
|
|
104
|
+
*/
|
|
105
|
+
export const normalizeIcon = (
|
|
106
|
+
icon: ImageSourcePropType | undefined
|
|
107
|
+
): ImageSourcePropType | undefined => {
|
|
108
|
+
const value: unknown = icon;
|
|
109
|
+
return value == null || value === false ? undefined : icon;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** デフォルト UI が Context から読む値。`texts` は既定値で補完し `{remote}` / `{local}` を置き換え済み */
|
|
113
|
+
export type DefaultUiContext = {
|
|
114
|
+
state: UseStoreVersionResult;
|
|
115
|
+
display: StoreVersionDisplay;
|
|
116
|
+
texts: StoreVersionResolvedTexts;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 判定の状態と表示の設定を読み、文言を解決する。Provider の中でしか描画されないので Context は必ずある。
|
|
121
|
+
* 文言は `texts` / `local` / `remote` が変わったときだけ解決し直す(`texts` の変更は表示中のモーダルに即座に反映される)
|
|
122
|
+
*/
|
|
123
|
+
export const useDefaultUiContext = (): DefaultUiContext => {
|
|
124
|
+
const state = useContext(StoreVersionStateContext);
|
|
125
|
+
const display = useContext(StoreVersionDisplayContext);
|
|
126
|
+
if (state === null || display === null) {
|
|
127
|
+
// Provider が描くので外から到達できない。型を狭めるためだけの throw
|
|
128
|
+
throw new Error(
|
|
129
|
+
'the default UI of react-native-store-version must be rendered by <StoreVersionProvider>'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const rawTexts = display.texts;
|
|
133
|
+
const { local, remote } = state;
|
|
134
|
+
const texts = useMemo(
|
|
135
|
+
() => resolveTexts(rawTexts, { local, remote }),
|
|
136
|
+
[rawTexts, local, remote]
|
|
137
|
+
);
|
|
138
|
+
return { state, display, texts };
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** {@link ActionButton} の props */
|
|
142
|
+
export type ActionButtonProps = {
|
|
143
|
+
label: string;
|
|
144
|
+
onPress: () => void;
|
|
145
|
+
/** 塗りの色。無ければ文字だけのボタン(Warning の「あとで」) */
|
|
146
|
+
backgroundColor?: ColorValue;
|
|
147
|
+
/** 文字の色 */
|
|
148
|
+
color: ColorValue;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* ボタン(デザイン: 高さ 50・radius 12・文字 16/600)。高さはフォントスケールで伸びるよう `minHeight` にする(デザインから意図的に変える点)。
|
|
153
|
+
* 押している間だけ `opacity: 0.7`(デザインに無いので決めた値)。`allowFontScaling` は切らない(既定 true)
|
|
154
|
+
*/
|
|
155
|
+
export const ActionButton = ({
|
|
156
|
+
label,
|
|
157
|
+
onPress,
|
|
158
|
+
backgroundColor,
|
|
159
|
+
color,
|
|
160
|
+
}: ActionButtonProps) => (
|
|
161
|
+
<Pressable
|
|
162
|
+
accessibilityRole="button"
|
|
163
|
+
onPress={onPress}
|
|
164
|
+
style={({ pressed }) => [
|
|
165
|
+
styles.button,
|
|
166
|
+
backgroundColor === undefined ? null : { backgroundColor },
|
|
167
|
+
pressed ? styles.pressed : null,
|
|
168
|
+
]}
|
|
169
|
+
>
|
|
170
|
+
<Text style={[styles.buttonText, { color }]}>{label}</Text>
|
|
171
|
+
</Pressable>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
/** タイトル(デザイン: 20/28 bold)。フォントはプラットフォーム標準(fontFamily は指定しない) */
|
|
175
|
+
export const titleStyle: TextStyle = {
|
|
176
|
+
fontSize: 20,
|
|
177
|
+
lineHeight: 28,
|
|
178
|
+
fontWeight: '700',
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/** 本文(デザイン: 15/22) */
|
|
182
|
+
export const messageStyle: TextStyle = {
|
|
183
|
+
fontSize: 15,
|
|
184
|
+
lineHeight: 22,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const styles = StyleSheet.create({
|
|
188
|
+
button: {
|
|
189
|
+
minHeight: 50,
|
|
190
|
+
borderRadius: 12,
|
|
191
|
+
alignItems: 'center',
|
|
192
|
+
justifyContent: 'center',
|
|
193
|
+
// 押せる範囲の余白。文字 16 の行の高さ(約 22)+ 上下 8 ずつは minHeight 50 に収まるので、デザインの見た目の大きさは変わらない。
|
|
194
|
+
// 文字が長くて折り返したときや大きいフォントでは、文字が端に貼り付かずに済む
|
|
195
|
+
paddingVertical: 8,
|
|
196
|
+
paddingHorizontal: 16,
|
|
197
|
+
},
|
|
198
|
+
buttonText: {
|
|
199
|
+
fontSize: 16,
|
|
200
|
+
fontWeight: '600',
|
|
201
|
+
},
|
|
202
|
+
pressed: {
|
|
203
|
+
opacity: 0.7,
|
|
204
|
+
},
|
|
205
|
+
});
|