@quantaroute/checkout 1.1.1 → 1.2.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.
@@ -1,4 +1,3 @@
1
- import { CSSProperties } from 'react';
2
1
  import { default as default_2 } from 'react';
3
2
 
4
3
  /**
@@ -49,6 +48,8 @@ export declare interface AdministrativeInfo {
49
48
  max_population_density?: number;
50
49
  }
51
50
 
51
+ declare type AnyStyle = any;
52
+
52
53
  /**
53
54
  * QuantaRoute Checkout Widget
54
55
  *
@@ -81,12 +82,12 @@ export declare interface CheckoutWidgetProps {
81
82
  defaultLng?: number;
82
83
  /** Color theme. Defaults to 'light'. */
83
84
  theme?: 'light' | 'dark';
84
- /** CSS class name(s) to add to the root element. */
85
+ /** CSS class name(s) to add to the root element (web only). */
85
86
  className?: string;
86
- /** Inline styles for the root element. */
87
- style?: CSSProperties;
88
- /** Map area height. Defaults to '380px'. */
89
- mapHeight?: string;
87
+ /** Inline styles for the root element (CSSProperties on web, StyleProp<ViewStyle> on native). */
88
+ style?: AnyStyle;
89
+ /** Map area height. String on web ('380px'), number on native (380). Defaults to '380px' / 380. */
90
+ mapHeight?: string | number;
90
91
  /** Widget header title. Defaults to 'Add Delivery Address'. */
91
92
  title?: string;
92
93
  /**
@@ -211,7 +212,8 @@ export declare interface MapPinSelectorProps {
211
212
  onLocationConfirm: (lat: number, lng: number, digipin: string) => void;
212
213
  defaultLat?: number;
213
214
  defaultLng?: number;
214
- mapHeight?: string;
215
+ /** Map height. String on web ('380px'), number on native (380). */
216
+ mapHeight?: string | number;
215
217
  theme?: 'light' | 'dark';
216
218
  /**
217
219
  * URL to an India boundary GeoJSON file (FeatureCollection).
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @quantaroute/checkout v1.1.1
2
+ * @quantaroute/checkout v1.2.0
3
3
  * (c) 2026 QuantaRoute – https://quantaroute.com
4
4
  * Released under the MIT License.
5
5
  *
@@ -7,10 +7,16 @@
7
7
  * (Apache 2.0 – © India Post, IIT Hyderabad, ISRO NRSC)
8
8
  * https://github.com/INDIAPOST-gov/digipin
9
9
  *
10
- * Peer dependencies (install separately):
11
- * react >= 18.2.0
10
+ * Web peer dependencies (install separately):
11
+ * react >= 18.0.0
12
12
  * react-dom >= 18.2.0
13
13
  * maplibre-gl >= 4.0.0
14
+ *
15
+ * Native peer dependencies (Expo / React Native):
16
+ * react-native >= 0.72.0
17
+ * expo >= 49.0.0
18
+ * expo-osm-sdk >= 2.0.0
19
+ * expo-location >= 17.0.0
14
20
  */
15
21
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
16
22
  import { useState, useCallback, useRef, useEffect, useReducer, useMemo } from "react";
@@ -1,7 +1,7 @@
1
1
  !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react/jsx-runtime"),require("react"),require("maplibre-gl")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","maplibre-gl"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).QuantaRouteCheckout={},e.ReactJSXRuntime,e.React,e.maplibregl)}(this,function(e,r,a,n){"use strict"
2
2
 
3
3
  ;/*!
4
- * @quantaroute/checkout v1.1.1
4
+ * @quantaroute/checkout v1.2.0
5
5
  * (c) 2026 QuantaRoute – https://quantaroute.com
6
6
  * Released under the MIT License.
7
7
  *
@@ -9,10 +9,16 @@
9
9
  * (Apache 2.0 – © India Post, IIT Hyderabad, ISRO NRSC)
10
10
  * https://github.com/INDIAPOST-gov/digipin
11
11
  *
12
- * Peer dependencies (install separately):
13
- * react >= 18.2.0
12
+ * Web peer dependencies (install separately):
13
+ * react >= 18.0.0
14
14
  * react-dom >= 18.2.0
15
15
  * maplibre-gl >= 4.0.0
16
+ *
17
+ * Native peer dependencies (Expo / React Native):
18
+ * react-native >= 0.72.0
19
+ * expo >= 49.0.0
20
+ * expo-osm-sdk >= 2.0.0
21
+ * expo-location >= 17.0.0
16
22
  */const t=[["F","C","9","8"],["J","3","2","7"],["K","4","5","6"],["L","M","P","T"]],i={minLat:2.5,maxLat:38.5,minLon:63.5,maxLon:99.5}
17
23
  function o(e,r){if(e<i.minLat||e>i.maxLat)throw new Error(`Latitude ${e} out of range. Must be between ${i.minLat} and ${i.maxLat}`)
18
24
  if(r<i.minLon||r>i.maxLon)throw new Error(`Longitude ${r} out of range. Must be between ${i.minLon} and ${i.maxLon}`)
package/expo-plugin.js ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @quantaroute/checkout — Expo Config Plugin
3
+ *
4
+ * Wires up all native permissions and native modules needed by the
5
+ * checkout widget in one step. Add this to your app.json:
6
+ *
7
+ * "plugins": [
8
+ * ["@quantaroute/checkout/plugin", {
9
+ * "locationPermissionText": "Used to place your delivery pin on the map"
10
+ * }]
11
+ * ]
12
+ *
13
+ * This plugin internally applies:
14
+ * • expo-osm-sdk/plugin → MapLibre GL native map (iOS/Android)
15
+ * • expo-location → GPS location permission
16
+ * • Android manifest → INTERNET + ACCESS_FINE_LOCATION permissions
17
+ * • iOS Info.plist → NSLocationWhenInUseUsageDescription
18
+ *
19
+ * @param {object} [options]
20
+ * @param {string} [options.locationPermissionText] - Custom permission text shown to the user.
21
+ * Defaults to a sensible delivery-address copy.
22
+ */
23
+
24
+ const { withAndroidManifest, withInfoPlist, withPlugins } = require('@expo/config-plugins');
25
+
26
+ const DEFAULT_LOCATION_TEXT =
27
+ 'Allow access to your location to place the delivery pin accurately on the map.';
28
+
29
+ // ─── Android helper ───────────────────────────────────────────────────────────
30
+
31
+ function ensurePermission(manifest, name) {
32
+ if (!manifest['uses-permission']) {
33
+ manifest['uses-permission'] = [];
34
+ }
35
+ const exists = manifest['uses-permission'].some(
36
+ (p) => p.$?.['android:name'] === name
37
+ );
38
+ if (!exists) {
39
+ manifest['uses-permission'].push({ $: { 'android:name': name } });
40
+ }
41
+ return manifest;
42
+ }
43
+
44
+ const withAndroidPermissions = (config) =>
45
+ withAndroidManifest(config, (cfg) => {
46
+ const m = cfg.modResults.manifest;
47
+ ensurePermission(m, 'android.permission.INTERNET');
48
+ ensurePermission(m, 'android.permission.ACCESS_FINE_LOCATION');
49
+ ensurePermission(m, 'android.permission.ACCESS_COARSE_LOCATION');
50
+ return cfg;
51
+ });
52
+
53
+ // ─── iOS helper ───────────────────────────────────────────────────────────────
54
+
55
+ const withIosPermissions = (config, { locationPermissionText }) =>
56
+ withInfoPlist(config, (cfg) => {
57
+ if (!cfg.modResults.NSLocationWhenInUseUsageDescription) {
58
+ cfg.modResults.NSLocationWhenInUseUsageDescription = locationPermissionText;
59
+ }
60
+ return cfg;
61
+ });
62
+
63
+ // ─── Main plugin ──────────────────────────────────────────────────────────────
64
+
65
+ const withQuantaRouteCheckout = (config, options = {}) => {
66
+ const locationPermissionText =
67
+ options.locationPermissionText ?? DEFAULT_LOCATION_TEXT;
68
+
69
+ return withPlugins(config, [
70
+ // 1. Apply expo-osm-sdk plugin (MapLibre GL native maps)
71
+ (cfg) => {
72
+ try {
73
+ const osmPlugin = require('expo-osm-sdk/plugin');
74
+ return osmPlugin(cfg, { locationPermissionText });
75
+ } catch {
76
+ console.warn(
77
+ '[@quantaroute/checkout] expo-osm-sdk/plugin not found. ' +
78
+ 'Make sure expo-osm-sdk is installed: npm install expo-osm-sdk'
79
+ );
80
+ return cfg;
81
+ }
82
+ },
83
+
84
+ // 2. Apply expo-location plugin (GPS location API)
85
+ (cfg) => {
86
+ try {
87
+ const locationPlugin = require('expo-location/build/ExpoLocationPlugin');
88
+ return locationPlugin(cfg, { locationAlwaysAndWhenInUsePermission: locationPermissionText });
89
+ } catch {
90
+ try {
91
+ // Fallback: expo-location ships its plugin at a different path in some versions
92
+ const mod = require('expo-location');
93
+ if (mod.withLocation) return mod.withLocation(cfg);
94
+ } catch {
95
+ // Silent: expo-location permissions are handled by withIosPermissions below
96
+ }
97
+ return cfg;
98
+ }
99
+ },
100
+
101
+ // 3. Ensure Android permissions (belt-and-suspenders on top of the above)
102
+ (cfg) => withAndroidPermissions(cfg),
103
+
104
+ // 4. Ensure iOS Info.plist key (belt-and-suspenders)
105
+ (cfg) => withIosPermissions(cfg, { locationPermissionText }),
106
+ ]);
107
+ };
108
+
109
+ module.exports = withQuantaRouteCheckout;
package/package.json CHANGED
@@ -1,21 +1,30 @@
1
1
  {
2
2
  "name": "@quantaroute/checkout",
3
- "version": "1.1.1",
4
- "description": "Embeddable DigiPin-powered smart address checkout widget for Indian e-commerce",
3
+ "version": "1.2.0",
4
+ "description": "Embeddable DigiPin-powered smart address checkout widget React (web), React Native & Expo (iOS/Android)",
5
5
  "main": "./dist/lib/quantaroute-checkout.umd.js",
6
6
  "module": "./dist/lib/quantaroute-checkout.es.js",
7
7
  "types": "./dist/lib/index.d.ts",
8
+ "source": "src/index.ts",
9
+ "react-native": "src/index.ts",
8
10
  "exports": {
9
11
  ".": {
12
+ "types": "./dist/lib/index.d.ts",
13
+ "react-native": "./src/index.ts",
10
14
  "import": "./dist/lib/quantaroute-checkout.es.js",
11
- "require": "./dist/lib/quantaroute-checkout.umd.js",
12
- "types": "./dist/lib/index.d.ts"
15
+ "require": "./dist/lib/quantaroute-checkout.umd.js"
16
+ },
17
+ "./plugin": {
18
+ "default": "./expo-plugin.js"
13
19
  },
14
20
  "./style.css": "./dist/style.css"
15
21
  },
16
22
  "files": [
23
+ "src",
17
24
  "dist/lib",
18
25
  "dist/style.css",
26
+ "expo-plugin.js",
27
+ "babel.config.js",
19
28
  "README.md",
20
29
  "LICENSE"
21
30
  ],
@@ -26,6 +35,7 @@
26
35
  "build:demo": "vite build",
27
36
  "preview": "vite preview --outDir dist/demo",
28
37
  "type-check": "tsc --noEmit",
38
+ "type-check:native": "tsc --project tsconfig.native.json --noEmit",
29
39
  "prepublishOnly": "npm run type-check && npm run build:lib"
30
40
  },
31
41
  "keywords": [
@@ -36,6 +46,10 @@
36
46
  "geocoding",
37
47
  "maplibre",
38
48
  "react",
49
+ "react-native",
50
+ "expo",
51
+ "ios",
52
+ "android",
39
53
  "ecommerce",
40
54
  "india-post",
41
55
  "address-autocomplete",
@@ -63,30 +77,53 @@
63
77
  "npm": ">=10.0.0"
64
78
  },
65
79
  "peerDependencies": {
80
+ "@expo/config-plugins": ">=7.0.0",
81
+ "expo": ">=49.0.0",
82
+ "expo-location": ">=17.0.0",
83
+ "expo-osm-sdk": ">=2.0.0",
66
84
  "maplibre-gl": ">=4.0.0",
67
- "react": ">=18.2.0",
68
- "react-dom": ">=18.2.0"
85
+ "react": ">=18.0.0",
86
+ "react-dom": ">=18.2.0",
87
+ "react-native": ">=0.72.0"
69
88
  },
70
89
  "peerDependenciesMeta": {
90
+ "@expo/config-plugins": {
91
+ "optional": true
92
+ },
71
93
  "react": {
72
94
  "optional": false
73
95
  },
74
96
  "react-dom": {
75
- "optional": false
97
+ "optional": true
76
98
  },
77
99
  "maplibre-gl": {
78
- "optional": false
100
+ "optional": true
101
+ },
102
+ "react-native": {
103
+ "optional": true
104
+ },
105
+ "expo": {
106
+ "optional": true
107
+ },
108
+ "expo-osm-sdk": {
109
+ "optional": true
110
+ },
111
+ "expo-location": {
112
+ "optional": true
79
113
  }
80
114
  },
81
- "dependencies": {},
82
115
  "devDependencies": {
83
- "@quantaroute/checkout": "^1.1.1",
116
+ "@expo/config-plugins": "^54.0.4",
84
117
  "@types/react": "^18.3.12",
85
118
  "@types/react-dom": "^18.3.1",
119
+ "@types/react-native": "^0.73.0",
86
120
  "@vitejs/plugin-react": "^4.3.4",
121
+ "expo-location": "^18.1.6",
122
+ "expo-osm-sdk": "^2.0.0",
87
123
  "maplibre-gl": "^4.7.1",
88
124
  "react": "^18.3.1",
89
125
  "react-dom": "^18.3.1",
126
+ "react-native": "^0.73.11",
90
127
  "terser": "^5.46.0",
91
128
  "typescript": "^5.6.3",
92
129
  "vite": "^5.4.11",