@office-iss/react-native-win32 0.72.0 → 0.72.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.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,43 @@
2
2
  "name": "@office-iss/react-native-win32",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 23 Jun 2023 22:29:26 GMT",
5
+ "date": "Mon, 14 Aug 2023 15:17:47 GMT",
6
+ "tag": "@office-iss/react-native-win32_v0.72.2",
7
+ "version": "0.72.2",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "email not defined",
12
+ "package": "@office-iss/react-native-win32",
13
+ "commit": "3e3d2da8e1bc2899525dc48e80d86df4e32c104d",
14
+ "comment": "add isDefaultButton check to win32"
15
+ },
16
+ {
17
+ "author": "30809111+acoates-ms@users.noreply.github.com",
18
+ "package": "@office-iss/react-native-win32",
19
+ "commit": "30ecf04918029a8699096532c8b13d4ae7a4b4f3",
20
+ "comment": "Add saveAssetPlugin to fix long path assets"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Wed, 19 Jul 2023 18:43:52 GMT",
27
+ "tag": "@office-iss/react-native-win32_v0.72.1",
28
+ "version": "0.72.1",
29
+ "comments": {
30
+ "patch": [
31
+ {
32
+ "author": "jthysell@microsoft.com",
33
+ "package": "@office-iss/react-native-win32",
34
+ "commit": "4b90fba00c273f34d7f97df5b659892d7a92749f",
35
+ "comment": "Integrate RN 0.72.3"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Fri, 23 Jun 2023 22:30:08 GMT",
6
42
  "tag": "@office-iss/react-native-win32_v0.72.0",
7
43
  "version": "0.72.0",
8
44
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,34 @@
1
1
  # Change Log - @office-iss/react-native-win32
2
2
 
3
- This log was last generated on Fri, 23 Jun 2023 22:29:26 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 14 Aug 2023 15:17:47 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.72.0
7
+ ## 0.72.2
8
8
 
9
- Fri, 23 Jun 2023 22:29:26 GMT
9
+ Mon, 14 Aug 2023 15:17:47 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Promote 0.72 to latest (jthysell@microsoft.com)
13
+ - add isDefaultButton check to win32 (email not defined)
14
+ - Add saveAssetPlugin to fix long path assets (30809111+acoates-ms@users.noreply.github.com)
14
15
 
16
+ ## 0.72.1
17
+
18
+ Wed, 19 Jul 2023 18:43:52 GMT
19
+
20
+ ### Patches
21
+
22
+ - Integrate RN 0.72.3 (jthysell@microsoft.com)
23
+
24
+ ## 0.72.0
25
+
26
+ Fri, 23 Jun 2023 22:30:08 GMT
27
+
28
+ ### Patches
29
+
30
+ - Promote 0.72 to latest (jthysell@microsoft.com)
31
+
15
32
  ## 0.72.0-preview.6
16
33
 
17
34
  Fri, 23 Jun 2023 01:59:52 GMT
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 72,
15
- patch: 0,
15
+ patch: 3,
16
16
  prerelease: null,
17
17
  };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @flow strict-local
6
+ * @format
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ // Some windows machines may not have long paths enabled
12
+ // https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
13
+ // Assets in nested node_modules (common when using pnpm) - end up creating very long paths
14
+ // Using this function we shorten longer paths to prevent paths from hitting the path limit
15
+ function ensureShortPath(str: string): string {
16
+ if (str.length < 40) return str;
17
+
18
+ const assetsPrefix = 'assets/';
19
+
20
+ if (!str.startsWith(assetsPrefix)) {
21
+ console.warn(`Unexpected asset uri - ${str} may not load correctly.`);
22
+ }
23
+
24
+ const postStr = str.slice(assetsPrefix.length);
25
+ var hash = 0,
26
+ i,
27
+ chr;
28
+ for (i = 0; i < postStr.length; i++) {
29
+ chr = postStr.charCodeAt(i);
30
+ hash = (hash << 5) - hash + chr;
31
+ hash |= 0; // Convert to 32bit integer
32
+ }
33
+ return assetsPrefix + hash.toString();
34
+ }
35
+
36
+ module.exports = ensureShortPath;
@@ -10,6 +10,7 @@
10
10
 
11
11
  const resolveAssetSource = require('./resolveAssetSource.js'); // Get base impl
12
12
  const Platform = require('../Utilities/Platform');
13
+ const ensureShortPath = require('./assetPaths.js');
13
14
 
14
15
  type IPackagerAsset = {
15
16
  __packager_asset: boolean,
@@ -56,7 +57,7 @@ class AssetResolverLateScaleResolution {
56
57
  */
57
58
  _scaledAssetURLInBundle() {
58
59
  const path = this._resolver.bundleUrl || 'file://';
59
- return this._fromSource(path + this._getAssetPath());
60
+ return this._fromSource(path + this._getAssetPath(true));
60
61
  }
61
62
 
62
63
  /**
@@ -66,7 +67,7 @@ class AssetResolverLateScaleResolution {
66
67
  _assetServerURL() {
67
68
  return this._fromSource(
68
69
  this._resolver.serverUrl +
69
- this._getAssetPath() +
70
+ this._getAssetPath(false) +
70
71
  '?platform=' +
71
72
  Platform.OS +
72
73
  '&hash=' +
@@ -77,8 +78,8 @@ class AssetResolverLateScaleResolution {
77
78
  /**
78
79
  * Returns a path like 'assets/AwesomeModule/icon.png'
79
80
  */
80
- _getAssetPath(): string {
81
- const assetDir = this._getBasePath();
81
+ _getAssetPath(local: boolean): string {
82
+ const assetDir = this._getBasePath(local);
82
83
  return (
83
84
  assetDir +
84
85
  '/' +
@@ -88,7 +89,19 @@ class AssetResolverLateScaleResolution {
88
89
  );
89
90
  }
90
91
 
91
- _getBasePath() {
92
+ _getBasePath(local: boolean) {
93
+ if (local) {
94
+ const safePath = this._resolver.asset.httpServerLocation
95
+ .substr(1)
96
+ .replace(/\.\.\//g, '_');
97
+ // If this asset was created with the newer saveAssetPlugin, then we should shorten the path
98
+ // This conditional is added to allow back compat of older bundles which might have been created without the saveAssetPlugin
99
+ if (this._resolver.asset.__useShortPath) {
100
+ return ensureShortPath(safePath);
101
+ }
102
+ return safePath;
103
+ }
104
+
92
105
  let basePath = this._resolver.asset.httpServerLocation;
93
106
  if (basePath[0] === '/') {
94
107
  basePath = basePath.substr(1);
@@ -429,6 +429,7 @@ export default class Pressability {
429
429
  |}>;
430
430
  _touchActivateTime: ?number;
431
431
  _touchState: TouchState = 'NOT_RESPONDER';
432
+ _isKeyDown: boolean = false;
432
433
 
433
434
  constructor(config: PressabilityConfig) {
434
435
  this.configure(config);
@@ -474,6 +475,7 @@ export default class Pressability {
474
475
  if (onBlur != null) {
475
476
  onBlur(event);
476
477
  }
478
+ this._isKeyDown = false;
477
479
  },
478
480
  onFocus: (event: FocusEvent): void => {
479
481
  const {onFocus} = this._config;
@@ -602,7 +604,8 @@ export default class Pressability {
602
604
  (event.nativeEvent.code === 'Space' ||
603
605
  event.nativeEvent.code === 'Enter' ||
604
606
  event.nativeEvent.code === 'GamepadA') &&
605
- event.defaultPrevented !== true
607
+ event.defaultPrevented !== true &&
608
+ this._isKeyDown
606
609
  ) {
607
610
  const {onPressOut, onPress} = this._config;
608
611
  // $FlowFixMe: PressEvents don't mesh with keyboarding APIs. Keep legacy behavior of passing KeyEvents instead
@@ -610,6 +613,8 @@ export default class Pressability {
610
613
  // $FlowFixMe: PressEvents don't mesh with keyboarding APIs. Keep legacy behavior of passing KeyEvents instead
611
614
  onPress && onPress(event);
612
615
  }
616
+ // Native windows app clears the key pressed state when another key press interrupts the current
617
+ this._isKeyDown = false;
613
618
  },
614
619
  onKeyDown: (event: KeyEvent): void => {
615
620
  const {onKeyDown} = this._config;
@@ -622,6 +627,7 @@ export default class Pressability {
622
627
  event.defaultPrevented !== true
623
628
  ) {
624
629
  const {onPressIn} = this._config;
630
+ this._isKeyDown = true;
625
631
  // $FlowFixMe: PressEvents don't mesh with keyboarding APIs. Keep legacy behavior of passing KeyEvents instead
626
632
  onPressIn && onPressIn(event);
627
633
  }
@@ -786,6 +792,12 @@ export default class Pressability {
786
792
  }
787
793
  }
788
794
 
795
+ // [Win32]
796
+ // $FlowFixMe - button typing
797
+ _isDefaultPressButton(button): boolean {
798
+ return !button; // Treat 0 or undefined as default press
799
+ }
800
+
789
801
  /**
790
802
  * Performs a transition between touchable states and identify any activations
791
803
  * or deactivations (and callback invocations).
@@ -814,7 +826,10 @@ export default class Pressability {
814
826
 
815
827
  if (isPressInSignal(prevState) && signal === 'LONG_PRESS_DETECTED') {
816
828
  const {onLongPress} = this._config;
817
- if (onLongPress != null) {
829
+ if (
830
+ onLongPress != null &&
831
+ this._isDefaultPressButton(getTouchFromPressEvent(event).button)
832
+ ) {
818
833
  onLongPress(event);
819
834
  }
820
835
  }
@@ -835,7 +850,11 @@ export default class Pressability {
835
850
  this._deactivate(event);
836
851
  }
837
852
  const {onLongPress, onPress, android_disableSound} = this._config;
838
- if (onPress != null) {
853
+
854
+ if (
855
+ onPress != null &&
856
+ this._isDefaultPressButton(getTouchFromPressEvent(event).button)
857
+ ) {
839
858
  const isPressCanceledByLongPress =
840
859
  onLongPress != null &&
841
860
  prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN' &&
@@ -854,17 +873,20 @@ export default class Pressability {
854
873
 
855
874
  _activate(event: PressEvent): void {
856
875
  const {onPressIn} = this._config;
857
- const {pageX, pageY} = getTouchFromPressEvent(event);
876
+ const {pageX, pageY, button} = getTouchFromPressEvent(event);
858
877
  this._touchActivatePosition = {pageX, pageY};
859
878
  this._touchActivateTime = Date.now();
860
- if (onPressIn != null) {
879
+ if (onPressIn != null && this._isDefaultPressButton(button)) {
861
880
  onPressIn(event);
862
881
  }
863
882
  }
864
883
 
865
884
  _deactivate(event: PressEvent): void {
866
885
  const {onPressOut} = this._config;
867
- if (onPressOut != null) {
886
+ if (
887
+ onPressOut != null &&
888
+ this._isDefaultPressButton(getTouchFromPressEvent(event).button)
889
+ ) {
868
890
  const minPressDuration = normalizeDelay(
869
891
  this._config.minPressDuration,
870
892
  0,
package/metro.config.js CHANGED
@@ -14,3 +14,5 @@ if (
14
14
 
15
15
  const {makeMetroConfig} = require('@rnw-scripts/metro-dev-config');
16
16
  module.exports = makeMetroConfig();
17
+ // Enable this when RN CLI gets support for saveAssetPlugins: https://github.com/react-native-community/cli/pull/2002
18
+ // module.exports.transformer.assetPlugins = [require.resolve('./metroShortPathAssetDataPlugin.js')];
@@ -0,0 +1,15 @@
1
+ // @ts-check
2
+ /**
3
+ * @typedef {import("metro").AssetData} AssetData;
4
+ **/
5
+
6
+ /**
7
+ * @param {AssetData & {__useShortPath: boolean}} asset
8
+ * @returns {Promise<AssetData>}
9
+ */
10
+ async function metroShortPathAssetDataPlugin(asset) {
11
+ asset.__useShortPath = true;
12
+ return Promise.resolve(asset);
13
+ }
14
+
15
+ module.exports = metroShortPathAssetDataPlugin;
package/overrides.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "**/__snapshots__/**",
8
8
  "src/rntypes/**"
9
9
  ],
10
- "baseVersion": "0.72.0",
10
+ "baseVersion": "0.72.3",
11
11
  "overrides": [
12
12
  {
13
13
  "type": "derived",
@@ -233,6 +233,10 @@
233
233
  "baseFile": "packages/react-native/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js",
234
234
  "baseHash": "1c9eb481e8ed077fa650e3ea34837e2a31310366"
235
235
  },
236
+ {
237
+ "type": "platform",
238
+ "file": "src/Libraries/Image/assetPaths.js"
239
+ },
236
240
  {
237
241
  "type": "derived",
238
242
  "file": "src/Libraries/Image/Image.win32.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@office-iss/react-native-win32",
3
- "version": "0.72.0",
3
+ "version": "0.72.2",
4
4
  "description": "Implementation of react native on top of Office's Win32 platform.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,16 +26,16 @@
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.0.0",
28
28
  "@jest/create-cache-key-function": "^29.2.1",
29
- "@react-native-community/cli": "11.3.2",
30
- "@react-native-community/cli-platform-android": "11.3.2",
31
- "@react-native-community/cli-platform-ios": "11.3.2",
29
+ "@react-native-community/cli": "11.3.5",
30
+ "@react-native-community/cli-platform-android": "11.3.5",
31
+ "@react-native-community/cli-platform-ios": "11.3.5",
32
32
  "@react-native/assets": "1.0.0",
33
33
  "@react-native/assets-registry": "^0.72.0",
34
34
  "@react-native/codegen": "^0.72.6",
35
- "@react-native/gradle-plugin": "^0.72.10",
35
+ "@react-native/gradle-plugin": "^0.72.11",
36
36
  "@react-native/js-polyfills": "^0.72.1",
37
37
  "@react-native/normalize-colors": "^0.72.0",
38
- "@react-native/virtualized-lists": "^0.72.5",
38
+ "@react-native/virtualized-lists": "^0.72.6",
39
39
  "abort-controller": "^3.0.0",
40
40
  "anser": "^1.4.9",
41
41
  "art": "^0.10.0",
@@ -47,8 +47,8 @@
47
47
  "jest-environment-node": "^29.2.1",
48
48
  "jsc-android": "^250231.0.0",
49
49
  "memoize-one": "^5.0.0",
50
- "metro-runtime": "0.76.5",
51
- "metro-source-map": "0.76.5",
50
+ "metro-runtime": "0.76.7",
51
+ "metro-source-map": "0.76.7",
52
52
  "mkdirp": "^0.5.1",
53
53
  "nullthrows": "^1.1.1",
54
54
  "pretty-format": "^26.5.2",
@@ -83,13 +83,13 @@
83
83
  "just-scripts": "^1.3.3",
84
84
  "prettier": "^2.4.1",
85
85
  "react": "18.2.0",
86
- "react-native": "0.72.0",
86
+ "react-native": "0.72.3",
87
87
  "react-native-platform-override": "^1.9.4",
88
88
  "typescript": "^4.9.5"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "react": "18.2.0",
92
- "react-native": "^0.72.0"
92
+ "react-native": "^0.72.3"
93
93
  },
94
94
  "beachball": {
95
95
  "defaultNpmTag": "latest",
@@ -7,6 +7,8 @@ module.exports = {
7
7
  projectConfig: (projectRoot, projectParams) => null,
8
8
  dependencyConfig: (projectRoot, dependencyParams) => null,
9
9
  npmPackageName: '@office-iss/react-native-win32',
10
+ // Enable once CLI config supports it - https://github.com/react-native-community/cli/pull/2002
11
+ // saveAssetsPlugin: '@office-iss/react-native-win32/saveAssetPlugin'
10
12
  },
11
13
  },
12
14
  };
@@ -0,0 +1,45 @@
1
+ // @ts-check
2
+ const path = require('path');
3
+ const ensureShortPath = require('./Libraries/Image/assetPaths');
4
+
5
+ /**
6
+ * @typedef {import("metro").AssetData} AssetData;
7
+ **/
8
+
9
+ /**
10
+ * @param {AssetData} asset
11
+ * @param {number} scale
12
+ * @returns {string}
13
+ */
14
+ function getAssetDestPath(asset, scale) {
15
+ const suffix = scale === 1 ? '' : `@${scale}x`;
16
+ const fileName = `${asset.name + suffix}.${asset.type}`;
17
+ return path.join(
18
+ // Assets can have relative paths outside of the project root.
19
+ // Replace `../` with `_` to make sure they don't end up outside of
20
+ // the expected assets directory.
21
+ ensureShortPath(asset.httpServerLocation.substr(1).replace(/\.\.\//g, '_')),
22
+ fileName,
23
+ );
24
+ }
25
+
26
+ /**
27
+ * @param {ReadonlyArray<AssetData>} assets
28
+ * @param {string} _platform
29
+ * @param {string | undefined} _assetsDest
30
+ * @param {string | undefined} _assetCatalogDest
31
+ * @param {(asset: AssetData, allowedScales: number[] | undefined, getAssetDestPath: (asset: AssetData, scale: number) => string) => void} addAssetToCopy
32
+ */
33
+ function saveAssetsWin32(
34
+ assets,
35
+ _platform,
36
+ _assetsDest,
37
+ _assetCatalogDest,
38
+ addAssetToCopy,
39
+ ) {
40
+ assets.forEach((asset) =>
41
+ addAssetToCopy(asset, undefined, getAssetDestPath),
42
+ );
43
+ }
44
+
45
+ module.exports = saveAssetsWin32;