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.
- package/README.md +770 -231
- package/lib/module/components/TourOverlay.js +45 -45
- package/lib/module/components/TourOverlay.js.map +1 -1
- package/lib/module/components/TourProvider.js +345 -80
- package/lib/module/components/TourProvider.js.map +1 -1
- package/lib/module/components/TourTooltip.js +113 -73
- package/lib/module/components/TourTooltip.js.map +1 -1
- package/lib/module/components/TourZone.js +229 -125
- package/lib/module/components/TourZone.js.map +1 -1
- package/lib/module/constants/defaults.js +43 -0
- package/lib/module/constants/defaults.js.map +1 -1
- package/lib/module/context/TourContext.js +5 -0
- package/lib/module/context/TourContext.js.map +1 -0
- package/lib/module/hooks/useTour.js +1 -1
- package/lib/module/hooks/useTour.js.map +1 -1
- package/lib/module/hooks/useTourScrollView.js +74 -0
- package/lib/module/hooks/useTourScrollView.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/storage.js +188 -0
- package/lib/module/utils/storage.js.map +1 -0
- package/lib/typescript/src/components/TourOverlay.d.ts.map +1 -1
- package/lib/typescript/src/components/TourProvider.d.ts +21 -4
- package/lib/typescript/src/components/TourProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/TourTooltip.d.ts.map +1 -1
- package/lib/typescript/src/components/TourZone.d.ts +19 -1
- package/lib/typescript/src/components/TourZone.d.ts.map +1 -1
- package/lib/typescript/src/constants/defaults.d.ts +10 -0
- package/lib/typescript/src/constants/defaults.d.ts.map +1 -1
- package/lib/typescript/src/context/TourContext.d.ts +3 -0
- package/lib/typescript/src/context/TourContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts +76 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +316 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/storage.d.ts +51 -0
- package/lib/typescript/src/utils/storage.d.ts.map +1 -0
- package/package.json +169 -171
- package/src/components/TourOverlay.tsx +0 -153
- package/src/components/TourProvider.tsx +0 -361
- package/src/components/TourTooltip.tsx +0 -256
- package/src/components/TourZone.tsx +0 -371
- package/src/constants/animations.ts +0 -71
- package/src/constants/defaults.ts +0 -15
- package/src/hooks/useTour.ts +0 -10
- package/src/index.tsx +0 -8
- package/src/types/index.ts +0 -142
package/package.json
CHANGED
|
@@ -1,171 +1,169 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-native-lumen",
|
|
3
|
-
"version": "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
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"ios",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"!
|
|
24
|
-
"!android/
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
},
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"@
|
|
63
|
-
"@eslint
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@react
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"eslint": "^
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"react": "
|
|
80
|
-
"react-native": "
|
|
81
|
-
"react-native-
|
|
82
|
-
"react-native-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"react": "
|
|
90
|
-
"react-native": "
|
|
91
|
-
"react-native-
|
|
92
|
-
"react-native-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
});
|