react-native-lumen 1.0.1 → 1.1.1

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.
Files changed (49) hide show
  1. package/README.md +770 -231
  2. package/lib/module/components/TourOverlay.js +45 -45
  3. package/lib/module/components/TourOverlay.js.map +1 -1
  4. package/lib/module/components/TourProvider.js +345 -80
  5. package/lib/module/components/TourProvider.js.map +1 -1
  6. package/lib/module/components/TourTooltip.js +113 -73
  7. package/lib/module/components/TourTooltip.js.map +1 -1
  8. package/lib/module/components/TourZone.js +229 -125
  9. package/lib/module/components/TourZone.js.map +1 -1
  10. package/lib/module/constants/defaults.js +43 -0
  11. package/lib/module/constants/defaults.js.map +1 -1
  12. package/lib/module/context/TourContext.js +5 -0
  13. package/lib/module/context/TourContext.js.map +1 -0
  14. package/lib/module/hooks/useTour.js +1 -1
  15. package/lib/module/hooks/useTour.js.map +1 -1
  16. package/lib/module/hooks/useTourScrollView.js +74 -0
  17. package/lib/module/hooks/useTourScrollView.js.map +1 -0
  18. package/lib/module/index.js +6 -0
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/utils/storage.js +188 -0
  21. package/lib/module/utils/storage.js.map +1 -0
  22. package/lib/typescript/src/components/TourOverlay.d.ts.map +1 -1
  23. package/lib/typescript/src/components/TourProvider.d.ts +21 -4
  24. package/lib/typescript/src/components/TourProvider.d.ts.map +1 -1
  25. package/lib/typescript/src/components/TourTooltip.d.ts.map +1 -1
  26. package/lib/typescript/src/components/TourZone.d.ts +19 -1
  27. package/lib/typescript/src/components/TourZone.d.ts.map +1 -1
  28. package/lib/typescript/src/constants/defaults.d.ts +10 -0
  29. package/lib/typescript/src/constants/defaults.d.ts.map +1 -1
  30. package/lib/typescript/src/context/TourContext.d.ts +3 -0
  31. package/lib/typescript/src/context/TourContext.d.ts.map +1 -0
  32. package/lib/typescript/src/hooks/useTourScrollView.d.ts +76 -0
  33. package/lib/typescript/src/hooks/useTourScrollView.d.ts.map +1 -0
  34. package/lib/typescript/src/index.d.ts +4 -0
  35. package/lib/typescript/src/index.d.ts.map +1 -1
  36. package/lib/typescript/src/types/index.d.ts +316 -1
  37. package/lib/typescript/src/types/index.d.ts.map +1 -1
  38. package/lib/typescript/src/utils/storage.d.ts +51 -0
  39. package/lib/typescript/src/utils/storage.d.ts.map +1 -0
  40. package/package.json +169 -171
  41. package/src/components/TourOverlay.tsx +0 -153
  42. package/src/components/TourProvider.tsx +0 -361
  43. package/src/components/TourTooltip.tsx +0 -256
  44. package/src/components/TourZone.tsx +0 -371
  45. package/src/constants/animations.ts +0 -71
  46. package/src/constants/defaults.ts +0 -15
  47. package/src/hooks/useTour.ts +0 -10
  48. package/src/index.tsx +0 -8
  49. package/src/types/index.ts +0 -142
package/package.json CHANGED
@@ -1,171 +1,169 @@
1
- {
2
- "name": "react-native-lumen",
3
- "version": "1.0.1",
4
- "description": "A customizable app tour library for React Native",
5
- "main": "./lib/module/index.js",
6
- "types": "./lib/typescript/src/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "source": "./src/index.tsx",
10
- "types": "./lib/typescript/src/index.d.ts",
11
- "default": "./lib/module/index.js"
12
- },
13
- "./package.json": "./package.json"
14
- },
15
- "files": [
16
- "src",
17
- "lib",
18
- "android",
19
- "ios",
20
- "cpp",
21
- "*.podspec",
22
- "react-native.config.js",
23
- "!ios/build",
24
- "!android/build",
25
- "!android/gradle",
26
- "!android/gradlew",
27
- "!android/gradlew.bat",
28
- "!android/local.properties",
29
- "!**/__tests__",
30
- "!**/__fixtures__",
31
- "!**/__mocks__",
32
- "!**/.*"
33
- ],
34
- "scripts": {
35
- "example": "yarn workspace react-native-lumen-example",
36
- "clean": "del-cli lib",
37
- "prepare": "bob build",
38
- "typecheck": "tsc",
39
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
- "test": "jest",
41
- "release": "release-it --only-version"
42
- },
43
- "keywords": [
44
- "react-native",
45
- "ios",
46
- "android"
47
- ],
48
- "repository": {
49
- "type": "git",
50
- "url": "git+https://github.com/thedev204/react-native-lumen.git"
51
- },
52
- "author": "thedev204 <116882323+thedev204@users.noreply.github.com> (https://github.com/thedev204)",
53
- "license": "MIT",
54
- "bugs": {
55
- "url": "https://github.com/thedev204/react-native-lumen/issues"
56
- },
57
- "homepage": "https://github.com/thedev204/react-native-lumen#readme",
58
- "publishConfig": {
59
- "registry": "https://registry.npmjs.org/"
60
- },
61
- "devDependencies": {
62
- "@commitlint/config-conventional": "^19.8.1",
63
- "@eslint/compat": "^1.3.2",
64
- "@eslint/eslintrc": "^3.3.1",
65
- "@eslint/js": "^9.35.0",
66
- "@react-native/babel-preset": "0.83.0",
67
- "@react-native/eslint-config": "0.83.0",
68
- "@release-it/conventional-changelog": "^10.0.1",
69
- "@types/jest": "^29.5.14",
70
- "@types/react": "^19.1.12",
71
- "commitlint": "^19.8.1",
72
- "del-cli": "^6.0.0",
73
- "eslint": "^9.39.2",
74
- "eslint-config-prettier": "^9.0.0",
75
- "eslint-plugin-prettier": "^5.0.0",
76
- "jest": "^29.7.0",
77
- "lefthook": "^2.0.3",
78
- "prettier": "^3.0.0",
79
- "react": "19.1.0",
80
- "react-native": "0.81.5",
81
- "react-native-builder-bob": "^0.40.13",
82
- "react-native-gesture-handler": "^2.16.0",
83
- "react-native-reanimated": "^3.0.0",
84
- "react-native-svg": "^12.0.0",
85
- "release-it": "^19.0.4",
86
- "typescript": "~5.7.0"
87
- },
88
- "peerDependencies": {
89
- "react": "*",
90
- "react-native": "*",
91
- "react-native-gesture-handler": ">=2.0.0",
92
- "react-native-reanimated": ">=3.0.0",
93
- "react-native-svg": ">=12.0.0",
94
- "react-native-worklets": ">=0.3.0"
95
- },
96
- "workspaces": [
97
- "example"
98
- ],
99
- "packageManager": "yarn@4.11.0",
100
- "react-native-builder-bob": {
101
- "source": "src",
102
- "output": "lib",
103
- "targets": [
104
- [
105
- "module",
106
- {
107
- "esm": true
108
- }
109
- ],
110
- [
111
- "typescript",
112
- {
113
- "project": "tsconfig.build.json"
114
- }
115
- ]
116
- ]
117
- },
118
- "prettier": {
119
- "quoteProps": "consistent",
120
- "singleQuote": true,
121
- "tabWidth": 2,
122
- "trailingComma": "es5",
123
- "useTabs": false
124
- },
125
- "jest": {
126
- "preset": "react-native",
127
- "modulePathIgnorePatterns": [
128
- "<rootDir>/example/node_modules",
129
- "<rootDir>/lib/"
130
- ]
131
- },
132
- "commitlint": {
133
- "extends": [
134
- "@commitlint/config-conventional"
135
- ]
136
- },
137
- "release-it": {
138
- "git": {
139
- "commitMessage": "chore: release ${version}",
140
- "tagName": "v${version}"
141
- },
142
- "npm": {
143
- "publish": true
144
- },
145
- "github": {
146
- "release": true
147
- },
148
- "plugins": {
149
- "@release-it/conventional-changelog": {
150
- "preset": {
151
- "name": "angular"
152
- }
153
- }
154
- }
155
- },
156
- "create-react-native-library": {
157
- "type": "library",
158
- "languages": "js",
159
- "tools": [
160
- "eslint",
161
- "jest",
162
- "lefthook",
163
- "release-it"
164
- ],
165
- "version": "0.57.0"
166
- },
167
- "resolutions": {
168
- "@types/react": "^19.1.12",
169
- "typescript": "5.7.3"
170
- }
171
- }
1
+ {
2
+ "name": "react-native-lumen",
3
+ "version": "1.1.1",
4
+ "description": "A customizable app tour library for React Native",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "*.podspec",
18
+ "react-native.config.js",
19
+ "!ios/build",
20
+ "!android/build",
21
+ "!android/gradle",
22
+ "!android/gradlew",
23
+ "!android/gradlew.bat",
24
+ "!android/local.properties",
25
+ "!**/__tests__",
26
+ "!**/__fixtures__",
27
+ "!**/__mocks__",
28
+ "!**/.*"
29
+ ],
30
+ "scripts": {
31
+ "example": "yarn workspace react-native-lumen-example",
32
+ "clean": "del-cli lib",
33
+ "prepare": "bob build",
34
+ "typecheck": "tsc",
35
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
36
+ "test": "jest",
37
+ "release": "release-it --only-version"
38
+ },
39
+ "keywords": [
40
+ "react-native",
41
+ "ios",
42
+ "android"
43
+ ],
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/thedev204/react-native-lumen.git"
47
+ },
48
+ "author": "thedev204 <116882323+thedev204@users.noreply.github.com> (https://github.com/thedev204)",
49
+ "license": "MIT",
50
+ "bugs": {
51
+ "url": "https://github.com/thedev204/react-native-lumen/issues"
52
+ },
53
+ "homepage": "https://github.com/thedev204/react-native-lumen#readme",
54
+ "publishConfig": {
55
+ "registry": "https://registry.npmjs.org/"
56
+ },
57
+ "devDependencies": {
58
+ "@commitlint/config-conventional": "^19.8.1",
59
+ "@eslint/compat": "^1.3.2",
60
+ "@eslint/eslintrc": "^3.3.1",
61
+ "@eslint/js": "^9.35.0",
62
+ "@react-native/babel-preset": "0.83.0",
63
+ "@react-native/eslint-config": "0.83.0",
64
+ "@release-it/conventional-changelog": "^10.0.1",
65
+ "@types/jest": "^29.5.14",
66
+ "@types/react": "^19.1.12",
67
+ "commitlint": "^19.8.1",
68
+ "del-cli": "^6.0.0",
69
+ "eslint": "^9.39.2",
70
+ "eslint-config-prettier": "^9.0.0",
71
+ "eslint-plugin-ft-flow": "^3.0.11",
72
+ "eslint-plugin-prettier": "^5.0.0",
73
+ "eslint-plugin-react-native": "^5.0.0",
74
+ "jest": "^29.7.0",
75
+ "lefthook": "^2.0.3",
76
+ "prettier": "^3.0.0",
77
+ "react": "19.1.0",
78
+ "react-native": "0.81.5",
79
+ "react-native-builder-bob": "^0.40.13",
80
+ "react-native-gesture-handler": "^2.16.0",
81
+ "react-native-reanimated": "^3.0.0",
82
+ "react-native-svg": "^12.0.0",
83
+ "release-it": "^19.0.4",
84
+ "typescript": "~5.7.0"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "*",
88
+ "react-native": "*",
89
+ "react-native-gesture-handler": ">=2.0.0",
90
+ "react-native-reanimated": ">=3.0.0",
91
+ "react-native-svg": ">=12.0.0",
92
+ "react-native-worklets": ">=0.3.0"
93
+ },
94
+ "workspaces": [
95
+ "example"
96
+ ],
97
+ "packageManager": "yarn@4.11.0",
98
+ "react-native-builder-bob": {
99
+ "source": "src",
100
+ "output": "lib",
101
+ "targets": [
102
+ [
103
+ "module",
104
+ {
105
+ "esm": true
106
+ }
107
+ ],
108
+ [
109
+ "typescript",
110
+ {
111
+ "project": "tsconfig.build.json"
112
+ }
113
+ ]
114
+ ]
115
+ },
116
+ "prettier": {
117
+ "quoteProps": "consistent",
118
+ "singleQuote": true,
119
+ "tabWidth": 2,
120
+ "trailingComma": "es5",
121
+ "useTabs": false
122
+ },
123
+ "jest": {
124
+ "preset": "react-native",
125
+ "modulePathIgnorePatterns": [
126
+ "<rootDir>/example/node_modules",
127
+ "<rootDir>/lib/"
128
+ ]
129
+ },
130
+ "commitlint": {
131
+ "extends": [
132
+ "@commitlint/config-conventional"
133
+ ]
134
+ },
135
+ "release-it": {
136
+ "git": {
137
+ "commitMessage": "chore: release ${version}",
138
+ "tagName": "v${version}"
139
+ },
140
+ "npm": {
141
+ "publish": true
142
+ },
143
+ "github": {
144
+ "release": true
145
+ },
146
+ "plugins": {
147
+ "@release-it/conventional-changelog": {
148
+ "preset": {
149
+ "name": "angular"
150
+ }
151
+ }
152
+ }
153
+ },
154
+ "create-react-native-library": {
155
+ "type": "library",
156
+ "languages": "js",
157
+ "tools": [
158
+ "eslint",
159
+ "jest",
160
+ "lefthook",
161
+ "release-it"
162
+ ],
163
+ "version": "0.57.0"
164
+ },
165
+ "resolutions": {
166
+ "@types/react": "^19.1.12",
167
+ "typescript": "5.7.3"
168
+ }
169
+ }
@@ -1,153 +0,0 @@
1
- import { memo, type ComponentType } from 'react';
2
- import { StyleSheet, Dimensions } from 'react-native';
3
- import Svg, { Path } from 'react-native-svg';
4
- import Animated, {
5
- useAnimatedProps,
6
- useAnimatedStyle,
7
- } from 'react-native-reanimated';
8
- import { useTour } from '../hooks/useTour';
9
- import type { InternalTourContextType } from '../types';
10
-
11
- const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window');
12
-
13
- const AnimatedPath = Animated.createAnimatedComponent(Path);
14
- const AnimatedView = Animated.View as unknown as ComponentType<any>;
15
-
16
- // Helper to create rounded rect path
17
- // x,y are top-left coordinates
18
- const createRoundedRectPath = (
19
- x: number,
20
- y: number,
21
- w: number,
22
- h: number,
23
- r: number
24
- ) => {
25
- 'worklet';
26
- // Ensure radius doesn't exceed dimensions
27
- const radius = Math.min(r, w / 2, h / 2);
28
-
29
- // Standard SVG Path command for rounded rect
30
- return `
31
- M ${x + radius}, ${y}
32
- H ${x + w - radius}
33
- A ${radius} ${radius} 0 0 1 ${x + w}, ${y + radius}
34
- V ${y + h - radius}
35
- A ${radius} ${radius} 0 0 1 ${x + w - radius}, ${y + h}
36
- H ${x + radius}
37
- A ${radius} ${radius} 0 0 1 ${x}, ${y + h - radius}
38
- V ${y + radius}
39
- A ${radius} ${radius} 0 0 1 ${x + radius}, ${y}
40
- Z
41
- `;
42
- };
43
-
44
- export const TourOverlay = memo(() => {
45
- const {
46
- targetX,
47
- targetY,
48
- targetWidth,
49
- targetHeight,
50
- targetRadius,
51
- opacity,
52
- config,
53
- currentStep,
54
- steps,
55
- } = useTour() as InternalTourContextType;
56
-
57
- // Create the d string for the mask
58
- // Outer rectangle covers the whole screen
59
- // Inner shape is the "hole"
60
- // fillRule="evenodd" makes the intersection transparent
61
- const animatedProps = useAnimatedProps(() => {
62
- const holePath = createRoundedRectPath(
63
- targetX.value,
64
- targetY.value,
65
- targetWidth.value,
66
- targetHeight.value,
67
- targetRadius.value
68
- );
69
-
70
- const path = `
71
- M 0,0
72
- H ${SCREEN_WIDTH}
73
- V ${SCREEN_HEIGHT}
74
- H 0
75
- Z
76
- ${holePath}
77
- `;
78
-
79
- return {
80
- d: path,
81
- fillOpacity: opacity.value,
82
- };
83
- });
84
-
85
- const step = currentStep ? steps[currentStep] : null;
86
- const isClickable = step?.clickable ?? false;
87
-
88
- // Interaction Logic:
89
- // 1. preventInteraction = true:
90
- // - Wrapper pointerEvents = 'box-none' (pass through) BUT SVG is auto?
91
- // - Actually, if we want to block OUTSIDE but allow INSIDE:
92
- // - SVG path normally blocks where it draws (the dark part).
93
- // - The 'hole' is empty, so touches pass through the hole to the app?
94
- // - YES, with fillRule="evenodd", the hole effectively has no fill.
95
- // - So if SVG is 'auto', touching the dark mask is blocked (if we consume touch).
96
- // - Touching the hole goes through to the app (GOOD for clickable).
97
- // - IF we want to BLOCK the hole (clickable=false):
98
- // - We need a transparent view covering the hole that consumes touches.
99
- //
100
- // 2. preventInteraction = false (default):
101
- // - Overlay shouldn't block anything?
102
- // - pointerEvents='none' on the whole container.
103
-
104
- const shouldBlockOutside = config?.preventInteraction ?? false;
105
-
106
- // If we don't want to block outside, we just let everything pass.
107
- // But wait, if we let everything pass, we can't implement 'clickable=false' strictness?
108
- // Usually preventInteraction=false means "just show the highlighter, let user do whatever".
109
-
110
- const containerPointerEvents =
111
- shouldBlockOutside && currentStep ? 'box-none' : 'none';
112
-
113
- // If blocking outside, the SVG (which is absolute fill) needs to catch touches on the dark part.
114
-
115
- // Blocker style for the hole (only if NOT clickable)
116
- const blockerStyle = useAnimatedStyle(() => {
117
- return {
118
- position: 'absolute',
119
- left: targetX.value,
120
- top: targetY.value,
121
- width: targetWidth.value,
122
- height: targetHeight.value,
123
- // We can match radius too if needed, but rect is fine for touch area usually
124
- borderRadius: targetRadius.value,
125
- };
126
- });
127
-
128
- return (
129
- <AnimatedView
130
- pointerEvents={containerPointerEvents}
131
- style={StyleSheet.absoluteFill}
132
- >
133
- <Svg height="100%" width="100%" style={StyleSheet.absoluteFill}>
134
- <AnimatedPath
135
- animatedProps={animatedProps as any}
136
- fill="black" // The backdrop color
137
- fillRule="evenodd"
138
- onPress={() => {
139
- // Consume touch on the backdrop?
140
- }}
141
- />
142
- </Svg>
143
- {/* If strictly blocking interaction AND current step is NOT clickable, we cover the hole */}
144
- {shouldBlockOutside && !isClickable && currentStep && (
145
- <AnimatedView
146
- style={blockerStyle}
147
- pointerEvents="auto" // Catch touches
148
- // backgroundColor="transparent" // Default
149
- />
150
- )}
151
- </AnimatedView>
152
- );
153
- });