@apps-in-toss/framework 0.0.30 → 0.0.31
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.cjs +128 -4
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +128 -4
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1180,10 +1180,132 @@ __export(event_bridges_exports, {
|
|
|
1180
1180
|
// src/hooks/useCreateUserAgent.ts
|
|
1181
1181
|
var import_react_native14 = require("react-native");
|
|
1182
1182
|
var import_react_native_bedrock10 = require("react-native-bedrock");
|
|
1183
|
+
var FontA11yCategory = {
|
|
1184
|
+
Large: "Large",
|
|
1185
|
+
xLarge: "xLarge",
|
|
1186
|
+
xxLarge: "xxLarge",
|
|
1187
|
+
xxxLarge: "xxxLarge",
|
|
1188
|
+
A11y_Medium: "A11y_Medium",
|
|
1189
|
+
A11y_Large: "A11y_Large",
|
|
1190
|
+
A11y_xLarge: "A11y_xLarge",
|
|
1191
|
+
A11y_xxLarge: "A11y_xxLarge",
|
|
1192
|
+
A11y_xxxLarge: "A11y_xxxLarge"
|
|
1193
|
+
};
|
|
1194
|
+
var androidFontScaleMap = {
|
|
1195
|
+
100: FontA11yCategory.Large,
|
|
1196
|
+
110: FontA11yCategory.xLarge,
|
|
1197
|
+
120: FontA11yCategory.xxLarge,
|
|
1198
|
+
135: FontA11yCategory.xxxLarge,
|
|
1199
|
+
160: FontA11yCategory.A11y_Medium,
|
|
1200
|
+
190: FontA11yCategory.A11y_Large,
|
|
1201
|
+
235: FontA11yCategory.A11y_xLarge,
|
|
1202
|
+
275: FontA11yCategory.A11y_xxLarge,
|
|
1203
|
+
310: FontA11yCategory.A11y_xxxLarge
|
|
1204
|
+
};
|
|
1205
|
+
var iosScaleToAndroidScale = {
|
|
1206
|
+
0.823: 100,
|
|
1207
|
+
0.882: 100,
|
|
1208
|
+
0.941: 100,
|
|
1209
|
+
1: 100,
|
|
1210
|
+
1.118: 110,
|
|
1211
|
+
1.235: 120,
|
|
1212
|
+
1.353: 135,
|
|
1213
|
+
1.786: 160,
|
|
1214
|
+
2.143: 190,
|
|
1215
|
+
2.643: 235,
|
|
1216
|
+
3.143: 275,
|
|
1217
|
+
3.571: 310
|
|
1218
|
+
};
|
|
1219
|
+
function convertToAndroidStyleScale(fontScale, platform) {
|
|
1220
|
+
if (platform === "android") {
|
|
1221
|
+
if (fontScale <= 1) {
|
|
1222
|
+
return 100;
|
|
1223
|
+
}
|
|
1224
|
+
const scaledValue = Math.round(fontScale * 100);
|
|
1225
|
+
const keys = Object.keys(androidFontScaleMap).map(Number).sort((a, b) => a - b);
|
|
1226
|
+
let closestKey = keys[0];
|
|
1227
|
+
let minDiff = Math.abs(scaledValue - closestKey);
|
|
1228
|
+
for (const key of keys) {
|
|
1229
|
+
const diff = Math.abs(scaledValue - key);
|
|
1230
|
+
if (diff < minDiff) {
|
|
1231
|
+
minDiff = diff;
|
|
1232
|
+
closestKey = key;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return closestKey;
|
|
1236
|
+
} else {
|
|
1237
|
+
const iosScales = Object.keys(iosScaleToAndroidScale).map(Number);
|
|
1238
|
+
let closestScale = iosScales[0];
|
|
1239
|
+
let minDiff = Math.abs(fontScale - closestScale);
|
|
1240
|
+
for (const scale of iosScales) {
|
|
1241
|
+
const diff = Math.abs(fontScale - scale);
|
|
1242
|
+
if (diff < minDiff) {
|
|
1243
|
+
minDiff = diff;
|
|
1244
|
+
closestScale = scale;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return iosScaleToAndroidScale[closestScale];
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function mapIOSFontScaleToCategory(fontScale) {
|
|
1251
|
+
if (fontScale < 1) {
|
|
1252
|
+
return FontA11yCategory.Large;
|
|
1253
|
+
}
|
|
1254
|
+
if (Math.abs(fontScale - 1) < 0.05) {
|
|
1255
|
+
return FontA11yCategory.Large;
|
|
1256
|
+
}
|
|
1257
|
+
if (Math.abs(fontScale - 1.118) < 0.05) {
|
|
1258
|
+
return FontA11yCategory.xLarge;
|
|
1259
|
+
}
|
|
1260
|
+
if (Math.abs(fontScale - 1.235) < 0.05) {
|
|
1261
|
+
return FontA11yCategory.xxLarge;
|
|
1262
|
+
}
|
|
1263
|
+
if (Math.abs(fontScale - 1.353) < 0.05) {
|
|
1264
|
+
return FontA11yCategory.xxxLarge;
|
|
1265
|
+
}
|
|
1266
|
+
if (Math.abs(fontScale - 1.786) < 0.05) {
|
|
1267
|
+
return FontA11yCategory.A11y_Medium;
|
|
1268
|
+
}
|
|
1269
|
+
if (Math.abs(fontScale - 2.143) < 0.05) {
|
|
1270
|
+
return FontA11yCategory.A11y_Large;
|
|
1271
|
+
}
|
|
1272
|
+
if (Math.abs(fontScale - 2.643) < 0.05) {
|
|
1273
|
+
return FontA11yCategory.A11y_xLarge;
|
|
1274
|
+
}
|
|
1275
|
+
if (Math.abs(fontScale - 3.143) < 0.05) {
|
|
1276
|
+
return FontA11yCategory.A11y_xxLarge;
|
|
1277
|
+
}
|
|
1278
|
+
if (Math.abs(fontScale - 3.571) < 0.05) {
|
|
1279
|
+
return FontA11yCategory.A11y_xxxLarge;
|
|
1280
|
+
}
|
|
1281
|
+
return FontA11yCategory.Large;
|
|
1282
|
+
}
|
|
1283
|
+
function mapAndroidFontScaleToCategory(fontScale) {
|
|
1284
|
+
if (fontScale <= 1) {
|
|
1285
|
+
return androidFontScaleMap[100];
|
|
1286
|
+
}
|
|
1287
|
+
const scaledValue = Math.round(fontScale * 100);
|
|
1288
|
+
const keys = Object.keys(androidFontScaleMap).map(Number).sort((a, b) => a - b);
|
|
1289
|
+
if (keys.length === 0) {
|
|
1290
|
+
return androidFontScaleMap[100];
|
|
1291
|
+
}
|
|
1292
|
+
let closestKey = keys[0];
|
|
1293
|
+
let minDiff = Math.abs(scaledValue - closestKey);
|
|
1294
|
+
for (const key of keys) {
|
|
1295
|
+
const diff = Math.abs(scaledValue - key);
|
|
1296
|
+
if (diff < minDiff) {
|
|
1297
|
+
minDiff = diff;
|
|
1298
|
+
closestKey = key;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return androidFontScaleMap[closestKey];
|
|
1302
|
+
}
|
|
1303
|
+
function mapFontScaleToCategory(fontScale, platform) {
|
|
1304
|
+
return platform === "ios" ? mapIOSFontScaleToCategory(fontScale) : mapAndroidFontScaleToCategory(fontScale);
|
|
1305
|
+
}
|
|
1183
1306
|
function useCreateUserAgent({
|
|
1184
1307
|
batteryModePreference,
|
|
1185
1308
|
colorPreference,
|
|
1186
|
-
fontA11y,
|
|
1187
1309
|
locale,
|
|
1188
1310
|
navbarPreference,
|
|
1189
1311
|
pureSafeArea,
|
|
@@ -1192,14 +1314,16 @@ function useCreateUserAgent({
|
|
|
1192
1314
|
}) {
|
|
1193
1315
|
const platform = (0, import_react_native_bedrock10.getPlatformOS)();
|
|
1194
1316
|
const appVersion = getTossAppVersion();
|
|
1195
|
-
const fontScale = (0, import_react_native14.useWindowDimensions)()
|
|
1317
|
+
const { fontScale } = (0, import_react_native14.useWindowDimensions)();
|
|
1196
1318
|
const platformString = platform === "ios" ? "iPhone" : "Android";
|
|
1319
|
+
const fontA11y = mapFontScaleToCategory(fontScale, platform);
|
|
1320
|
+
const normalizedFontScale = convertToAndroidStyleScale(fontScale, platform);
|
|
1197
1321
|
return [
|
|
1198
1322
|
`TossApp/${appVersion}`,
|
|
1199
1323
|
batteryModePreference && `TossBatteryModePreference/${batteryModePreference}`,
|
|
1200
1324
|
colorPreference && `TossColorPreference/${colorPreference}`,
|
|
1201
|
-
|
|
1202
|
-
|
|
1325
|
+
`TossFontAccessibility/${fontA11y}`,
|
|
1326
|
+
`TossFontScale/${normalizedFontScale}`,
|
|
1203
1327
|
locale && `TossLocale/${locale}`,
|
|
1204
1328
|
navbarPreference && `TossNavbarPreference/${navbarPreference}`,
|
|
1205
1329
|
pureSafeArea && `TossPureSafeArea/${pureSafeArea}`,
|
package/dist/index.d.cts
CHANGED
|
@@ -1963,10 +1963,9 @@ interface LocalNetwork {
|
|
|
1963
1963
|
type InternalProps = 'source' | 'cacheEnabled' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded';
|
|
1964
1964
|
declare function WebView({ type, local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
1965
1965
|
|
|
1966
|
-
declare function useCreateUserAgent({ batteryModePreference, colorPreference,
|
|
1966
|
+
declare function useCreateUserAgent({ batteryModePreference, colorPreference, locale, navbarPreference, pureSafeArea, safeArea, safeAreaBottomTransparency, }: {
|
|
1967
1967
|
batteryModePreference?: string;
|
|
1968
1968
|
colorPreference?: string;
|
|
1969
|
-
fontA11y?: string;
|
|
1970
1969
|
locale?: string;
|
|
1971
1970
|
navbarPreference?: string;
|
|
1972
1971
|
pureSafeArea?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1963,10 +1963,9 @@ interface LocalNetwork {
|
|
|
1963
1963
|
type InternalProps = 'source' | 'cacheEnabled' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded';
|
|
1964
1964
|
declare function WebView({ type, local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
1965
1965
|
|
|
1966
|
-
declare function useCreateUserAgent({ batteryModePreference, colorPreference,
|
|
1966
|
+
declare function useCreateUserAgent({ batteryModePreference, colorPreference, locale, navbarPreference, pureSafeArea, safeArea, safeAreaBottomTransparency, }: {
|
|
1967
1967
|
batteryModePreference?: string;
|
|
1968
1968
|
colorPreference?: string;
|
|
1969
|
-
fontA11y?: string;
|
|
1970
1969
|
locale?: string;
|
|
1971
1970
|
navbarPreference?: string;
|
|
1972
1971
|
pureSafeArea?: string;
|
package/dist/index.js
CHANGED
|
@@ -1128,10 +1128,132 @@ __export(event_bridges_exports, {
|
|
|
1128
1128
|
// src/hooks/useCreateUserAgent.ts
|
|
1129
1129
|
import { useWindowDimensions } from "react-native";
|
|
1130
1130
|
import { getPlatformOS } from "react-native-bedrock";
|
|
1131
|
+
var FontA11yCategory = {
|
|
1132
|
+
Large: "Large",
|
|
1133
|
+
xLarge: "xLarge",
|
|
1134
|
+
xxLarge: "xxLarge",
|
|
1135
|
+
xxxLarge: "xxxLarge",
|
|
1136
|
+
A11y_Medium: "A11y_Medium",
|
|
1137
|
+
A11y_Large: "A11y_Large",
|
|
1138
|
+
A11y_xLarge: "A11y_xLarge",
|
|
1139
|
+
A11y_xxLarge: "A11y_xxLarge",
|
|
1140
|
+
A11y_xxxLarge: "A11y_xxxLarge"
|
|
1141
|
+
};
|
|
1142
|
+
var androidFontScaleMap = {
|
|
1143
|
+
100: FontA11yCategory.Large,
|
|
1144
|
+
110: FontA11yCategory.xLarge,
|
|
1145
|
+
120: FontA11yCategory.xxLarge,
|
|
1146
|
+
135: FontA11yCategory.xxxLarge,
|
|
1147
|
+
160: FontA11yCategory.A11y_Medium,
|
|
1148
|
+
190: FontA11yCategory.A11y_Large,
|
|
1149
|
+
235: FontA11yCategory.A11y_xLarge,
|
|
1150
|
+
275: FontA11yCategory.A11y_xxLarge,
|
|
1151
|
+
310: FontA11yCategory.A11y_xxxLarge
|
|
1152
|
+
};
|
|
1153
|
+
var iosScaleToAndroidScale = {
|
|
1154
|
+
0.823: 100,
|
|
1155
|
+
0.882: 100,
|
|
1156
|
+
0.941: 100,
|
|
1157
|
+
1: 100,
|
|
1158
|
+
1.118: 110,
|
|
1159
|
+
1.235: 120,
|
|
1160
|
+
1.353: 135,
|
|
1161
|
+
1.786: 160,
|
|
1162
|
+
2.143: 190,
|
|
1163
|
+
2.643: 235,
|
|
1164
|
+
3.143: 275,
|
|
1165
|
+
3.571: 310
|
|
1166
|
+
};
|
|
1167
|
+
function convertToAndroidStyleScale(fontScale, platform) {
|
|
1168
|
+
if (platform === "android") {
|
|
1169
|
+
if (fontScale <= 1) {
|
|
1170
|
+
return 100;
|
|
1171
|
+
}
|
|
1172
|
+
const scaledValue = Math.round(fontScale * 100);
|
|
1173
|
+
const keys = Object.keys(androidFontScaleMap).map(Number).sort((a, b) => a - b);
|
|
1174
|
+
let closestKey = keys[0];
|
|
1175
|
+
let minDiff = Math.abs(scaledValue - closestKey);
|
|
1176
|
+
for (const key of keys) {
|
|
1177
|
+
const diff = Math.abs(scaledValue - key);
|
|
1178
|
+
if (diff < minDiff) {
|
|
1179
|
+
minDiff = diff;
|
|
1180
|
+
closestKey = key;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
return closestKey;
|
|
1184
|
+
} else {
|
|
1185
|
+
const iosScales = Object.keys(iosScaleToAndroidScale).map(Number);
|
|
1186
|
+
let closestScale = iosScales[0];
|
|
1187
|
+
let minDiff = Math.abs(fontScale - closestScale);
|
|
1188
|
+
for (const scale of iosScales) {
|
|
1189
|
+
const diff = Math.abs(fontScale - scale);
|
|
1190
|
+
if (diff < minDiff) {
|
|
1191
|
+
minDiff = diff;
|
|
1192
|
+
closestScale = scale;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return iosScaleToAndroidScale[closestScale];
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function mapIOSFontScaleToCategory(fontScale) {
|
|
1199
|
+
if (fontScale < 1) {
|
|
1200
|
+
return FontA11yCategory.Large;
|
|
1201
|
+
}
|
|
1202
|
+
if (Math.abs(fontScale - 1) < 0.05) {
|
|
1203
|
+
return FontA11yCategory.Large;
|
|
1204
|
+
}
|
|
1205
|
+
if (Math.abs(fontScale - 1.118) < 0.05) {
|
|
1206
|
+
return FontA11yCategory.xLarge;
|
|
1207
|
+
}
|
|
1208
|
+
if (Math.abs(fontScale - 1.235) < 0.05) {
|
|
1209
|
+
return FontA11yCategory.xxLarge;
|
|
1210
|
+
}
|
|
1211
|
+
if (Math.abs(fontScale - 1.353) < 0.05) {
|
|
1212
|
+
return FontA11yCategory.xxxLarge;
|
|
1213
|
+
}
|
|
1214
|
+
if (Math.abs(fontScale - 1.786) < 0.05) {
|
|
1215
|
+
return FontA11yCategory.A11y_Medium;
|
|
1216
|
+
}
|
|
1217
|
+
if (Math.abs(fontScale - 2.143) < 0.05) {
|
|
1218
|
+
return FontA11yCategory.A11y_Large;
|
|
1219
|
+
}
|
|
1220
|
+
if (Math.abs(fontScale - 2.643) < 0.05) {
|
|
1221
|
+
return FontA11yCategory.A11y_xLarge;
|
|
1222
|
+
}
|
|
1223
|
+
if (Math.abs(fontScale - 3.143) < 0.05) {
|
|
1224
|
+
return FontA11yCategory.A11y_xxLarge;
|
|
1225
|
+
}
|
|
1226
|
+
if (Math.abs(fontScale - 3.571) < 0.05) {
|
|
1227
|
+
return FontA11yCategory.A11y_xxxLarge;
|
|
1228
|
+
}
|
|
1229
|
+
return FontA11yCategory.Large;
|
|
1230
|
+
}
|
|
1231
|
+
function mapAndroidFontScaleToCategory(fontScale) {
|
|
1232
|
+
if (fontScale <= 1) {
|
|
1233
|
+
return androidFontScaleMap[100];
|
|
1234
|
+
}
|
|
1235
|
+
const scaledValue = Math.round(fontScale * 100);
|
|
1236
|
+
const keys = Object.keys(androidFontScaleMap).map(Number).sort((a, b) => a - b);
|
|
1237
|
+
if (keys.length === 0) {
|
|
1238
|
+
return androidFontScaleMap[100];
|
|
1239
|
+
}
|
|
1240
|
+
let closestKey = keys[0];
|
|
1241
|
+
let minDiff = Math.abs(scaledValue - closestKey);
|
|
1242
|
+
for (const key of keys) {
|
|
1243
|
+
const diff = Math.abs(scaledValue - key);
|
|
1244
|
+
if (diff < minDiff) {
|
|
1245
|
+
minDiff = diff;
|
|
1246
|
+
closestKey = key;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
return androidFontScaleMap[closestKey];
|
|
1250
|
+
}
|
|
1251
|
+
function mapFontScaleToCategory(fontScale, platform) {
|
|
1252
|
+
return platform === "ios" ? mapIOSFontScaleToCategory(fontScale) : mapAndroidFontScaleToCategory(fontScale);
|
|
1253
|
+
}
|
|
1131
1254
|
function useCreateUserAgent({
|
|
1132
1255
|
batteryModePreference,
|
|
1133
1256
|
colorPreference,
|
|
1134
|
-
fontA11y,
|
|
1135
1257
|
locale,
|
|
1136
1258
|
navbarPreference,
|
|
1137
1259
|
pureSafeArea,
|
|
@@ -1140,14 +1262,16 @@ function useCreateUserAgent({
|
|
|
1140
1262
|
}) {
|
|
1141
1263
|
const platform = getPlatformOS();
|
|
1142
1264
|
const appVersion = getTossAppVersion();
|
|
1143
|
-
const fontScale = useWindowDimensions()
|
|
1265
|
+
const { fontScale } = useWindowDimensions();
|
|
1144
1266
|
const platformString = platform === "ios" ? "iPhone" : "Android";
|
|
1267
|
+
const fontA11y = mapFontScaleToCategory(fontScale, platform);
|
|
1268
|
+
const normalizedFontScale = convertToAndroidStyleScale(fontScale, platform);
|
|
1145
1269
|
return [
|
|
1146
1270
|
`TossApp/${appVersion}`,
|
|
1147
1271
|
batteryModePreference && `TossBatteryModePreference/${batteryModePreference}`,
|
|
1148
1272
|
colorPreference && `TossColorPreference/${colorPreference}`,
|
|
1149
|
-
|
|
1150
|
-
|
|
1273
|
+
`TossFontAccessibility/${fontA11y}`,
|
|
1274
|
+
`TossFontScale/${normalizedFontScale}`,
|
|
1151
1275
|
locale && `TossLocale/${locale}`,
|
|
1152
1276
|
navbarPreference && `TossNavbarPreference/${navbarPreference}`,
|
|
1153
1277
|
pureSafeArea && `TossPureSafeArea/${pureSafeArea}`,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.31",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"ait": "./bin/ait.js"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@apps-in-toss/analytics": "0.0.
|
|
61
|
-
"@apps-in-toss/cli": "0.0.
|
|
62
|
-
"@apps-in-toss/plugins": "0.0.
|
|
60
|
+
"@apps-in-toss/analytics": "0.0.31",
|
|
61
|
+
"@apps-in-toss/cli": "0.0.31",
|
|
62
|
+
"@apps-in-toss/plugins": "0.0.31",
|
|
63
63
|
"es-hangul": "^2.3.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"publishConfig": {
|
|
95
95
|
"access": "public"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "d4fa62f4014162182181b9911e0a2912fdec318d"
|
|
98
98
|
}
|