rasp-feedback 1.0.8 → 1.1.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAMlD,OAAO,cAAc,CAAA;AAUrB,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAC;QAChB,GAAG,CAAC,EAAC,MAAM,CAAC;QACZ,IAAI,CAAC,EAAC,MAAM,CAAA;KACb,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAKD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAsfpD,CAAA"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
{ /*@ts-ignore*/ }
|
|
5
|
+
import { usePathname } from 'next/navigation';
|
|
6
|
+
{ /*@ts-ignore*/ }
|
|
5
7
|
import { getFormByRoute, getBrandTheme, getFormTheme, getBoardPosts, upvoteBoardPost, downvoteBoardPost, getPreloadRoutes, matchRouteClientSide } from '../functions/functionsexp';
|
|
6
8
|
import "../index.css";
|
|
7
9
|
import StaticFormComponent from './StaticFormComponent';
|
|
@@ -30,6 +32,8 @@ export const RaspProvider = ({ children, launcherPosition }) => {
|
|
|
30
32
|
const [showContent, setShowContent] = useState(false);
|
|
31
33
|
const [launcherContent, setLauncherContent] = useState('hidden');
|
|
32
34
|
const [parentColor, setParentColor] = useState("transparent");
|
|
35
|
+
// Track current pathname from Next.js router - updates on navigation
|
|
36
|
+
const pathname = usePathname();
|
|
33
37
|
const getForm = async () => {
|
|
34
38
|
setIsLoading(true);
|
|
35
39
|
setLauncherContent('loading');
|
|
@@ -101,74 +105,77 @@ export const RaspProvider = ({ children, launcherPosition }) => {
|
|
|
101
105
|
// If vote fails, localStorage won't be set, so user can retry
|
|
102
106
|
}
|
|
103
107
|
}
|
|
108
|
+
// Initialize companyId once on mount
|
|
104
109
|
useEffect(() => {
|
|
105
110
|
if (typeof window !== 'undefined') {
|
|
106
111
|
const id = process.env.NEXT_PUBLIC_RASP_COMPANY_ID;
|
|
107
|
-
const path = window.location.pathname;
|
|
108
112
|
setCompanyId(id);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
}
|
|
114
|
+
}, []);
|
|
115
|
+
// Check preload routes whenever pathname changes
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!companyId || !pathname)
|
|
118
|
+
return;
|
|
119
|
+
//console.log('[RaspProvider] Route changed to:', pathname);
|
|
120
|
+
// Reset to hidden at start of check to prevent flash
|
|
121
|
+
setLauncherContent('hidden');
|
|
122
|
+
setCurrentUrl(pathname);
|
|
123
|
+
getPreloadRoutes(companyId).then((preloadRoutes) => {
|
|
124
|
+
// No preloadRoutes configured — always show launcher on all routes
|
|
125
|
+
if (!preloadRoutes || !preloadRoutes.routePatterns || preloadRoutes.routePatterns.length === 0) {
|
|
126
|
+
console.log('[RaspProvider] No preload routes configured - showing launcher everywhere');
|
|
112
127
|
setLauncherContent('launcher');
|
|
113
128
|
return;
|
|
114
129
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
let patternPath;
|
|
134
|
-
try {
|
|
135
|
-
// Extract pathname from full URL patterns (e.g., "http://localhost:3000/blog/:slug/:slug/")
|
|
136
|
-
if (pattern.startsWith('http://') || pattern.startsWith('https://')) {
|
|
137
|
-
const url = new URL(pattern);
|
|
138
|
-
patternPath = url.pathname;
|
|
139
|
-
console.log(`[RaspProvider] → Extracted pathname: "${patternPath}"`);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
// Pattern is already just a path
|
|
143
|
-
patternPath = pattern;
|
|
144
|
-
console.log(`[RaspProvider] → Already a path: "${patternPath}"`);
|
|
145
|
-
}
|
|
146
|
-
const normalizedPattern = normalizePath(patternPath);
|
|
147
|
-
console.log(`[RaspProvider] → Normalized: "${normalizedPattern}"`);
|
|
148
|
-
const result = matchRouteClientSide(normalizedPath, normalizedPattern);
|
|
149
|
-
console.log(`[RaspProvider] Testing: "${normalizedPath}" vs "${normalizedPattern}" → ${result.matched ? '✓ MATCH' : '✗ no match'}`, result.params);
|
|
150
|
-
return result.matched;
|
|
130
|
+
//console.log('[RaspProvider] Current path:', pathname);
|
|
131
|
+
//console.log('[RaspProvider] Configured patterns (raw from DB):', preloadRoutes.routePatterns);
|
|
132
|
+
// Normalize path helper (ensure leading /, remove trailing / except root)
|
|
133
|
+
const normalizePath = (p) => {
|
|
134
|
+
const withLeading = p.startsWith('/') ? p : '/' + p;
|
|
135
|
+
return withLeading === '/' ? '/' : withLeading.replace(/\/$/, '');
|
|
136
|
+
};
|
|
137
|
+
const normalizedPath = normalizePath(pathname);
|
|
138
|
+
// Check each pattern to see if current path matches
|
|
139
|
+
const matchedPattern = preloadRoutes.routePatterns.find((pattern) => {
|
|
140
|
+
//console.log('[RaspProvider] Processing pattern:', pattern);
|
|
141
|
+
let patternPath;
|
|
142
|
+
try {
|
|
143
|
+
// Extract pathname from full URL patterns (e.g., "http://localhost:3000/blog/:slug/:slug/")
|
|
144
|
+
if (pattern.startsWith('http://') || pattern.startsWith('https://')) {
|
|
145
|
+
const url = new URL(pattern);
|
|
146
|
+
patternPath = url.pathname;
|
|
147
|
+
//console.log(`[RaspProvider] → Extracted pathname: "${patternPath}"`);
|
|
151
148
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
else {
|
|
150
|
+
// Pattern is already just a path
|
|
151
|
+
patternPath = pattern;
|
|
152
|
+
//console.log(`[RaspProvider] → Already a path: "${patternPath}"`);
|
|
155
153
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
const normalizedPattern = normalizePath(patternPath);
|
|
155
|
+
//console.log(`[RaspProvider] → Normalized: "${normalizedPattern}"`);
|
|
156
|
+
const result = matchRouteClientSide(normalizedPath, normalizedPattern);
|
|
157
|
+
//console.log(`[RaspProvider] Testing: "${normalizedPath}" vs "${normalizedPattern}" → ${result.matched ? '✓ MATCH' : '✗ no match'}`, result.params);
|
|
158
|
+
return result.matched;
|
|
160
159
|
}
|
|
161
|
-
|
|
162
|
-
console.
|
|
163
|
-
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error('[RaspProvider] Error parsing pattern:', pattern, error);
|
|
162
|
+
return false;
|
|
164
163
|
}
|
|
165
|
-
}).catch((error) => {
|
|
166
|
-
console.error('[RaspProvider] Error fetching preload routes:', error);
|
|
167
|
-
// If the preload fetch fails, default to showing the launcher
|
|
168
|
-
setLauncherContent('launcher');
|
|
169
164
|
});
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
if (matchedPattern) {
|
|
166
|
+
//console.log('[RaspProvider] ✓ Matched pattern:', matchedPattern, '- showing launcher');
|
|
167
|
+
setLauncherContent('launcher');
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
//console.log('[RaspProvider] ✗ No pattern matched - hiding launcher');
|
|
171
|
+
// stays 'hidden'
|
|
172
|
+
}
|
|
173
|
+
}).catch((error) => {
|
|
174
|
+
console.error('[RaspProvider] Error fetching preload routes:', error);
|
|
175
|
+
// If the preload fetch fails, default to showing the launcher
|
|
176
|
+
setLauncherContent('launcher');
|
|
177
|
+
});
|
|
178
|
+
}, [pathname, companyId]); // Re-run whenever pathname or companyId changes
|
|
172
179
|
useEffect(() => {
|
|
173
180
|
if (companyId) {
|
|
174
181
|
if (form) {
|
|
@@ -221,7 +228,7 @@ export const RaspProvider = ({ children, launcherPosition }) => {
|
|
|
221
228
|
display: 'flex',
|
|
222
229
|
flexDirection: "column",
|
|
223
230
|
justifyContent: 'center',
|
|
224
|
-
backgroundColor: "
|
|
231
|
+
backgroundColor: "white",
|
|
225
232
|
margin: '1.25rem',
|
|
226
233
|
width: '350px',
|
|
227
234
|
height: '200px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticFormComponent.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/StaticFormComponent.tsx"],"names":[],"mappings":"AAWA,iBAAS,mBAAmB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAqB,EAAE,cAAc,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IACxH,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,aAAa,EAAC,GAAG,CAAC;IAClB,eAAe,CAAC,EAAC,OAAO,CAAC;IACzB,cAAc,CAAC,EAAC,GAAG,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"StaticFormComponent.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/StaticFormComponent.tsx"],"names":[],"mappings":"AAWA,iBAAS,mBAAmB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAqB,EAAE,cAAc,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IACxH,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,aAAa,EAAC,GAAG,CAAC;IAClB,eAAe,CAAC,EAAC,OAAO,CAAC;IACzB,cAAc,CAAC,EAAC,GAAG,CAAC;CACrB,2CAgeA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -130,9 +130,10 @@ function StaticFormComponent({ form, mainTheme, fields, setIsExpanded, isFormCom
|
|
|
130
130
|
display: 'flex',
|
|
131
131
|
justifyContent: 'center',
|
|
132
132
|
borderRadius: '0.75rem',
|
|
133
|
-
backgroundColor: isFormComponent ? mainTheme.data.background : "
|
|
133
|
+
backgroundColor: isFormComponent ? mainTheme.data.background : "white",
|
|
134
134
|
margin: '1.25rem',
|
|
135
135
|
width: 'auto',
|
|
136
|
+
zIndex: 1000000000000000000000000000000,
|
|
136
137
|
padding: isFormComponent ? 20 : 0,
|
|
137
138
|
paddingRight: isFormComponent ? 5 : 0,
|
|
138
139
|
height: 'auto',
|
package/package.json
CHANGED