rn-css 1.6.13 → 1.6.14-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/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as RN from 'react-native';
3
+ import './polyfill';
3
4
  export { cssToRNStyle } from './cssToRN';
4
5
  export { SharedValue, FontSizeContext, RemContext } from './styleComponent';
5
6
  export * from './useTheme';
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.RemContext = exports.FontSizeContext = exports.SharedValue = exports.cssToRNStyle = void 0;
26
26
  const RN = __importStar(require("react-native"));
27
+ require("./polyfill");
27
28
  const styleComponent_1 = __importStar(require("./styleComponent"));
28
29
  var cssToRN_1 = require("./cssToRN");
29
30
  Object.defineProperty(exports, "cssToRNStyle", { enumerable: true, get: function () { return cssToRN_1.cssToRNStyle; } });
@@ -0,0 +1,3 @@
1
+ /** polyfill for Node < 12 */
2
+ declare function flat<A, D extends number = 1>(array: A, depth?: number): FlatArray<A, D>[];
3
+ declare function matchAll(str: string, regex: RegExp): IterableIterator<RegExpMatchArray>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /** polyfill for Node < 12 */
3
+ // eslint-disable-next-line no-extend-native
4
+ if (!Array.prototype.flat)
5
+ Array.prototype.flat = function (depth) { return flat(this, depth); };
6
+ // eslint-disable-next-line no-extend-native
7
+ if (!String.prototype.matchAll)
8
+ String.prototype.matchAll = function (regex) { return matchAll(this, regex); };
9
+ /** polyfill for Node < 12 */
10
+ function flat(array, depth = 1) {
11
+ if (!depth || depth < 1 || !Array.isArray(array))
12
+ return array;
13
+ return array.reduce((result, current) => result.concat(flat(current, depth - 1)), []);
14
+ }
15
+ function matchAll(str, regex) {
16
+ const matches = [];
17
+ let groups;
18
+ // eslint-disable-next-line no-cond-assign
19
+ while (groups = regex.exec(str)) {
20
+ matches.push(groups);
21
+ }
22
+ return matches[Symbol.iterator]();
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.6.13",
3
+ "version": "1.6.14-0",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "tsc",
@@ -53,9 +53,9 @@
53
53
  "ts-jest": "^27.1.1",
54
54
  "ts-loader": "^9.2.6",
55
55
  "typescript": "^4.5.4",
56
- "webpack": "^5.65.0",
57
- "webpack-cli": "^4.9.1",
58
- "webpack-dev-server": "^4.6.0"
56
+ "webpack": "^5.72.0",
57
+ "webpack-cli": "^4.9.2",
58
+ "webpack-dev-server": "^4.8.1"
59
59
  },
60
60
  "jest": {
61
61
  "preset": "react-native"
package/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import * as RN from 'react-native'
3
+ import './polyfill'
3
4
  import styledComponent, { styledFlatList, styledSectionList, styledVirtualizedList } from './styleComponent'
4
5
  export { cssToRNStyle } from './cssToRN'
5
6
  export { SharedValue, FontSizeContext, RemContext } from './styleComponent'
@@ -0,0 +1,23 @@
1
+ /** polyfill for Node < 12 */
2
+ // eslint-disable-next-line no-extend-native
3
+ if (!Array.prototype.flat) Array.prototype.flat = function <A, D extends number = 1> (depth?: number) { return flat<A, D>(this as unknown as A, depth) }
4
+ // eslint-disable-next-line no-extend-native
5
+ if (!String.prototype.matchAll) String.prototype.matchAll = function (regex: RegExp) { return matchAll(this as unknown as string, regex) }
6
+
7
+ /** polyfill for Node < 12 */
8
+ function flat <A, D extends number = 1> (array: A, depth = 1): FlatArray<A, D>[] {
9
+ if (!depth || depth < 1 || !Array.isArray(array)) return array as unknown as FlatArray<A, D>[]
10
+ return array.reduce((result, current) => result.concat(flat(current as unknown as unknown[], depth - 1)),
11
+ []
12
+ ) as FlatArray<A, D>[]
13
+ }
14
+
15
+ function matchAll (str: string, regex: RegExp): IterableIterator<RegExpMatchArray> {
16
+ const matches = []
17
+ let groups
18
+ // eslint-disable-next-line no-cond-assign
19
+ while (groups = regex.exec(str)) {
20
+ matches.push(groups)
21
+ }
22
+ return matches[Symbol.iterator]()
23
+ }