@hero-design/rn 8.141.0 → 8.141.2-expo-snack

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.141.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#5698](https://github.com/Thinkei/hero-design/pull/5698) [`e0047fb`](https://github.com/Thinkei/hero-design/commit/e0047fb662d104e68e63b390648d8b3cd6712729) Thanks [@ttkien](https://github.com/ttkien)! - expo snack for documentation website
8
+
9
+ ## 8.141.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#5652](https://github.com/Thinkei/hero-design/pull/5652) [`fdf82a6`](https://github.com/Thinkei/hero-design/commit/fdf82a6ff5136ae788041dcd0039951656799d0f) Thanks [@haudao-eh](https://github.com/haudao-eh)! - [Icon] Update stop-outlined mobile icon
14
+
3
15
  ## 8.141.0
4
16
 
5
17
  ### Minor Changes
Binary file
package/jest.config.js CHANGED
@@ -16,7 +16,7 @@ module.exports = {
16
16
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
17
17
  setupFiles: ['<rootDir>/testUtils/setup.tsx'],
18
18
  setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
19
- roots: ['<rootDir>/src'],
19
+ roots: ['<rootDir>/src', '<rootDir>/scripts'],
20
20
  snapshotSerializers: ['@emotion/jest/serializer'],
21
21
  transformIgnorePatterns: [
22
22
  'node_modules/(?!((jest-)?@react-native|@emotion/.*|react-native|react-native-pager-view|@react-native-community|@react-native-masked-view|expo-linear-gradient|nanoid|d3|d3-.*|internmap|delaunator|robust-predicates|date-fns)/)',
package/lib/index.js CHANGED
@@ -9,8 +9,6 @@ var Svg = require('react-native-svg');
9
9
  var reactNativeSafeAreaContext = require('react-native-safe-area-context');
10
10
  var reactNativeMonthYearPicker = require('@hero-design/react-native-month-year-picker');
11
11
  var DateTimePicker = require('@react-native-community/datetimepicker');
12
- var RnSlider = require('@react-native-community/slider');
13
- var MultiSlider = require('@ptomasroos/react-native-multi-slider');
14
12
  var reactNativeGestureHandler = require('react-native-gesture-handler');
15
13
  var PagerView = require('react-native-pager-view');
16
14
  var events = require('events');
@@ -41,8 +39,6 @@ var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
41
39
  var MaskedView__default = /*#__PURE__*/_interopDefaultCompat(MaskedView);
42
40
  var Svg__default = /*#__PURE__*/_interopDefaultCompat(Svg);
43
41
  var DateTimePicker__default = /*#__PURE__*/_interopDefaultCompat(DateTimePicker);
44
- var RnSlider__default = /*#__PURE__*/_interopDefaultCompat(RnSlider);
45
- var MultiSlider__default = /*#__PURE__*/_interopDefaultCompat(MultiSlider);
46
42
  var PagerView__default = /*#__PURE__*/_interopDefaultCompat(PagerView);
47
43
 
48
44
  function _arrayLikeToArray(r, a) {
@@ -2204,10 +2200,9 @@ styleSheet.flush()
2204
2200
  - empties the stylesheet of all its contents
2205
2201
 
2206
2202
  */
2207
- // $FlowFixMe
2203
+
2208
2204
  function sheetForTag(tag) {
2209
2205
  if (tag.sheet) {
2210
- // $FlowFixMe
2211
2206
  return tag.sheet;
2212
2207
  } // this weirdness brought to you by firefox
2213
2208
 
@@ -2215,10 +2210,12 @@ function sheetForTag(tag) {
2215
2210
 
2216
2211
  for (var i = 0; i < document.styleSheets.length; i++) {
2217
2212
  if (document.styleSheets[i].ownerNode === tag) {
2218
- // $FlowFixMe
2219
2213
  return document.styleSheets[i];
2220
2214
  }
2221
- }
2215
+ } // this function should always return with a value
2216
+ // TS can't understand it though so we make it stop complaining here
2217
+
2218
+ return undefined;
2222
2219
  }
2223
2220
  function createStyleElement(options) {
2224
2221
  var tag = document.createElement('style');
@@ -2250,7 +2247,7 @@ var StyleSheet = /*#__PURE__*/function () {
2250
2247
  _this.container.insertBefore(tag, before);
2251
2248
  _this.tags.push(tag);
2252
2249
  };
2253
- this.isSpeedy = options.speedy === undefined ? "production" === 'production' : options.speedy;
2250
+ this.isSpeedy = options.speedy === undefined ? true : options.speedy;
2254
2251
  this.tags = [];
2255
2252
  this.ctr = 0;
2256
2253
  this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
@@ -2279,17 +2276,16 @@ var StyleSheet = /*#__PURE__*/function () {
2279
2276
  // this is the ultrafast version, works across browsers
2280
2277
  // the big drawback is that the css won't be editable in devtools
2281
2278
  sheet.insertRule(rule, sheet.cssRules.length);
2282
- } catch (e) {
2283
- }
2279
+ } catch (e) {}
2284
2280
  } else {
2285
2281
  tag.appendChild(document.createTextNode(rule));
2286
2282
  }
2287
2283
  this.ctr++;
2288
2284
  };
2289
2285
  _proto.flush = function flush() {
2290
- // $FlowFixMe
2291
2286
  this.tags.forEach(function (tag) {
2292
- return tag.parentNode && tag.parentNode.removeChild(tag);
2287
+ var _tag$parentNode;
2288
+ return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
2293
2289
  });
2294
2290
  this.tags = [];
2295
2291
  this.ctr = 0;
@@ -2885,11 +2881,11 @@ function rulesheet(callback) {
2885
2881
  }
2886
2882
 
2887
2883
  var weakMemoize = function weakMemoize(func) {
2888
- // $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
2889
2884
  var cache = new WeakMap();
2890
2885
  return function (arg) {
2891
2886
  if (cache.has(arg)) {
2892
- // $FlowFixMe
2887
+ // Use non-null assertion because we just checked that the cache `has` it
2888
+ // This allows us to remove `undefined` from the return value
2893
2889
  return cache.get(arg);
2894
2890
  }
2895
2891
  var ret = func(arg);
@@ -2898,6 +2894,15 @@ var weakMemoize = function weakMemoize(func) {
2898
2894
  };
2899
2895
  };
2900
2896
 
2897
+ function memoize(fn) {
2898
+ var cache = Object.create(null);
2899
+ return function (arg) {
2900
+ if (cache[arg] === undefined) cache[arg] = fn(arg);
2901
+ return cache[arg];
2902
+ };
2903
+ }
2904
+
2905
+ var isBrowser = typeof document !== 'undefined';
2901
2906
  var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
2902
2907
  var previous = 0;
2903
2908
  var character = 0;
@@ -2964,8 +2969,8 @@ var compat = function compat(element) {
2964
2969
  element.length < 1) {
2965
2970
  return;
2966
2971
  }
2967
- var value = element.value,
2968
- parent = element.parent;
2972
+ var value = element.value;
2973
+ var parent = element.parent;
2969
2974
  var isImplicitRule = element.column === parent.column && element.line === parent.line;
2970
2975
  while (parent.type !== 'rule') {
2971
2976
  parent = parent.parent;
@@ -3210,10 +3215,15 @@ var prefixer = function prefixer(element, index, children, callback) {
3210
3215
  });
3211
3216
  }
3212
3217
  };
3218
+ var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () {
3219
+ return memoize(function () {
3220
+ return {};
3221
+ });
3222
+ });
3213
3223
  var defaultStylisPlugins = [prefixer];
3214
3224
  var createCache = function createCache(options) {
3215
3225
  var key = options.key;
3216
- if (key === 'css') {
3226
+ if (isBrowser && key === 'css') {
3217
3227
  var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
3218
3228
  // document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
3219
3229
  // note this very very intentionally targets all style elements regardless of the key to ensure
@@ -3238,14 +3248,13 @@ var createCache = function createCache(options) {
3238
3248
  var inserted = {};
3239
3249
  var container;
3240
3250
  var nodesToHydrate = [];
3241
- {
3251
+ if (isBrowser) {
3242
3252
  container = options.container || document.head;
3243
3253
  Array.prototype.forEach.call(
3244
3254
  // this means we will ignore elements which don't have a space in them which
3245
3255
  // means that the style elements we're looking at are only Emotion 11 server-rendered style elements
3246
3256
  document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
3247
- var attrib = node.getAttribute("data-emotion").split(' '); // $FlowFixMe
3248
-
3257
+ var attrib = node.getAttribute("data-emotion").split(' ');
3249
3258
  for (var i = 1; i < attrib.length; i++) {
3250
3259
  inserted[attrib[i]] = true;
3251
3260
  }
@@ -3254,7 +3263,7 @@ var createCache = function createCache(options) {
3254
3263
  }
3255
3264
  var _insert;
3256
3265
  var omnipresentPlugins = [compat, removeLabel];
3257
- {
3266
+ if (!getServerStylisCache) {
3258
3267
  var currentSheet;
3259
3268
  var finalizingPlugins = [stringify, rulesheet(function (rule) {
3260
3269
  currentSheet.insert(rule);
@@ -3270,6 +3279,46 @@ var createCache = function createCache(options) {
3270
3279
  cache.inserted[serialized.name] = true;
3271
3280
  }
3272
3281
  };
3282
+ } else {
3283
+ var _finalizingPlugins = [stringify];
3284
+ var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
3285
+ var _stylis = function _stylis(styles) {
3286
+ return serialize(compile(styles), _serializer);
3287
+ };
3288
+ var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
3289
+ var getRules = function getRules(selector, serialized) {
3290
+ var name = serialized.name;
3291
+ if (serverStylisCache[name] === undefined) {
3292
+ serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
3293
+ }
3294
+ return serverStylisCache[name];
3295
+ };
3296
+ _insert = function _insert(selector, serialized, sheet, shouldCache) {
3297
+ var name = serialized.name;
3298
+ var rules = getRules(selector, serialized);
3299
+ if (cache.compat === undefined) {
3300
+ // in regular mode, we don't set the styles on the inserted cache
3301
+ // since we don't need to and that would be wasting memory
3302
+ // we return them so that they are rendered in a style tag
3303
+ if (shouldCache) {
3304
+ cache.inserted[name] = true;
3305
+ }
3306
+ return rules;
3307
+ } else {
3308
+ // in compat mode, we put the styles on the inserted cache so
3309
+ // that emotion-server can pull out the styles
3310
+ // except when we don't want to cache it which was in Global but now
3311
+ // is nowhere but we don't want to do a major right now
3312
+ // and just in case we're going to leave the case here
3313
+ // it's also not affecting client side bundle size
3314
+ // so it's really not a big deal
3315
+ if (shouldCache) {
3316
+ cache.inserted[name] = rules;
3317
+ } else {
3318
+ return rules;
3319
+ }
3320
+ }
3321
+ };
3273
3322
  }
3274
3323
  var cache = {
3275
3324
  key: key,
@@ -27244,6 +27293,46 @@ var Progress = {
27244
27293
  Step: ProgressStep
27245
27294
  };
27246
27295
 
27296
+ // Function/class components, or exotic ones such as memo/forwardRef (objects with `$$typeof`)
27297
+ var isComponent = function isComponent(value) {
27298
+ return typeof value === 'function' || _typeof(value) === 'object' && value !== null && '$$typeof' in value;
27299
+ };
27300
+ var getLinkingError = function getLinkingError(packageName) {
27301
+ return "The package '".concat(packageName, "' doesn't seem to be linked. Make sure: \n\n").concat(reactNative.Platform.select({
27302
+ ios: "- You have run 'pod install'\n",
27303
+ "default": ''
27304
+ }), "- You rebuilt the app after installing the package\n");
27305
+ };
27306
+ /**
27307
+ * Loads a component from a package that needs native linking.
27308
+ * When the package can't be loaded (e.g. in Expo Snack), returns a component
27309
+ * that renders a linking error instead of crashing the whole library.
27310
+ *
27311
+ * `load` must contain a literal `require('<packageName>')` so Metro can resolve it statically.
27312
+ */
27313
+ var loadNativeComponent = function loadNativeComponent(packageName, load) {
27314
+ try {
27315
+ var nativeModule = load();
27316
+ // Depending on the bundler's interop, the component is either `default` or the module itself
27317
+ var defaultExport = nativeModule["default"];
27318
+ var component = isComponent(defaultExport) ? defaultExport : nativeModule;
27319
+ if (isComponent(component)) {
27320
+ return component;
27321
+ }
27322
+ } catch (_unused) {
27323
+ // package not linked, fall through to the linking error component
27324
+ }
27325
+ var LinkingError = function LinkingError() {
27326
+ return /*#__PURE__*/React__namespace.default.createElement(reactNative.View, null, /*#__PURE__*/React__namespace.default.createElement(reactNative.Text, null, getLinkingError(packageName)));
27327
+ };
27328
+ return LinkingError;
27329
+ };
27330
+
27331
+ var SliderComponent = loadNativeComponent('@react-native-community/slider',
27332
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
27333
+ function () {
27334
+ return require('@react-native-community/slider');
27335
+ });
27247
27336
  var Slider$2 = function Slider(_ref) {
27248
27337
  var _ref$minimumValue = _ref.minimumValue,
27249
27338
  minimumValue = _ref$minimumValue === void 0 ? 0 : _ref$minimumValue,
@@ -27265,7 +27354,7 @@ var Slider$2 = function Slider(_ref) {
27265
27354
  selectedTrack = _theme$__hd__$slider$.selectedTrack,
27266
27355
  thumb = _theme$__hd__$slider$.thumb,
27267
27356
  unselectedTrack = _theme$__hd__$slider$.unselectedTrack;
27268
- return /*#__PURE__*/React__namespace.default.createElement(RnSlider__default.default, {
27357
+ return /*#__PURE__*/React__namespace.default.createElement(SliderComponent, {
27269
27358
  minimumValue: minimumValue,
27270
27359
  maximumValue: maximumValue,
27271
27360
  step: step,
@@ -27293,6 +27382,11 @@ var StyledMarker = index$c(reactNative.View)(function (_ref) {
27293
27382
  }, theme.__hd__.slider.shadows.marker);
27294
27383
  });
27295
27384
 
27385
+ var MultiSlider = loadNativeComponent('@ptomasroos/react-native-multi-slider',
27386
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
27387
+ function () {
27388
+ return require('@ptomasroos/react-native-multi-slider');
27389
+ });
27296
27390
  var Slider$1 = function Slider(_ref) {
27297
27391
  var minimumValue = _ref.minimumValue,
27298
27392
  maximumValue = _ref.maximumValue,
@@ -27391,7 +27485,7 @@ var Slider$1 = function Slider(_ref) {
27391
27485
  accessibilityState: {
27392
27486
  disabled: disabled
27393
27487
  }
27394
- }, /*#__PURE__*/React__namespace.default.createElement(MultiSlider__default.default, {
27488
+ }, /*#__PURE__*/React__namespace.default.createElement(MultiSlider, {
27395
27489
  values: nativeValue,
27396
27490
  onValuesChange: handleTwoWaySliderChange,
27397
27491
  onValuesChangeStart: handleOnValueChangeStart,
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.141.0",
3
+ "version": "8.141.2-expo-snack",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
- "module": "es/index.js",
7
6
  "types": "types/index.d.ts",
8
7
  "typesVersions": {
9
8
  "*": {
@@ -12,7 +11,6 @@
12
11
  ]
13
12
  }
14
13
  },
15
- "react-native": "src/index.ts",
16
14
  "scripts": {
17
15
  "lint": "eslint src --quiet",
18
16
  "type-check": "tsc --noEmit",
@@ -24,6 +22,7 @@
24
22
  "build": "yarn build:js && yarn build:types",
25
23
  "build:watch": "yarn build:js -w & yarn build:types -w",
26
24
  "publish:npm": "yarn publish --access public",
25
+ "publish:expo-snack": "node scripts/publish-expo-snack.js",
27
26
  "set-dev-env": "npm pkg set react-native=src/index.ts"
28
27
  },
29
28
  "dependencies": {
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@hero-design/rn",
3
+ "version": "8.141.2",
4
+ "license": "MIT",
5
+ "main": "lib/index.js",
6
+ "types": "types/index.d.ts",
7
+ "typesVersions": {
8
+ "*": {
9
+ "locales/*": [
10
+ "types/locales/*"
11
+ ]
12
+ }
13
+ },
14
+ "react-native": "src/index.ts",
15
+ "scripts": {
16
+ "lint": "eslint src --quiet",
17
+ "type-check": "tsc --noEmit",
18
+ "test": "jest --runInBand",
19
+ "test:watch": "jest --runInBand --watch",
20
+ "test:ci": "jest --c=jest-ci.config.js --i --logHeapUsage --coverage",
21
+ "build:js": "rollup -c",
22
+ "build:types": "tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json",
23
+ "build": "yarn build:js && yarn build:types",
24
+ "build:watch": "yarn build:js -w & yarn build:types -w",
25
+ "publish:npm": "yarn publish --access public",
26
+ "publish:expo-snack": "node scripts/publish-expo-snack.js",
27
+ "set-dev-env": "npm pkg set react-native=src/index.ts"
28
+ },
29
+ "dependencies": {
30
+ "@emotion/native": "^11.9.3",
31
+ "@emotion/react": "^11.9.3",
32
+ "@hero-design/colors": "8.47.3",
33
+ "d3": "^7.8.5",
34
+ "date-fns": "^4.4.0",
35
+ "hero-editor": "^1.17.0",
36
+ "nanoid": "^5.0.9"
37
+ },
38
+ "peerDependencies": {
39
+ "@hero-design/react-native-month-year-picker": "^8.46.1",
40
+ "@ptomasroos/react-native-multi-slider": "^2.2.2",
41
+ "@react-native-community/datetimepicker": "^8.4.4",
42
+ "@react-native-community/slider": "^5.0.1",
43
+ "@react-native-masked-view/masked-view": "^0.3.2",
44
+ "expo-linear-gradient": ">=14.0.0",
45
+ "react": "19.1.0",
46
+ "react-native": "0.81.5",
47
+ "react-native-gesture-handler": "~2.28.0",
48
+ "react-native-pager-view": "^6.7.0",
49
+ "react-native-safe-area-context": "~5.6.0",
50
+ "react-native-svg": "^15.11.2",
51
+ "react-native-vector-icons": "^9.1.0",
52
+ "react-native-webview": "^13.10.2"
53
+ },
54
+ "devDependencies": {
55
+ "@babel/core": "^7.25.2",
56
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
57
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
58
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
59
+ "@babel/preset-env": "^7.29.7",
60
+ "@babel/preset-react": "^7.26.3",
61
+ "@babel/preset-typescript": "^7.27.0",
62
+ "@babel/runtime": "^7.29.7",
63
+ "@emotion/jest": "^11.11.0",
64
+ "@eslint/compat": "^1.1.1",
65
+ "@eslint/js": "^9.8.0",
66
+ "@hero-design/eslint-plugin": "10.0.0",
67
+ "@hero-design/react-native-month-year-picker": "^8.46.1",
68
+ "@ptomasroos/react-native-multi-slider": "^2.2.2",
69
+ "@react-native-community/datetimepicker": "8.4.4",
70
+ "@react-native-community/slider": "^5.0.1",
71
+ "@react-native-masked-view/masked-view": "0.3.2",
72
+ "@react-native/babel-preset": "0.81.5",
73
+ "@rollup/plugin-babel": "^6.0.4",
74
+ "@rollup/plugin-commonjs": "^28.0.1",
75
+ "@rollup/plugin-json": "^6.1.0",
76
+ "@rollup/plugin-node-resolve": "^15.3.0",
77
+ "@rollup/plugin-replace": "^6.0.1",
78
+ "@rollup/plugin-typescript": "^12.1.1",
79
+ "@testing-library/jest-native": "^5.4.2",
80
+ "@testing-library/react-hooks": "^8.0.1",
81
+ "@testing-library/react-native": "^13.0.0",
82
+ "@types/d3": "^7.4.3",
83
+ "@types/events": "^3.0.3",
84
+ "@types/jest": "^29.5.3",
85
+ "@types/react": "^19.0.0",
86
+ "@types/react-native-vector-icons": "^6.4.10",
87
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
88
+ "babel-plugin-inline-import": "^3.0.0",
89
+ "core-js": "^3.33.0",
90
+ "eslint": "^9.0.0",
91
+ "eslint-config-hd": "8.42.7",
92
+ "expo-linear-gradient": "55.0.9",
93
+ "jest": "^29.7.0",
94
+ "jest-environment-jsdom": "^29.2.1",
95
+ "jest-junit": "^17.0.0",
96
+ "prettier-config-hd": "8.42.4",
97
+ "react": "19.1.0",
98
+ "react-dom": "19.1.0",
99
+ "react-native": "0.81.5",
100
+ "react-native-gesture-handler": "~2.28.0",
101
+ "react-native-pager-view": "6.9.1",
102
+ "react-native-safe-area-context": "~5.6.0",
103
+ "react-native-svg": "15.12.1",
104
+ "react-native-vector-icons": "^9.1.0",
105
+ "react-native-webview": "13.15.0",
106
+ "react-test-renderer": "19.1.0",
107
+ "rollup": "^4.57.1",
108
+ "rollup-plugin-copy": "^3.5.0",
109
+ "rollup-plugin-flow": "^1.1.1",
110
+ "rollup-plugin-visualizer": "^5.12.0",
111
+ "ts-jest": "^29.1.1",
112
+ "typescript": "^5.7.3"
113
+ },
114
+ "engines": {
115
+ "node": "^20.0.0 || ^22.0.0"
116
+ },
117
+ "prettier": "prettier-config-hd"
118
+ }
package/rollup.config.mjs CHANGED
@@ -26,11 +26,6 @@ export default [
26
26
  format: 'cjs',
27
27
  interop: 'compat',
28
28
  },
29
- {
30
- file: pkg.module,
31
- format: 'es',
32
- interop: 'compat',
33
- },
34
29
  ],
35
30
  external: [
36
31
  '@react-native-masked-view/masked-view',
@@ -52,7 +47,7 @@ export default [
52
47
  replace({
53
48
  'process.env.NODE_ENV': JSON.stringify('production'),
54
49
  }),
55
- nodeResolve({ extensions, browser: true }),
50
+ nodeResolve({ extensions, browser: false }),
56
51
  flow(),
57
52
  commonjs(),
58
53
  json(),
@@ -68,11 +63,11 @@ export default [
68
63
  }),
69
64
  ...(generateBuildStats
70
65
  ? [
71
- visualizer({
72
- filename: fileName,
73
- template: bundleTemplate,
74
- }),
75
- ]
66
+ visualizer({
67
+ filename: fileName,
68
+ template: bundleTemplate,
69
+ }),
70
+ ]
76
71
  : []),
77
72
  ],
78
73
  },
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Publishes the Expo Snack flavour of `@hero-design/rn`:
3
+ * - version: `{version}-expo-snack`
4
+ * - no `react-native` field, so Metro/Snack resolves the built `lib/index.js`
5
+ * (`main`) instead of the TypeScript source (`src/index.ts`)
6
+ * - npm dist-tag `expo-snack`, so it never becomes `latest`
7
+ *
8
+ * Requires `lib/` to be built. Idempotent: does nothing if the version exists.
9
+ * Set DRY_RUN=true to only print the manifest that would be published.
10
+ */
11
+ const childProcess = require('child_process');
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+
15
+ const SNACK_DIST_TAG = 'expo-snack';
16
+
17
+ // Resolve npm next to the running node binary instead of searching PATH
18
+ const NPM_BIN = path.join(path.dirname(process.execPath), 'npm');
19
+
20
+ const getSnackVersion = (version) => `${version}-expo-snack`;
21
+
22
+ const buildSnackManifest = (pkg) => {
23
+ const { 'react-native': _reactNative, ...rest } = pkg;
24
+
25
+ return { ...rest, version: getSnackVersion(pkg.version) };
26
+ };
27
+
28
+ const versionExists = (name, version, runNpm) => {
29
+ try {
30
+ const output = runNpm(['view', `${name}@${version}`, 'version'], {
31
+ encoding: 'utf8',
32
+ stdio: ['ignore', 'pipe', 'ignore'],
33
+ });
34
+
35
+ return String(output).trim() === version;
36
+ } catch {
37
+ // `npm view` exits non-zero when the version does not exist
38
+ return false;
39
+ }
40
+ };
41
+
42
+ const publishExpoSnack = ({
43
+ packageJsonPath,
44
+ dryRun = false,
45
+ runNpm = (args, options) => childProcess.execFileSync(NPM_BIN, args, options),
46
+ log = console.log,
47
+ }) => {
48
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
49
+ const snackManifest = buildSnackManifest(pkg);
50
+ const snackVersion = snackManifest.version;
51
+
52
+ if (versionExists(pkg.name, snackVersion, runNpm)) {
53
+ log(`${pkg.name}@${snackVersion} already published, skipping`);
54
+
55
+ return 'skipped';
56
+ }
57
+
58
+ const backupPath = `${packageJsonPath}.bak`;
59
+ fs.copyFileSync(packageJsonPath, backupPath);
60
+
61
+ try {
62
+ fs.writeFileSync(
63
+ packageJsonPath,
64
+ `${JSON.stringify(snackManifest, null, 2)}\n`
65
+ );
66
+
67
+ if (dryRun) {
68
+ log(`DRY_RUN: would publish ${pkg.name}@${snackVersion}`);
69
+ log(
70
+ JSON.stringify(
71
+ {
72
+ name: snackManifest.name,
73
+ version: snackManifest.version,
74
+ main: snackManifest.main,
75
+ 'react-native': snackManifest['react-native'],
76
+ },
77
+ null,
78
+ 2
79
+ )
80
+ );
81
+
82
+ return 'dry-run';
83
+ }
84
+
85
+ runNpm(['publish', '--access', 'public', '--tag', SNACK_DIST_TAG], {
86
+ stdio: 'inherit',
87
+ });
88
+
89
+ return 'published';
90
+ } finally {
91
+ fs.copyFileSync(backupPath, packageJsonPath);
92
+ fs.rmSync(backupPath);
93
+ }
94
+ };
95
+
96
+ module.exports = {
97
+ buildSnackManifest,
98
+ getSnackVersion,
99
+ publishExpoSnack,
100
+ SNACK_DIST_TAG,
101
+ versionExists,
102
+ };
103
+
104
+ /* istanbul ignore next -- thin CLI wrapper */
105
+ if (require.main === module) {
106
+ publishExpoSnack({
107
+ packageJsonPath: path.resolve(__dirname, '../package.json'),
108
+ dryRun: process.env.DRY_RUN === 'true',
109
+ });
110
+ }
@@ -1,15 +1,24 @@
1
1
  import React, { useCallback, useMemo, useState } from 'react';
2
- import MultiSlider from '@ptomasroos/react-native-multi-slider';
3
2
 
4
3
  import type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
5
4
  import { View } from 'react-native';
5
+ import type MultiSliderComponent from '@ptomasroos/react-native-multi-slider';
6
6
  import { useTheme } from '../../theme';
7
+ import loadNativeComponent from '../../utils/loadNativeComponent';
7
8
  import { StyledMarker } from './StyledRangeSlider';
8
9
  import {
9
10
  DISABLED_UNSELECTED_TRACK_OPACITY,
10
11
  DISABLED_SELECTED_TRACK_OPACITY,
11
12
  } from './constants';
12
13
 
14
+ type MultiSliderProps = React.ComponentProps<typeof MultiSliderComponent>;
15
+
16
+ const MultiSlider = loadNativeComponent<MultiSliderProps>(
17
+ '@ptomasroos/react-native-multi-slider',
18
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
19
+ () => require('@ptomasroos/react-native-multi-slider')
20
+ );
21
+
13
22
  export type SliderRangeValue = {
14
23
  start: number;
15
24
  end: number;
@@ -1,7 +1,16 @@
1
- import RnSlider from '@react-native-community/slider';
2
1
  import React from 'react';
3
2
  import type { StyleProp, ViewStyle } from 'react-native';
3
+ import type RnSliderComponent from '@react-native-community/slider';
4
4
  import { useTheme } from '../../theme';
5
+ import loadNativeComponent from '../../utils/loadNativeComponent';
6
+
7
+ type RnSliderProps = React.ComponentProps<typeof RnSliderComponent>;
8
+
9
+ const SliderComponent = loadNativeComponent<RnSliderProps>(
10
+ '@react-native-community/slider',
11
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
12
+ () => require('@react-native-community/slider')
13
+ );
5
14
 
6
15
  export interface SingleSliderProps {
7
16
  /**
@@ -70,7 +79,7 @@ const Slider = ({
70
79
  const { selectedTrack, thumb, unselectedTrack } = theme.__hd__.slider.colors;
71
80
 
72
81
  return (
73
- <RnSlider
82
+ <SliderComponent
74
83
  minimumValue={minimumValue}
75
84
  maximumValue={maximumValue}
76
85
  step={step}