@office-iss/react-native-win32 0.68.4 → 0.68.5
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.json +16 -1
- package/CHANGELOG.md +12 -4
- package/Libraries/Utilities/Dimensions.win32.js +108 -11
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@office-iss/react-native-win32",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Sat, 17 Sep 2022 02:23:14 GMT",
|
|
6
|
+
"tag": "@office-iss/react-native-win32_v0.68.5",
|
|
7
|
+
"version": "0.68.5",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "patboyd@microsoft.com",
|
|
12
|
+
"package": "@office-iss/react-native-win32",
|
|
13
|
+
"commit": "3c214f08bba4a01f36e49eadb1dd749921150b94",
|
|
14
|
+
"comment": "Add Dimensions.win32 implementation to support text scale factor"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 14 Sep 2022 18:19:21 GMT",
|
|
6
21
|
"tag": "@office-iss/react-native-win32_v0.68.4",
|
|
7
22
|
"version": "0.68.4",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
# Change Log - @office-iss/react-native-win32
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 17 Sep 2022 02:23:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.68.
|
|
7
|
+
## 0.68.5
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Sat, 17 Sep 2022 02:23:14 GMT
|
|
10
10
|
|
|
11
11
|
### Patches
|
|
12
12
|
|
|
13
|
-
- Add
|
|
13
|
+
- Add Dimensions.win32 implementation to support text scale factor (patboyd@microsoft.com)
|
|
14
14
|
|
|
15
|
+
## 0.68.4
|
|
16
|
+
|
|
17
|
+
Wed, 14 Sep 2022 18:19:21 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Add `accessibilityAccessKey` prop to ViewWin32 (#10527) (ruaraki@microsoft.com)
|
|
22
|
+
|
|
15
23
|
## 0.68.3
|
|
16
24
|
|
|
17
25
|
Wed, 31 Aug 2022 19:24:44 GMT
|
|
@@ -6,28 +6,108 @@
|
|
|
6
6
|
* @flow
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import EventEmitter, {
|
|
10
|
+
type EventSubscription,
|
|
11
|
+
} from '../vendor/emitter/EventEmitter';
|
|
12
|
+
import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
|
|
13
|
+
import NativeDeviceInfo, {
|
|
14
|
+
type DisplayMetrics,
|
|
15
|
+
type DisplayMetricsAndroid,
|
|
16
|
+
type DimensionsPayload,
|
|
17
|
+
} from './NativeDeviceInfo';
|
|
18
|
+
import invariant from 'invariant';
|
|
10
19
|
|
|
20
|
+
const eventEmitter = new EventEmitter<{
|
|
21
|
+
change: [DimensionsPayload],
|
|
22
|
+
}>();
|
|
23
|
+
let dimensionsInitialized = false;
|
|
24
|
+
let dimensions: DimensionsPayload;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* While a global Dimensions object for window and screen dimensions is too simple for Win32,
|
|
28
|
+
* attached to this object is also fontScale which is a system global value. We expose this value
|
|
29
|
+
* for large text scaling support while leaving other window dimension information undefined. These undefined
|
|
30
|
+
* values will cause rendering issues if used but should avoid runtime failures in JS.
|
|
31
|
+
*/
|
|
11
32
|
class Dimensions {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
/**
|
|
34
|
+
* NOTE: `useWindowDimensions` is the preferred API for React components.
|
|
35
|
+
*
|
|
36
|
+
* Initial dimensions are set before `runApplication` is called so they should
|
|
37
|
+
* be available before any other require's are run, but may be updated later.
|
|
38
|
+
*
|
|
39
|
+
* Note: Although dimensions are available immediately, they may change (e.g
|
|
40
|
+
* due to device rotation) so any rendering logic or styles that depend on
|
|
41
|
+
* these constants should try to call this function on every render, rather
|
|
42
|
+
* than caching the value (for example, using inline styles rather than
|
|
43
|
+
* setting a value in a `StyleSheet`).
|
|
44
|
+
*
|
|
45
|
+
* Example: `const {height, width} = Dimensions.get('window');`
|
|
46
|
+
*
|
|
47
|
+
* @param {string} dim Name of dimension as defined when calling `set`.
|
|
48
|
+
* @returns {DisplayMetrics? | DisplayMetricsAndroid?} Value for the dimension.
|
|
49
|
+
*/
|
|
50
|
+
static get(dim: string): DisplayMetrics | DisplayMetricsAndroid {
|
|
51
|
+
invariant(dimensions[dim], 'No dimension set for key ' + dim);
|
|
52
|
+
return dimensions[dim];
|
|
16
53
|
}
|
|
17
54
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
/**
|
|
56
|
+
* This should only be called from native code by sending the
|
|
57
|
+
* didUpdateDimensions event.
|
|
58
|
+
*
|
|
59
|
+
* @param {DimensionsPayload} dims Simple string-keyed object of dimensions to set
|
|
60
|
+
*/
|
|
61
|
+
static set(dims: $ReadOnly<DimensionsPayload>): void {
|
|
62
|
+
let {screen, window} = dims;
|
|
63
|
+
const {windowPhysicalPixels} = dims;
|
|
64
|
+
if (windowPhysicalPixels) {
|
|
65
|
+
window = {
|
|
66
|
+
width: windowPhysicalPixels.width,
|
|
67
|
+
height: windowPhysicalPixels.height,
|
|
68
|
+
scale: windowPhysicalPixels.scale,
|
|
69
|
+
fontScale: windowPhysicalPixels.fontScale,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const {screenPhysicalPixels} = dims;
|
|
73
|
+
if (screenPhysicalPixels) {
|
|
74
|
+
screen = {
|
|
75
|
+
width: screenPhysicalPixels.width,
|
|
76
|
+
height: screenPhysicalPixels.height,
|
|
77
|
+
scale: screenPhysicalPixels.scale,
|
|
78
|
+
fontScale: screenPhysicalPixels.fontScale,
|
|
79
|
+
};
|
|
80
|
+
} else if (screen == null) {
|
|
81
|
+
screen = window;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
dimensions = {window, screen};
|
|
85
|
+
if (dimensionsInitialized) {
|
|
86
|
+
// Don't fire 'change' the first time the dimensions are set.
|
|
87
|
+
eventEmitter.emit('change', dimensions);
|
|
88
|
+
} else {
|
|
89
|
+
dimensionsInitialized = true;
|
|
90
|
+
}
|
|
22
91
|
}
|
|
23
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Add an event handler. Supported events:
|
|
95
|
+
*
|
|
96
|
+
* - `change`: Fires when a property within the `Dimensions` object changes. The argument
|
|
97
|
+
* to the event handler is an object with `window` and `screen` properties whose values
|
|
98
|
+
* are the same as the return values of `Dimensions.get('window')` and
|
|
99
|
+
* `Dimensions.get('screen')`, respectively.
|
|
100
|
+
*/
|
|
24
101
|
static addEventListener(
|
|
25
102
|
type: 'change',
|
|
26
103
|
handler: Function,
|
|
27
104
|
): EventSubscription {
|
|
28
|
-
|
|
29
|
-
|
|
105
|
+
invariant(
|
|
106
|
+
type === 'change',
|
|
107
|
+
'Trying to subscribe to unknown event: "%s"',
|
|
108
|
+
type,
|
|
30
109
|
);
|
|
110
|
+
return eventEmitter.addListener(type, handler);
|
|
31
111
|
}
|
|
32
112
|
|
|
33
113
|
/**
|
|
@@ -40,4 +120,21 @@ class Dimensions {
|
|
|
40
120
|
}
|
|
41
121
|
}
|
|
42
122
|
|
|
123
|
+
let initialDims: ?$ReadOnly<DimensionsPayload> =
|
|
124
|
+
global.nativeExtensions &&
|
|
125
|
+
global.nativeExtensions.DeviceInfo &&
|
|
126
|
+
global.nativeExtensions.DeviceInfo.Dimensions;
|
|
127
|
+
if (!initialDims) {
|
|
128
|
+
// Subscribe before calling getConstants to make sure we don't miss any updates in between.
|
|
129
|
+
RCTDeviceEventEmitter.addListener(
|
|
130
|
+
'didUpdateDimensions',
|
|
131
|
+
(update: DimensionsPayload) => {
|
|
132
|
+
Dimensions.set(update);
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
initialDims = NativeDeviceInfo.getConstants().Dimensions;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Dimensions.set(initialDims);
|
|
139
|
+
|
|
43
140
|
module.exports = Dimensions;
|