@prosopo/client-bundle-example 2.9.4 → 2.10.5
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 +151 -0
- package/dist/cjs/index.cjs +49 -0
- package/dist/index.js +49 -0
- package/package.json +8 -13
- package/vite.config.ts +2 -1
- package/dist/assets/captcha-BaCo3bEP.js +0 -1
- package/dist/assets/captcha-DAWM1slf.css +0 -1
- package/dist/assets/dummy.txt +0 -0
- package/dist/assets/frictionless-explicit-CtnTw8dK.js +0 -1
- package/dist/assets/frictionless-implicit-BH7anfOq.js +0 -1
- package/dist/assets/image-explicit-Dm_JoW0N.js +0 -4
- package/dist/assets/image-implicit-M0Y7U93R.js +0 -1
- package/dist/assets/index-Ck5HfpfQ.js +0 -1
- package/dist/assets/invisible-frictionless-explicit-CSPYfcNr.js +0 -4
- package/dist/assets/invisible-frictionless-implicit-D0saDt4U.js +0 -1
- package/dist/assets/invisible-image-explicit-erOMAo-F.js +0 -4
- package/dist/assets/invisible-image-implicit-c0sMfk2s.js +0 -1
- package/dist/assets/invisible-pow-explicit-BgMt7lhN.js +0 -4
- package/dist/assets/invisible-pow-implicit-CnxS8gw2.js +0 -4
- package/dist/assets/pow-explicit-BgDWNJK9.js +0 -4
- package/dist/assets/pow-implicit-Ck5HfpfQ.js +0 -1
- package/dist/frictionless-explicit.html +0 -875
- package/dist/frictionless-implicit.html +0 -874
- package/dist/image-explicit.html +0 -877
- package/dist/index.html +0 -850
- package/dist/invisible-frictionless-explicit.html +0 -877
- package/dist/invisible-frictionless-implicit.html +0 -884
- package/dist/invisible-image-explicit.html +0 -878
- package/dist/invisible-image-implicit.html +0 -884
- package/dist/invisible-pow-explicit.html +0 -878
- package/dist/invisible-pow-implicit.html +0 -878
- package/dist/plugins/explanation-injector.ts +0 -250
- package/dist/plugins/form-filler-injector.ts +0 -233
- package/dist/plugins/navigation-injector.ts +0 -602
- package/dist/plugins/status-log-injector.ts +0 -199
- package/dist/pow-explicit.html +0 -877
- package/dist/pow-implicit.html +0 -881
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
// Vite plugin to inject navigation into HTML files
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import {
|
|
17
|
-
type IndexHtmlTransformContext,
|
|
18
|
-
type Plugin,
|
|
19
|
-
normalizePath,
|
|
20
|
-
} from "vite";
|
|
21
|
-
|
|
22
|
-
interface CaptchaTypeDetails {
|
|
23
|
-
path: string;
|
|
24
|
-
exists: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface CaptchaType {
|
|
28
|
-
[key: string]: CaptchaTypeDetails;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface CaptchaTypes {
|
|
32
|
-
[key: string]: CaptchaType;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default function navigationInjector(): Plugin {
|
|
36
|
-
// Define all pages, including existing and planned
|
|
37
|
-
const pageDefinitions = {
|
|
38
|
-
standard: {
|
|
39
|
-
image: {
|
|
40
|
-
implicit: { path: "index.html", exists: true },
|
|
41
|
-
explicit: { path: "image-explicit.html", exists: true },
|
|
42
|
-
},
|
|
43
|
-
pow: {
|
|
44
|
-
implicit: { path: "pow-implicit.html", exists: true },
|
|
45
|
-
explicit: { path: "pow-explicit.html", exists: true },
|
|
46
|
-
},
|
|
47
|
-
frictionless: {
|
|
48
|
-
implicit: { path: "frictionless-implicit.html", exists: true },
|
|
49
|
-
explicit: { path: "frictionless-explicit.html", exists: true },
|
|
50
|
-
},
|
|
51
|
-
// slider: {
|
|
52
|
-
// implicit: { path: "slider-implicit.html", exists: true },
|
|
53
|
-
// explicit: { path: "slider-explicit.html", exists: true },
|
|
54
|
-
// },
|
|
55
|
-
},
|
|
56
|
-
invisible: {
|
|
57
|
-
image: {
|
|
58
|
-
implicit: { path: "invisible-image-implicit.html", exists: true },
|
|
59
|
-
explicit: { path: "invisible-image-explicit.html", exists: true },
|
|
60
|
-
},
|
|
61
|
-
pow: {
|
|
62
|
-
implicit: { path: "invisible-pow-implicit.html", exists: true },
|
|
63
|
-
explicit: { path: "invisible-pow-explicit.html", exists: true },
|
|
64
|
-
},
|
|
65
|
-
frictionless: {
|
|
66
|
-
implicit: {
|
|
67
|
-
path: "invisible-frictionless-implicit.html",
|
|
68
|
-
exists: true,
|
|
69
|
-
},
|
|
70
|
-
explicit: {
|
|
71
|
-
path: "invisible-frictionless-explicit.html",
|
|
72
|
-
exists: true,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
// slider: {
|
|
76
|
-
// implicit: { path: "invisible-slider-implicit.html", exists: true },
|
|
77
|
-
// explicit: { path: "invisible-slider-explicit.html", exists: true },
|
|
78
|
-
// },
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// Style for the navigation bar
|
|
83
|
-
const navStyle = `
|
|
84
|
-
<style>
|
|
85
|
-
.nav-topbar {
|
|
86
|
-
background-color: #2196F3;
|
|
87
|
-
padding: 0;
|
|
88
|
-
margin-bottom: 20px;
|
|
89
|
-
transition: all 0.3s ease;
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
max-height: 500px;
|
|
92
|
-
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
|
93
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
94
|
-
}
|
|
95
|
-
.nav-topbar.collapsed {
|
|
96
|
-
max-height: 60px;
|
|
97
|
-
}
|
|
98
|
-
.nav-container {
|
|
99
|
-
max-width: 1200px;
|
|
100
|
-
margin: 0 auto;
|
|
101
|
-
padding: 0 20px;
|
|
102
|
-
position: relative;
|
|
103
|
-
}
|
|
104
|
-
.nav-header {
|
|
105
|
-
display: flex;
|
|
106
|
-
justify-content: space-between;
|
|
107
|
-
align-items: center;
|
|
108
|
-
padding: 12px 0;
|
|
109
|
-
position: relative;
|
|
110
|
-
z-index: 20;
|
|
111
|
-
}
|
|
112
|
-
.nav-title {
|
|
113
|
-
color: white;
|
|
114
|
-
font-size: 1.25rem;
|
|
115
|
-
font-weight: 600;
|
|
116
|
-
margin: 0;
|
|
117
|
-
display: flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
gap: 8px;
|
|
120
|
-
}
|
|
121
|
-
.nav-title-text {
|
|
122
|
-
margin-right: 8px;
|
|
123
|
-
}
|
|
124
|
-
.nav-title-hint {
|
|
125
|
-
font-size: 0.875rem;
|
|
126
|
-
font-weight: normal;
|
|
127
|
-
opacity: 0;
|
|
128
|
-
transition: opacity 0.3s ease;
|
|
129
|
-
color: rgba(255,255,255,0.8);
|
|
130
|
-
}
|
|
131
|
-
.collapsed .nav-title-hint {
|
|
132
|
-
opacity: 0.8;
|
|
133
|
-
}
|
|
134
|
-
.nav-toggle {
|
|
135
|
-
background-color: rgba(255,255,255,0.1);
|
|
136
|
-
color: white;
|
|
137
|
-
border: none;
|
|
138
|
-
padding: 8px 12px;
|
|
139
|
-
cursor: pointer;
|
|
140
|
-
border-radius: 6px;
|
|
141
|
-
z-index: 10;
|
|
142
|
-
display: flex;
|
|
143
|
-
align-items: center;
|
|
144
|
-
justify-content: center;
|
|
145
|
-
transition: background-color 0.2s ease;
|
|
146
|
-
}
|
|
147
|
-
.nav-toggle:hover {
|
|
148
|
-
background-color: rgba(255,255,255,0.2);
|
|
149
|
-
}
|
|
150
|
-
.nav-toggle-icon {
|
|
151
|
-
width: 24px;
|
|
152
|
-
height: 24px;
|
|
153
|
-
display: inline-block;
|
|
154
|
-
position: relative;
|
|
155
|
-
}
|
|
156
|
-
.nav-toggle-icon svg {
|
|
157
|
-
position: absolute;
|
|
158
|
-
top: 0;
|
|
159
|
-
left: 0;
|
|
160
|
-
transition: opacity 0.3s ease;
|
|
161
|
-
}
|
|
162
|
-
.nav-toggle-icon .icon-collapse {
|
|
163
|
-
opacity: 1;
|
|
164
|
-
}
|
|
165
|
-
.nav-toggle-icon .icon-expand {
|
|
166
|
-
opacity: 0;
|
|
167
|
-
}
|
|
168
|
-
.collapsed .nav-toggle-icon .icon-collapse {
|
|
169
|
-
opacity: 0;
|
|
170
|
-
}
|
|
171
|
-
.collapsed .nav-toggle-icon .icon-expand {
|
|
172
|
-
opacity: 1;
|
|
173
|
-
}
|
|
174
|
-
.nav-content {
|
|
175
|
-
padding: 0 0 20px 0;
|
|
176
|
-
transition: opacity 0.3s ease;
|
|
177
|
-
}
|
|
178
|
-
.collapsed .nav-content {
|
|
179
|
-
opacity: 0;
|
|
180
|
-
}
|
|
181
|
-
.nav-sections {
|
|
182
|
-
display: flex;
|
|
183
|
-
flex-wrap: wrap;
|
|
184
|
-
gap: 20px;
|
|
185
|
-
}
|
|
186
|
-
.nav-section {
|
|
187
|
-
flex: 1;
|
|
188
|
-
min-width: 280px;
|
|
189
|
-
}
|
|
190
|
-
.nav-section h3 {
|
|
191
|
-
color: white;
|
|
192
|
-
font-size: 1rem;
|
|
193
|
-
font-weight: 600;
|
|
194
|
-
margin: 0 0 12px 0;
|
|
195
|
-
padding-bottom: 8px;
|
|
196
|
-
border-bottom: 1px solid rgba(255,255,255,0.2);
|
|
197
|
-
}
|
|
198
|
-
.nav-group {
|
|
199
|
-
background: rgba(255,255,255,0.1);
|
|
200
|
-
border-radius: 8px;
|
|
201
|
-
padding: 12px;
|
|
202
|
-
margin-bottom: 12px;
|
|
203
|
-
}
|
|
204
|
-
.nav-group-title {
|
|
205
|
-
color: rgba(255,255,255,0.9);
|
|
206
|
-
font-size: 0.875rem;
|
|
207
|
-
font-weight: 500;
|
|
208
|
-
margin: 0 0 8px 0;
|
|
209
|
-
text-transform: uppercase;
|
|
210
|
-
letter-spacing: 0.5px;
|
|
211
|
-
}
|
|
212
|
-
.nav-group-links {
|
|
213
|
-
list-style: none;
|
|
214
|
-
margin: 0;
|
|
215
|
-
padding: 0;
|
|
216
|
-
}
|
|
217
|
-
.nav-group-links li {
|
|
218
|
-
margin: 6px 0;
|
|
219
|
-
}
|
|
220
|
-
.nav-group-links a {
|
|
221
|
-
color: white;
|
|
222
|
-
text-decoration: none;
|
|
223
|
-
font-weight: 500;
|
|
224
|
-
padding: 6px 8px;
|
|
225
|
-
display: inline-block;
|
|
226
|
-
border-radius: 4px;
|
|
227
|
-
transition: background-color 0.2s ease;
|
|
228
|
-
}
|
|
229
|
-
.nav-group-links a:hover {
|
|
230
|
-
background-color: rgba(255,255,255,0.2);
|
|
231
|
-
}
|
|
232
|
-
.nav-group-links .active {
|
|
233
|
-
background-color: rgba(255,255,255,0.2);
|
|
234
|
-
font-weight: 600;
|
|
235
|
-
}
|
|
236
|
-
.nav-group-links .disabled {
|
|
237
|
-
color: rgba(255,255,255,0.5);
|
|
238
|
-
cursor: not-allowed;
|
|
239
|
-
opacity: 0.7;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
@media (max-width: 768px) {
|
|
243
|
-
.nav-container {
|
|
244
|
-
padding: 0 16px;
|
|
245
|
-
}
|
|
246
|
-
.nav-title {
|
|
247
|
-
font-size: 1.125rem;
|
|
248
|
-
}
|
|
249
|
-
.nav-title-hint {
|
|
250
|
-
display: none;
|
|
251
|
-
}
|
|
252
|
-
.nav-sections {
|
|
253
|
-
flex-direction: column;
|
|
254
|
-
gap: 16px;
|
|
255
|
-
}
|
|
256
|
-
.nav-section {
|
|
257
|
-
min-width: 100%;
|
|
258
|
-
}
|
|
259
|
-
.nav-section h3 {
|
|
260
|
-
font-size: 0.875rem;
|
|
261
|
-
}
|
|
262
|
-
.nav-group {
|
|
263
|
-
padding: 10px;
|
|
264
|
-
}
|
|
265
|
-
.nav-group-title {
|
|
266
|
-
font-size: 0.8125rem;
|
|
267
|
-
}
|
|
268
|
-
.nav-group-links a {
|
|
269
|
-
padding: 8px 10px;
|
|
270
|
-
width: 100%;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
@media (max-width: 480px) {
|
|
275
|
-
.nav-topbar {
|
|
276
|
-
max-height: 60px;
|
|
277
|
-
}
|
|
278
|
-
.nav-topbar.collapsed {
|
|
279
|
-
max-height: 60px;
|
|
280
|
-
}
|
|
281
|
-
.nav-title {
|
|
282
|
-
font-size: 1rem;
|
|
283
|
-
}
|
|
284
|
-
.nav-toggle {
|
|
285
|
-
padding: 6px 10px;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.nav-group-dropdown {
|
|
290
|
-
position: relative;
|
|
291
|
-
display: inline-block;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.nav-group-dropdown-btn {
|
|
295
|
-
background: none;
|
|
296
|
-
border: none;
|
|
297
|
-
color: white;
|
|
298
|
-
font-weight: 500;
|
|
299
|
-
padding: 6px 8px;
|
|
300
|
-
cursor: pointer;
|
|
301
|
-
display: flex;
|
|
302
|
-
align-items: center;
|
|
303
|
-
gap: 4px;
|
|
304
|
-
border-radius: 4px;
|
|
305
|
-
transition: background-color 0.2s ease;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.nav-group-dropdown-btn:hover {
|
|
309
|
-
background-color: rgba(255,255,255,0.2);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.nav-group-dropdown-btn svg {
|
|
313
|
-
width: 16px;
|
|
314
|
-
height: 16px;
|
|
315
|
-
transition: transform 0.2s ease;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.nav-group-dropdown-btn.open svg {
|
|
319
|
-
transform: rotate(180deg);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.nav-group-dropdown-content {
|
|
323
|
-
display: none;
|
|
324
|
-
position: absolute;
|
|
325
|
-
background-color: rgba(33, 150, 243, 0.95);
|
|
326
|
-
min-width: 160px;
|
|
327
|
-
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
|
|
328
|
-
z-index: 1;
|
|
329
|
-
border-radius: 4px;
|
|
330
|
-
padding: 8px 0;
|
|
331
|
-
margin-top: 4px;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.nav-group-dropdown-btn.open + .nav-group-dropdown-content {
|
|
335
|
-
display: block;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.nav-group-dropdown-content a {
|
|
339
|
-
color: white;
|
|
340
|
-
padding: 8px 16px;
|
|
341
|
-
text-decoration: none;
|
|
342
|
-
display: block;
|
|
343
|
-
transition: background-color 0.2s ease;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.nav-group-dropdown-content a:hover {
|
|
347
|
-
background-color: rgba(255,255,255,0.2);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.nav-group-dropdown-content a.active {
|
|
351
|
-
background-color: rgba(255,255,255,0.2);
|
|
352
|
-
font-weight: 600;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
@media (max-width: 768px) {
|
|
356
|
-
.nav-group-dropdown-content {
|
|
357
|
-
position: static;
|
|
358
|
-
box-shadow: none;
|
|
359
|
-
background-color: rgba(255,255,255,0.1);
|
|
360
|
-
margin-top: 8px;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
</style>
|
|
364
|
-
`;
|
|
365
|
-
|
|
366
|
-
// JavaScript for toggling navigation
|
|
367
|
-
const navScript = `
|
|
368
|
-
<script>
|
|
369
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
370
|
-
const toggleBtn = document.getElementById('nav-toggle');
|
|
371
|
-
const navBar = document.getElementById('nav-topbar');
|
|
372
|
-
const navHeader = document.getElementById('nav-header');
|
|
373
|
-
const isMobile = window.innerWidth <= 768;
|
|
374
|
-
|
|
375
|
-
// Check if navigation was previously collapsed
|
|
376
|
-
const navCollapsed = localStorage.getItem('navCollapsed') === 'true';
|
|
377
|
-
if (navCollapsed) {
|
|
378
|
-
navBar.classList.add('collapsed');
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Function to expand the navigation
|
|
382
|
-
function expandNav() {
|
|
383
|
-
if (navBar.classList.contains('collapsed')) {
|
|
384
|
-
navBar.classList.remove('collapsed');
|
|
385
|
-
localStorage.setItem('navCollapsed', 'false');
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// Function to collapse the navigation
|
|
390
|
-
function collapseNav() {
|
|
391
|
-
if (!navBar.classList.contains('collapsed')) {
|
|
392
|
-
navBar.classList.add('collapsed');
|
|
393
|
-
localStorage.setItem('navCollapsed', 'true');
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// Function to toggle the navigation
|
|
398
|
-
function toggleNav() {
|
|
399
|
-
navBar.classList.toggle('collapsed');
|
|
400
|
-
localStorage.setItem('navCollapsed', navBar.classList.contains('collapsed'));
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// Toggle on button click
|
|
404
|
-
toggleBtn.addEventListener('click', function(e) {
|
|
405
|
-
e.stopPropagation();
|
|
406
|
-
toggleNav();
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
// Expand on toggle button hover when collapsed (desktop only)
|
|
410
|
-
if (!isMobile) {
|
|
411
|
-
toggleBtn.addEventListener('mouseenter', function() {
|
|
412
|
-
if (navBar.classList.contains('collapsed')) {
|
|
413
|
-
expandNav();
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// Toggle on header click
|
|
419
|
-
navHeader.addEventListener('click', function(e) {
|
|
420
|
-
if (e.target.tagName === 'A') {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
toggleNav();
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// Make the header appear clickable with cursor style
|
|
427
|
-
navHeader.style.cursor = 'pointer';
|
|
428
|
-
|
|
429
|
-
// Handle window resize
|
|
430
|
-
window.addEventListener('resize', function() {
|
|
431
|
-
const newIsMobile = window.innerWidth <= 768;
|
|
432
|
-
if (newIsMobile !== isMobile) {
|
|
433
|
-
if (newIsMobile) {
|
|
434
|
-
// On mobile, collapse the nav by default
|
|
435
|
-
collapseNav();
|
|
436
|
-
} else {
|
|
437
|
-
// On desktop, expand the nav by default
|
|
438
|
-
expandNav();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
// Handle dropdown toggles
|
|
444
|
-
document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
|
|
445
|
-
button.addEventListener('click', function(e) {
|
|
446
|
-
e.stopPropagation();
|
|
447
|
-
this.classList.toggle('open');
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// Close dropdowns when clicking outside
|
|
452
|
-
document.addEventListener('click', function(e) {
|
|
453
|
-
if (!e.target.closest('.nav-group-dropdown')) {
|
|
454
|
-
document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
|
|
455
|
-
button.classList.remove('open');
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
</script>
|
|
461
|
-
`;
|
|
462
|
-
|
|
463
|
-
return {
|
|
464
|
-
name: "navigation-injector",
|
|
465
|
-
transformIndexHtml: {
|
|
466
|
-
enforce: "pre",
|
|
467
|
-
transform(html: string, ctx: IndexHtmlTransformContext): string {
|
|
468
|
-
// Get the relative path from the root
|
|
469
|
-
const relativePath = ctx.filename
|
|
470
|
-
? normalizePath(path.relative(process.cwd(), ctx.filename))
|
|
471
|
-
: "";
|
|
472
|
-
|
|
473
|
-
// Extract the page path relative to src or dist directory
|
|
474
|
-
let pagePath = "";
|
|
475
|
-
const srcDir = "src/";
|
|
476
|
-
const distDir = "dist/";
|
|
477
|
-
|
|
478
|
-
if (relativePath.includes(srcDir)) {
|
|
479
|
-
pagePath = relativePath.substring(
|
|
480
|
-
relativePath.indexOf(srcDir) + srcDir.length,
|
|
481
|
-
);
|
|
482
|
-
} else if (relativePath.includes(distDir)) {
|
|
483
|
-
pagePath = relativePath.substring(
|
|
484
|
-
relativePath.indexOf(distDir) + distDir.length,
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
console.log(`Processing file: ${relativePath}, pagePath: ${pagePath}`);
|
|
489
|
-
|
|
490
|
-
// Build navigation structure
|
|
491
|
-
const standardNav = buildCaptchaNavGroup(
|
|
492
|
-
"Standard Captchas",
|
|
493
|
-
pageDefinitions.standard,
|
|
494
|
-
pagePath,
|
|
495
|
-
);
|
|
496
|
-
const invisibleNav = buildCaptchaNavGroup(
|
|
497
|
-
"Invisible Captchas",
|
|
498
|
-
pageDefinitions.invisible,
|
|
499
|
-
pagePath,
|
|
500
|
-
);
|
|
501
|
-
|
|
502
|
-
const navHtml = `
|
|
503
|
-
<div id="nav-topbar" class="nav-topbar">
|
|
504
|
-
<div class="nav-container">
|
|
505
|
-
<div id="nav-header" class="nav-header">
|
|
506
|
-
<h1 class="nav-title">
|
|
507
|
-
<span class="nav-title-text">Procaptcha Demo Playground</span>
|
|
508
|
-
<span class="nav-title-hint">(Click anywhere to see more examples)</span>
|
|
509
|
-
</h1>
|
|
510
|
-
<button id="nav-toggle" class="nav-toggle" aria-label="Toggle navigation">
|
|
511
|
-
<span class="nav-toggle-icon">
|
|
512
|
-
<svg class="icon-collapse" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
513
|
-
<polyline points="18 15 12 9 6 15"></polyline>
|
|
514
|
-
</svg>
|
|
515
|
-
<svg class="icon-expand" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
516
|
-
<polyline points="6 9 12 15 18 9"></polyline>
|
|
517
|
-
</svg>
|
|
518
|
-
</span>
|
|
519
|
-
</button>
|
|
520
|
-
</div>
|
|
521
|
-
<div class="nav-content">
|
|
522
|
-
<div class="nav-sections">
|
|
523
|
-
${standardNav}
|
|
524
|
-
${invisibleNav}
|
|
525
|
-
</div>
|
|
526
|
-
</div>
|
|
527
|
-
</div>
|
|
528
|
-
</div>
|
|
529
|
-
`;
|
|
530
|
-
|
|
531
|
-
// Inject navigation after <body> tag and script before </body>
|
|
532
|
-
if (html.includes("<body>") && html.includes("</body>")) {
|
|
533
|
-
return html
|
|
534
|
-
.replace("</head>", `${navStyle}</head>`)
|
|
535
|
-
.replace("<body>", `<body>\n${navHtml}`)
|
|
536
|
-
.replace("</body>", `${navScript}\n</body>`);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return html;
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
// Helper function to build a navigation group for each captcha type
|
|
545
|
-
function buildCaptchaNavGroup(
|
|
546
|
-
title: string,
|
|
547
|
-
captchaTypes: CaptchaTypes,
|
|
548
|
-
currentPath: string,
|
|
549
|
-
): string {
|
|
550
|
-
const navGroups: string[] = [];
|
|
551
|
-
|
|
552
|
-
for (const [typeName, captchaType] of Object.entries(captchaTypes)) {
|
|
553
|
-
const typeTitle = typeName.charAt(0).toUpperCase() + typeName.slice(1);
|
|
554
|
-
const links: string[] = [];
|
|
555
|
-
|
|
556
|
-
// Create simple buttons for each implementation
|
|
557
|
-
for (const [implName, implDetails] of Object.entries(
|
|
558
|
-
captchaType as CaptchaType,
|
|
559
|
-
)) {
|
|
560
|
-
const pagePath = implDetails.path;
|
|
561
|
-
const pageExists = implDetails.exists;
|
|
562
|
-
const implTitle = implName.charAt(0).toUpperCase() + implName.slice(1);
|
|
563
|
-
|
|
564
|
-
// Calculate relative path
|
|
565
|
-
let href: string;
|
|
566
|
-
if (currentPath.includes("/")) {
|
|
567
|
-
const depth = (currentPath.match(/\//g) || []).length;
|
|
568
|
-
href = "../".repeat(depth) + pagePath;
|
|
569
|
-
} else {
|
|
570
|
-
href = pagePath;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if (pageExists) {
|
|
574
|
-
const activeClass = currentPath === pagePath ? ' class="active"' : "";
|
|
575
|
-
links.push(`<a href="${href}"${activeClass}>${implTitle}</a>`);
|
|
576
|
-
} else {
|
|
577
|
-
links.push(
|
|
578
|
-
`<span class="disabled" title="Coming Soon">${implTitle}</span>`,
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
navGroups.push(`
|
|
584
|
-
<div class="nav-group">
|
|
585
|
-
<div class="nav-group-title">${typeTitle}</div>
|
|
586
|
-
<div class="nav-group-links">
|
|
587
|
-
${links.join("\n ")}
|
|
588
|
-
</div>
|
|
589
|
-
</div>
|
|
590
|
-
`);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
return `
|
|
594
|
-
<div class="nav-section">
|
|
595
|
-
<h3>${title}</h3>
|
|
596
|
-
<div class="nav-row">
|
|
597
|
-
${navGroups.join("\n ")}
|
|
598
|
-
</div>
|
|
599
|
-
</div>
|
|
600
|
-
`;
|
|
601
|
-
}
|
|
602
|
-
}
|