@bananacool467/authtics-host 0.1.5 → 0.1.6
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 +15 -7
- package/dist/cli.js +395 -83
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/devPanel.js +33 -62
- package/dist/index.d.ts +28 -3
- package/dist/index.js +2 -3
- package/dist/renderEngine.d.ts +1 -1
- package/dist/renderEngine.js +21 -7
- package/dist/rendererTempFiles.d.ts +1 -0
- package/dist/rendererTempFiles.js +7 -0
- package/dist/route.d.ts +4 -0
- package/dist/route.js +20 -10
- package/package.json +4 -4
- package/dist/fileLocator.d.ts +0 -4
- package/dist/fileLocator.js +0 -15
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
package/dist/devPanel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import { ShieldCheck, CircleX, ChevronDown, ChevronUp, Bug, AlertTriangle, Info, ArrowLeft, Wifi, Terminal, Route, Globe, ChevronRight, ChevronLeft, Server, TriangleAlert, Eye, Zap } from 'lucide-react';
|
|
4
4
|
import Prism from 'prismjs';
|
|
5
5
|
import 'prismjs/components/prism-javascript';
|
|
@@ -260,7 +260,7 @@ function installConsoleInterceptor() {
|
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
function SecuredTab() {
|
|
263
|
-
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column', padding: '8px 10px', textAlign: 'center', gap: '8px' }, children: [_jsx(CircleX, { size: 32, color: 'red' }), _jsx("span", { style: { color: 'red', fontSize: 24 }, children: "Tab
|
|
263
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column', padding: '8px 10px', textAlign: 'center', gap: '8px' }, children: [_jsx(CircleX, { size: 32, color: 'red' }), _jsx("span", { style: { color: 'red', fontSize: 24 }, children: "This Tab Is Currently Not Accessible" }), _jsx("span", { style: { color: 'red', fontSize: 12 }, children: "To access this tab, you need to set \"dat\" in the Authtics Host config to set restriction and then restart." })] }));
|
|
264
264
|
}
|
|
265
265
|
function PanelButton({ onClick, onClick2, children, style, fullWidth, disabled }) {
|
|
266
266
|
const [hovered, setHovered] = useState(false);
|
|
@@ -305,7 +305,6 @@ export default function DevPanel() {
|
|
|
305
305
|
const [clientInfoOpen, setClientInfoOpen] = useState(false);
|
|
306
306
|
const [aboutHostOpen, setAboutHostOpen] = useState(false);
|
|
307
307
|
const [serverInfoOpen, setServerInfoOpen] = useState(false);
|
|
308
|
-
const [siteInspectOpen, setSiteInspectOpen] = useState(false);
|
|
309
308
|
const [hasIssue, setHasIssue] = useState(false);
|
|
310
309
|
const [ping__, setPing__] = useState(0);
|
|
311
310
|
const [networkFetches, setNetworkFetches] = useState([]);
|
|
@@ -315,14 +314,10 @@ export default function DevPanel() {
|
|
|
315
314
|
const [webSockets, setWebSockets] = useState([]);
|
|
316
315
|
const [resourcesFound, setResourcesFound] = useState([]);
|
|
317
316
|
const [status, setStatus] = useState(200);
|
|
318
|
-
const [code, setCode] = useState('');
|
|
319
317
|
const [pathName, setPathName] = useState(undefined);
|
|
320
318
|
const [hostName, setHostName] = useState(undefined);
|
|
321
319
|
const [protocol, setProtocol] = useState(undefined);
|
|
322
320
|
const [path, setPath] = useState(undefined);
|
|
323
|
-
const contextMenuTimeoutMobile = useRef(undefined);
|
|
324
|
-
const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 });
|
|
325
|
-
const [contextMenuShown, setContextMenuShown] = useState(false);
|
|
326
321
|
const [isSsr, setIsSsr] = useState(false);
|
|
327
322
|
const datRestrictionMissingRef = useRef(true);
|
|
328
323
|
const cpuUsage = useRef(0);
|
|
@@ -339,20 +334,19 @@ export default function DevPanel() {
|
|
|
339
334
|
const [token, setToken] = useState(null);
|
|
340
335
|
const [tokenLength, setTokenLength] = useState(0);
|
|
341
336
|
const [tokenHidden, setTokenHidden] = useState(true);
|
|
342
|
-
const [consoleInputFocused, setConsoleInputFocused] = useState(false);
|
|
343
|
-
const consoleInputRef = useRef(null);
|
|
344
|
-
const overlayRef = useRef(null);
|
|
345
337
|
const fpsSpanRef = useRef(null);
|
|
346
338
|
const frameCount = useRef(0);
|
|
347
339
|
const frames = useRef(0);
|
|
348
340
|
const consoleScrollRef = useRef(null);
|
|
349
341
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
350
342
|
const [datRestrictionMissing, setDatRestrictionMissing] = useState(true);
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
343
|
+
const cookie = {
|
|
344
|
+
set: (k, v) => document.cookie = `${k}=${v}; path=/`,
|
|
345
|
+
get: (k) => Object.fromEntries(document.cookie.split(";")
|
|
346
|
+
.filter(Boolean)
|
|
347
|
+
.map(c => c.trim().split("=")))[k],
|
|
348
|
+
del: (k) => document.cookie = `${k}=; path=/; max-age=0`
|
|
349
|
+
};
|
|
356
350
|
const [doc, setDoc] = useState(null);
|
|
357
351
|
const [filters, setFilters] = useState({
|
|
358
352
|
Log: true, Info: true, Warn: true, Error: true, Debug: false
|
|
@@ -381,7 +375,7 @@ export default function DevPanel() {
|
|
|
381
375
|
const resp = await fetch('/__authtics_host_apis__/get-file-by-pathname', {
|
|
382
376
|
method: 'POST',
|
|
383
377
|
headers: { 'Content-Type': 'application/json' },
|
|
384
|
-
body: JSON.stringify({ pathname: window.location.pathname,
|
|
378
|
+
body: JSON.stringify({ pathname: window.location.pathname, })
|
|
385
379
|
});
|
|
386
380
|
if (resp.status === 200) {
|
|
387
381
|
const data = await resp.json();
|
|
@@ -392,7 +386,7 @@ export default function DevPanel() {
|
|
|
392
386
|
const resp = await fetch('/__authtics_host_apis__/get-dat-matching', {
|
|
393
387
|
method: 'POST',
|
|
394
388
|
headers: { 'Content-Type': 'application/json' },
|
|
395
|
-
body: JSON.stringify({
|
|
389
|
+
body: JSON.stringify({})
|
|
396
390
|
});
|
|
397
391
|
if (resp.status === 200) {
|
|
398
392
|
const data = await resp.json();
|
|
@@ -400,7 +394,7 @@ export default function DevPanel() {
|
|
|
400
394
|
const resp3 = await fetch('/__authtics_host_apis__/is-users-paused', {
|
|
401
395
|
method: 'POST',
|
|
402
396
|
headers: { 'Content-Type': 'application/json' },
|
|
403
|
-
body: JSON.stringify({
|
|
397
|
+
body: JSON.stringify({})
|
|
404
398
|
});
|
|
405
399
|
let paused = false;
|
|
406
400
|
if (resp3.status === 200) {
|
|
@@ -415,7 +409,7 @@ export default function DevPanel() {
|
|
|
415
409
|
const resp2 = await fetch('/__authtics_host_apis__/get-dat-restriction-missing', {
|
|
416
410
|
method: 'POST',
|
|
417
411
|
headers: { 'Content-Type': 'application/json' },
|
|
418
|
-
body: JSON.stringify({
|
|
412
|
+
body: JSON.stringify({})
|
|
419
413
|
});
|
|
420
414
|
if (resp2.status === 200) {
|
|
421
415
|
const data = await resp2.json();
|
|
@@ -430,7 +424,7 @@ export default function DevPanel() {
|
|
|
430
424
|
const resp = await fetch('/__authtics_host_apis__/get-is-ssr', {
|
|
431
425
|
method: 'POST',
|
|
432
426
|
headers: { 'Content-Type': 'application/json' },
|
|
433
|
-
body: JSON.stringify({
|
|
427
|
+
body: JSON.stringify({})
|
|
434
428
|
});
|
|
435
429
|
if (resp.status === 200) {
|
|
436
430
|
const data = await resp.json();
|
|
@@ -441,7 +435,7 @@ export default function DevPanel() {
|
|
|
441
435
|
const resp = await fetch('/__authtics_host_apis__/get-cpu_memory', {
|
|
442
436
|
method: 'POST',
|
|
443
437
|
headers: { 'Content-Type': 'application/json' },
|
|
444
|
-
body: JSON.stringify({
|
|
438
|
+
body: JSON.stringify({})
|
|
445
439
|
});
|
|
446
440
|
if (resp.status === 200) {
|
|
447
441
|
const data = await resp.json();
|
|
@@ -453,7 +447,7 @@ export default function DevPanel() {
|
|
|
453
447
|
const resp = await fetch('/__authtics_host_apis__/get-host-ver', {
|
|
454
448
|
method: 'POST',
|
|
455
449
|
headers: { 'Content-Type': 'application/json' },
|
|
456
|
-
body: JSON.stringify({
|
|
450
|
+
body: JSON.stringify({})
|
|
457
451
|
});
|
|
458
452
|
if (resp.status === 200) {
|
|
459
453
|
const data = await resp.json();
|
|
@@ -464,7 +458,7 @@ export default function DevPanel() {
|
|
|
464
458
|
const resp = await fetch('/__authtics_host_apis__/get-compiler', {
|
|
465
459
|
method: 'POST',
|
|
466
460
|
headers: { 'Content-Type': 'application/json' },
|
|
467
|
-
body: JSON.stringify({
|
|
461
|
+
body: JSON.stringify({})
|
|
468
462
|
});
|
|
469
463
|
if (resp.status === 200) {
|
|
470
464
|
const data = await resp.json();
|
|
@@ -475,7 +469,7 @@ export default function DevPanel() {
|
|
|
475
469
|
const resp = await fetch('/__authtics_host_apis__/get-connection', {
|
|
476
470
|
method: 'POST',
|
|
477
471
|
headers: { 'Content-Type': 'application/json' },
|
|
478
|
-
body: JSON.stringify({
|
|
472
|
+
body: JSON.stringify({})
|
|
479
473
|
});
|
|
480
474
|
if (resp.status === 200) {
|
|
481
475
|
const data = await resp.json();
|
|
@@ -494,7 +488,7 @@ export default function DevPanel() {
|
|
|
494
488
|
const resp = await fetch('/__authtics_host_apis__/get-user-settings', {
|
|
495
489
|
method: 'POST',
|
|
496
490
|
headers: { 'Content-Type': 'application/json' },
|
|
497
|
-
body: JSON.stringify({
|
|
491
|
+
body: JSON.stringify({})
|
|
498
492
|
});
|
|
499
493
|
if (resp.status === 200) {
|
|
500
494
|
const data = await resp.json();
|
|
@@ -505,7 +499,7 @@ export default function DevPanel() {
|
|
|
505
499
|
const resp = await fetch('/__authtics_host_apis__/get-server-info', {
|
|
506
500
|
method: 'POST',
|
|
507
501
|
headers: { 'Content-Type': 'application/json' },
|
|
508
|
-
body: JSON.stringify({
|
|
502
|
+
body: JSON.stringify({})
|
|
509
503
|
});
|
|
510
504
|
if (resp.status === 200) {
|
|
511
505
|
const data = await resp.json();
|
|
@@ -532,30 +526,18 @@ export default function DevPanel() {
|
|
|
532
526
|
}, 250);
|
|
533
527
|
}, 250);
|
|
534
528
|
}, []);
|
|
535
|
-
const datTouchStart = (e) => {
|
|
536
|
-
e.preventDefault();
|
|
537
|
-
setCursorPosition({ x: e.clientX || e.touches[0].clientX, y: e.clientY || e.touches[0].clientY });
|
|
538
|
-
contextMenuTimeoutMobile.current = setTimeout(() => {
|
|
539
|
-
setContextMenuShown(true);
|
|
540
|
-
clearTimeout(contextMenuTimeoutMobile.current);
|
|
541
|
-
}, 1000);
|
|
542
|
-
};
|
|
543
|
-
const datTouchEnd = (e) => {
|
|
544
|
-
e.preventDefault();
|
|
545
|
-
clearTimeout(contextMenuTimeoutMobile.current);
|
|
546
|
-
};
|
|
547
529
|
const restart = async () => {
|
|
548
|
-
|
|
530
|
+
await fetch('/__authtics_host_apis__/restart', {
|
|
549
531
|
method: 'POST',
|
|
550
532
|
headers: { 'Content-Type': 'application/json' },
|
|
551
|
-
body: JSON.stringify({
|
|
533
|
+
body: JSON.stringify({})
|
|
552
534
|
});
|
|
553
535
|
};
|
|
554
536
|
const shutDown = async () => {
|
|
555
|
-
|
|
537
|
+
await fetch('/__authtics_host_apis__/shutdown', {
|
|
556
538
|
method: 'POST',
|
|
557
539
|
headers: { 'Content-Type': 'application/json' },
|
|
558
|
-
body: JSON.stringify({
|
|
540
|
+
body: JSON.stringify({})
|
|
559
541
|
});
|
|
560
542
|
};
|
|
561
543
|
useEffect(() => {
|
|
@@ -584,14 +566,13 @@ export default function DevPanel() {
|
|
|
584
566
|
? '320px'
|
|
585
567
|
: '320px';
|
|
586
568
|
useEffect(() => {
|
|
587
|
-
const dat = localStorage.getItem('dat');
|
|
588
569
|
const interval = setInterval(async () => {
|
|
589
570
|
try {
|
|
590
571
|
const timeStart = Date.now();
|
|
591
572
|
const resp = await fetch('/__authtics_host_apis__/ping', {
|
|
592
573
|
method: 'POST',
|
|
593
574
|
headers: { 'Content-Type': 'application/json' },
|
|
594
|
-
body: JSON.stringify({
|
|
575
|
+
body: JSON.stringify({})
|
|
595
576
|
});
|
|
596
577
|
if (resp.status === 200) {
|
|
597
578
|
const data = await resp.json();
|
|
@@ -639,7 +620,7 @@ export default function DevPanel() {
|
|
|
639
620
|
;
|
|
640
621
|
};
|
|
641
622
|
try {
|
|
642
|
-
const existingToken =
|
|
623
|
+
const existingToken = cookie.get('dat');
|
|
643
624
|
if (existingToken) {
|
|
644
625
|
setToken(existingToken);
|
|
645
626
|
let length_ = existingToken?.split('');
|
|
@@ -650,7 +631,13 @@ export default function DevPanel() {
|
|
|
650
631
|
else {
|
|
651
632
|
const newToken = generateToken();
|
|
652
633
|
try {
|
|
653
|
-
|
|
634
|
+
let localStorageToken;
|
|
635
|
+
try {
|
|
636
|
+
localStorageToken = localStorage.getItem('dat');
|
|
637
|
+
}
|
|
638
|
+
catch (e) {
|
|
639
|
+
}
|
|
640
|
+
cookie.set('dat', localStorageToken || newToken);
|
|
654
641
|
setToken(newToken);
|
|
655
642
|
let length_ = newToken?.split('');
|
|
656
643
|
let length;
|
|
@@ -738,23 +725,12 @@ export default function DevPanel() {
|
|
|
738
725
|
};
|
|
739
726
|
__();
|
|
740
727
|
}, []);
|
|
741
|
-
const showSelfConsoleLog = (message) => {
|
|
742
|
-
const event = window.dispatchEvent(new CustomEvent('authtics:log', {
|
|
743
|
-
detail: {
|
|
744
|
-
type: "Eval",
|
|
745
|
-
message: message,
|
|
746
|
-
time: Date.now(),
|
|
747
|
-
source: "console.js"
|
|
748
|
-
}
|
|
749
|
-
}));
|
|
750
|
-
};
|
|
751
728
|
const pause_Resume_Users = async () => {
|
|
752
729
|
if (usersPausedRealInfo) {
|
|
753
730
|
const resp = await fetch('/__authtics_host_apis__/set-users-paused', {
|
|
754
731
|
method: 'POST',
|
|
755
732
|
headers: { 'Content-Type': 'application/json' },
|
|
756
733
|
body: JSON.stringify({
|
|
757
|
-
dat: localStorage.getItem('dat'),
|
|
758
734
|
paused: false
|
|
759
735
|
})
|
|
760
736
|
});
|
|
@@ -767,7 +743,6 @@ export default function DevPanel() {
|
|
|
767
743
|
method: 'POST',
|
|
768
744
|
headers: { 'Content-Type': 'application/json' },
|
|
769
745
|
body: JSON.stringify({
|
|
770
|
-
dat: localStorage.getItem('dat'),
|
|
771
746
|
paused: true
|
|
772
747
|
})
|
|
773
748
|
});
|
|
@@ -776,10 +751,6 @@ export default function DevPanel() {
|
|
|
776
751
|
}
|
|
777
752
|
}
|
|
778
753
|
};
|
|
779
|
-
if (usersPaused) {
|
|
780
|
-
doc?.getElementById('root')?.remove();
|
|
781
|
-
window.location.href = '/failed-to-handle';
|
|
782
|
-
}
|
|
783
754
|
return (_jsxs(_Fragment, { children: [_jsx("div", { style: {
|
|
784
755
|
position: 'absolute',
|
|
785
756
|
zIndex: 999999,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
declare module "http" {
|
|
2
|
+
interface IncomingMessage {
|
|
3
|
+
ip: string | undefined;
|
|
4
|
+
ipType: number;
|
|
5
|
+
body: any;
|
|
6
|
+
cookies: Record<string, string>;
|
|
7
|
+
ua: string | undefined;
|
|
8
|
+
os: any;
|
|
9
|
+
browser: any;
|
|
10
|
+
dat: string | undefined;
|
|
11
|
+
bodySize: number;
|
|
12
|
+
bodyType: string;
|
|
13
|
+
sentTime: number;
|
|
14
|
+
}
|
|
15
|
+
interface ServerResponse {
|
|
16
|
+
redirect: (url: string) => void;
|
|
17
|
+
html: (content: string) => void;
|
|
18
|
+
json: (content: any) => void;
|
|
19
|
+
text: (content: string) => void;
|
|
20
|
+
file: (path_: string) => void;
|
|
21
|
+
status: (code: number) => ServerResponse;
|
|
22
|
+
reload: () => void;
|
|
23
|
+
setCookie: (name: string, value: string) => void;
|
|
24
|
+
rmvCookie: (name: string) => void;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
1
27
|
import { defineConfig } from './config.js';
|
|
2
28
|
import App from './cli.js';
|
|
3
|
-
import { Route } from './route.js';
|
|
4
|
-
|
|
5
|
-
export { App, Route, RouteMap, defineConfig };
|
|
29
|
+
import { Route, RouteMap, Paused } from './route.js';
|
|
30
|
+
export { App, Route, RouteMap, Paused, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineConfig } from './config.js';
|
|
2
2
|
import App from './cli.js';
|
|
3
|
-
import { Route } from './route.js';
|
|
4
|
-
|
|
5
|
-
export { App, Route, RouteMap, defineConfig };
|
|
3
|
+
import { Route, RouteMap, Paused } from './route.js';
|
|
4
|
+
export { App, Route, RouteMap, Paused, defineConfig };
|
package/dist/renderEngine.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type CompilerType = 'esbuild' | 'babel';
|
|
2
2
|
export declare function findFileUpwards(startDir: string, relativePath: string): string | null;
|
|
3
|
-
export declare function renderPage(tsxPath: string, reqUrl?: string, showPanel?: boolean, compiler?: CompilerType, hotReload?: boolean, autoPaging?: boolean, autoPageDir?: string, appDir?: string): Promise<string>;
|
|
3
|
+
export declare function renderPage(tsxPath: string, reqUrl?: string, showPanel?: boolean, compiler?: CompilerType, hotReload?: boolean, autoPaging?: boolean, autoPageDir?: string, appDir?: string, fileHandler?: (f: string, p: string) => void, reqDAT?: string | undefined, configDAT?: string | string[] | undefined): Promise<string>;
|
package/dist/renderEngine.js
CHANGED
|
@@ -86,7 +86,7 @@ function resolveTemplate(appDir, autoPageDir, autoPaging) {
|
|
|
86
86
|
return nextToCli;
|
|
87
87
|
}
|
|
88
88
|
function buildHtml(opts) {
|
|
89
|
-
const { pageHtml, clientCode, devPanelContainer, templatePath, hotReload } = opts;
|
|
89
|
+
const { pageHtml, clientCode, devPanelContainer, templatePath, hotReload, fileName } = opts;
|
|
90
90
|
const hmrScript = hotReload ? HMR_SCRIPT : '';
|
|
91
91
|
if (templatePath && fs.existsSync(templatePath)) {
|
|
92
92
|
let template = fs.readFileSync(templatePath, "utf-8");
|
|
@@ -94,8 +94,8 @@ function buildHtml(opts) {
|
|
|
94
94
|
if (contentTag.test(template)) {
|
|
95
95
|
template = template.replace(contentTag, `<div id="root">${pageHtml}</div>\n ${devPanelContainer}`);
|
|
96
96
|
template = template.includes("</body>")
|
|
97
|
-
? template.replace("</body>", `
|
|
98
|
-
: template + `\n
|
|
97
|
+
? template.replace("</body>", ` ${fileName ? `<script src="${fileName}"></script>` : `<script>${clientCode}</script>`}\n${hmrScript}</body>`)
|
|
98
|
+
: template + `\n${fileName ? `<script src="${fileName}"></script>` : `<script>${clientCode}</script>`}${hmrScript}`;
|
|
99
99
|
return template;
|
|
100
100
|
}
|
|
101
101
|
console.warn('[authtics] _template.html has no <authtics_host_content /> — using default layout.');
|
|
@@ -109,7 +109,7 @@ function buildHtml(opts) {
|
|
|
109
109
|
<body>
|
|
110
110
|
<div id="root">${pageHtml}</div>
|
|
111
111
|
${devPanelContainer}
|
|
112
|
-
|
|
112
|
+
${fileName ? `<script src="${fileName}"></script>` : `<script>${clientCode}</script>`}
|
|
113
113
|
${hmrScript}
|
|
114
114
|
</body>
|
|
115
115
|
</html>`;
|
|
@@ -137,15 +137,28 @@ const HMR_SCRIPT = `
|
|
|
137
137
|
const es = new EventSource('/__authtics_hmr__');
|
|
138
138
|
es.onmessage = function(e) { if (e.data === 'reload') window.location.reload(); };
|
|
139
139
|
es.onerror = function() { setTimeout(function() { window.location.reload(); }, 1000); };
|
|
140
|
+
window.onbeforeunload = function() {
|
|
141
|
+
es.close();
|
|
142
|
+
es = null;
|
|
143
|
+
};
|
|
140
144
|
})();
|
|
141
145
|
</script>
|
|
142
146
|
`;
|
|
143
|
-
export async function renderPage(tsxPath, reqUrl, showPanel = true, compiler = 'esbuild', hotReload = false, autoPaging = true, autoPageDir, appDir) {
|
|
147
|
+
export async function renderPage(tsxPath, reqUrl, showPanel = true, compiler = 'esbuild', hotReload = false, autoPaging = true, autoPageDir, appDir, fileHandler, reqDAT, configDAT) {
|
|
144
148
|
ensureTempDirs();
|
|
145
149
|
if (!fs.existsSync(tsxPath)) {
|
|
146
150
|
throw new Error(`renderPage: source file not found: ${tsxPath}`);
|
|
147
151
|
}
|
|
148
|
-
|
|
152
|
+
let usesDevPanel = showPanel && devPanelPath !== null;
|
|
153
|
+
let datMatched = false;
|
|
154
|
+
if (configDAT && configDAT == reqDAT)
|
|
155
|
+
datMatched = true;
|
|
156
|
+
if (configDAT && Array.isArray(configDAT) && configDAT.includes(reqDAT || ""))
|
|
157
|
+
datMatched = true;
|
|
158
|
+
if (configDAT == undefined)
|
|
159
|
+
datMatched = true;
|
|
160
|
+
if (!datMatched && usesDevPanel)
|
|
161
|
+
usesDevPanel = false;
|
|
149
162
|
const templatePath = resolveTemplate(appDir, autoPageDir, autoPaging);
|
|
150
163
|
const tempPath = tempFileForTsx(tsxPath);
|
|
151
164
|
const serverCjsPath = tempPath.replace(/\.json$/, ".server.cjs");
|
|
@@ -205,5 +218,6 @@ export async function renderPage(tsxPath, reqUrl, showPanel = true, compiler = '
|
|
|
205
218
|
const devPanelContainer = usesDevPanel
|
|
206
219
|
? `<div id="authtics-dev-panel-root">${devPanelHtml}</div>`
|
|
207
220
|
: "";
|
|
208
|
-
|
|
221
|
+
fileHandler ? fileHandler(clientCode.replace('\n', ''), `/${tsxPath.substring(tsxPath.lastIndexOf('/') + 1).replace(".tsx", ".js").toLowerCase()}`) : null;
|
|
222
|
+
return buildHtml({ pageHtml, clientCode, devPanelContainer, templatePath, hotReload, fileName: `/${tsxPath.substring(tsxPath.lastIndexOf('/') + 1).replace(".tsx", ".js").toLowerCase()}` });
|
|
209
223
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function ensureTempDirs(): void;
|
|
2
2
|
export declare function tempFileForTsx(tsxPath: string): string;
|
|
3
|
+
export declare function tempFileForDev(): string;
|
|
3
4
|
export declare function isTempUpToDate(tsxPath: string, tempPath: string): boolean;
|
|
4
5
|
export declare function writeTempFile(tempPath: string, content: string): void;
|
|
5
6
|
export declare function readTempFile(tempPath: string): string;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
const AUTHTICS_DIR = path.join(process.cwd(), ".authtics_host");
|
|
4
|
+
const DEV_CACHE_DIR = path.join(AUTHTICS_DIR, "dev-cache");
|
|
4
5
|
const CACHE_DIR = path.join(AUTHTICS_DIR, "cache");
|
|
5
6
|
export function ensureTempDirs() {
|
|
6
7
|
if (!fs.existsSync(AUTHTICS_DIR))
|
|
7
8
|
fs.mkdirSync(AUTHTICS_DIR, { recursive: true });
|
|
8
9
|
if (!fs.existsSync(CACHE_DIR))
|
|
9
10
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
11
|
+
if (!fs.existsSync(DEV_CACHE_DIR))
|
|
12
|
+
fs.mkdirSync(DEV_CACHE_DIR, { recursive: true });
|
|
10
13
|
}
|
|
11
14
|
export function tempFileForTsx(tsxPath) {
|
|
12
15
|
ensureTempDirs();
|
|
@@ -14,6 +17,10 @@ export function tempFileForTsx(tsxPath) {
|
|
|
14
17
|
const hash = simpleHash(tsxPath);
|
|
15
18
|
return path.join(CACHE_DIR, `${base}_${hash}.json`);
|
|
16
19
|
}
|
|
20
|
+
export function tempFileForDev() {
|
|
21
|
+
ensureTempDirs();
|
|
22
|
+
return path.join(DEV_CACHE_DIR, "page.cache.json");
|
|
23
|
+
}
|
|
17
24
|
export function isTempUpToDate(tsxPath, tempPath) {
|
|
18
25
|
try {
|
|
19
26
|
const srcMtime = fs.statSync(tsxPath).mtimeMs;
|
package/dist/route.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare function RouteMap({ children }: {
|
|
2
2
|
children?: React.ReactNode;
|
|
3
3
|
}): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function Paused({ page, statusCode }: {
|
|
5
|
+
page: Function;
|
|
6
|
+
statusCode?: number;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
4
8
|
export declare function Route({ page, statusCode, at }: {
|
|
5
9
|
page: Function;
|
|
6
10
|
statusCode?: number;
|
package/dist/route.js
CHANGED
|
@@ -15,20 +15,27 @@ export function RouteMap({ children }) {
|
|
|
15
15
|
const childrenToProcess = Array.isArray(childArray.current)
|
|
16
16
|
? childArray.current
|
|
17
17
|
: [childArray.current];
|
|
18
|
+
setCurrentlyAwaiting(false);
|
|
18
19
|
childrenToProcess.forEach((child) => {
|
|
19
|
-
if (child?.
|
|
20
|
+
if (child?.type?.name === "Paused") {
|
|
21
|
+
if (window.__paused__ === true) {
|
|
22
|
+
matched.current = child.props;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (child?.props?.at === path && !window.__paused__ && !matched.current) {
|
|
20
26
|
matched.current = child.props;
|
|
21
27
|
}
|
|
22
28
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
if (!matched.current && !window.__paused__) {
|
|
31
|
+
childrenToProcess.forEach((child) => {
|
|
32
|
+
if (child?.props?.at === undefined && child?.type?.name !== "Paused" && !window.__paused__) {
|
|
33
|
+
matched.current = child.props;
|
|
34
|
+
setAt404(true);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, 500);
|
|
32
39
|
}, [path]);
|
|
33
40
|
useEffect(() => {
|
|
34
41
|
if (matched.current && !At404) {
|
|
@@ -50,6 +57,9 @@ export function RouteMap({ children }) {
|
|
|
50
57
|
return _jsx(_Fragment, {});
|
|
51
58
|
return _jsx(NotFound, {});
|
|
52
59
|
}
|
|
60
|
+
export function Paused({ page, statusCode }) {
|
|
61
|
+
return (_jsx(_Fragment, {}));
|
|
62
|
+
}
|
|
53
63
|
export function Route({ page, statusCode, at }) {
|
|
54
64
|
return (_jsx(_Fragment, {}));
|
|
55
65
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananacool467/authtics-host",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A Next.js-inspired SSR framework for Node.js with TypeScript and JSX support.",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "Authtics Host, A Next.js-inspired SSR framework for Node.js with TypeScript and JSX support.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"tsx",
|
|
33
33
|
"jsx",
|
|
34
34
|
"html",
|
|
35
|
+
"js",
|
|
35
36
|
"lightweight",
|
|
36
37
|
"hot-reload",
|
|
37
38
|
"dev",
|
|
@@ -50,8 +51,7 @@
|
|
|
50
51
|
"esbuild": "^0.27.3",
|
|
51
52
|
"jiti": "^2.6.1",
|
|
52
53
|
"lucide-react": "^0.577.0",
|
|
53
|
-
"prismjs": "^1.30.0"
|
|
54
|
-
"react-device-detect": "^2.2.3"
|
|
54
|
+
"prismjs": "^1.30.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^19.2.4",
|
package/dist/fileLocator.d.ts
DELETED
package/dist/fileLocator.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
export default function locate(fileName, fileName2) {
|
|
4
|
-
if (fileName.startsWith(".") && fileName.endsWith("/")) {
|
|
5
|
-
const dots = fileName.split("/").filter(Boolean).length;
|
|
6
|
-
let path_ = process.cwd();
|
|
7
|
-
for (let current = 0; current < dots; current++) {
|
|
8
|
-
path_ = path_.split("/").slice(0, -1).join("/");
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
resolved: path.join(path_, fileName2),
|
|
12
|
-
exists: fs.existsSync(path.join(path_, fileName2))
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
}
|