@webtypen/webframez-react 0.0.21 → 0.0.23
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/dist/http.cjs +45 -5
- package/dist/http.js +45 -5
- package/dist/index.cjs +45 -5
- package/dist/index.js +45 -5
- package/dist/router.cjs +30 -4
- package/dist/router.js +30 -4
- package/dist/types.d.ts +1 -1
- package/dist/webframez-core.cjs +45 -5
- package/dist/webframez-core.js +45 -5
- package/package.json +1 -1
package/dist/http.cjs
CHANGED
|
@@ -311,21 +311,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
311
311
|
const relativeDir = import_node_path2.default.dirname(import_node_path2.default.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
312
312
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
313
313
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
314
|
+
const catchAllCount = segments.filter(
|
|
315
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
316
|
+
).length;
|
|
314
317
|
return {
|
|
315
318
|
filePath,
|
|
316
319
|
segments,
|
|
317
|
-
staticCount
|
|
320
|
+
staticCount,
|
|
321
|
+
catchAllCount
|
|
318
322
|
};
|
|
319
323
|
}
|
|
320
324
|
function matchRoute(entry, pathname) {
|
|
321
325
|
const targetSegments = splitSegments(pathname);
|
|
322
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
326
|
const params = {};
|
|
326
327
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
327
328
|
const routeSegment = entry.segments[index];
|
|
329
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
330
|
+
if (isCatchAll) {
|
|
331
|
+
const paramName = routeSegment.slice(4, -1);
|
|
332
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const restSegments = targetSegments.slice(index);
|
|
336
|
+
if (restSegments.length === 0) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
340
|
+
return params;
|
|
341
|
+
}
|
|
328
342
|
const targetSegment = targetSegments[index];
|
|
343
|
+
if (typeof targetSegment !== "string") {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
329
346
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
330
347
|
const paramName = routeSegment.slice(1, -1);
|
|
331
348
|
if (!paramName) {
|
|
@@ -338,6 +355,9 @@ function matchRoute(entry, pathname) {
|
|
|
338
355
|
return null;
|
|
339
356
|
}
|
|
340
357
|
}
|
|
358
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
341
361
|
return params;
|
|
342
362
|
}
|
|
343
363
|
function mergeHead(...configs) {
|
|
@@ -417,6 +437,9 @@ function findBestMatch(entries, pathname) {
|
|
|
417
437
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
418
438
|
return b.entry.staticCount - a.entry.staticCount;
|
|
419
439
|
}
|
|
440
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
441
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
442
|
+
}
|
|
420
443
|
return b.entry.segments.length - a.entry.segments.length;
|
|
421
444
|
});
|
|
422
445
|
return matches[0] ?? null;
|
|
@@ -461,6 +484,9 @@ function createFileRouter(options) {
|
|
|
461
484
|
if (b.staticCount !== a.staticCount) {
|
|
462
485
|
return b.staticCount - a.staticCount;
|
|
463
486
|
}
|
|
487
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
488
|
+
return a.catchAllCount - b.catchAllCount;
|
|
489
|
+
}
|
|
464
490
|
return b.segments.length - a.segments.length;
|
|
465
491
|
});
|
|
466
492
|
}
|
|
@@ -677,6 +703,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
677
703
|
paths: [process.cwd()]
|
|
678
704
|
});
|
|
679
705
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
706
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
707
|
+
return Promise.resolve();
|
|
708
|
+
};
|
|
709
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
710
|
+
if (typeof id !== "string") {
|
|
711
|
+
return require(id);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (id.startsWith("./")) {
|
|
715
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
return require(id);
|
|
719
|
+
};
|
|
680
720
|
|
|
681
721
|
function renderHtml(model) {
|
|
682
722
|
return new Promise((resolve, reject) => {
|
|
@@ -987,7 +1027,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
987
1027
|
consumerManifest[key] = {
|
|
988
1028
|
"*": {
|
|
989
1029
|
id: entry.id,
|
|
990
|
-
chunks:
|
|
1030
|
+
chunks: [],
|
|
991
1031
|
name: entry.name ?? "*",
|
|
992
1032
|
...entry.async ? { async: entry.async } : {}
|
|
993
1033
|
}
|
package/dist/http.js
CHANGED
|
@@ -286,21 +286,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
286
286
|
const relativeDir = path2.dirname(path2.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
287
287
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
288
288
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
289
|
+
const catchAllCount = segments.filter(
|
|
290
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
291
|
+
).length;
|
|
289
292
|
return {
|
|
290
293
|
filePath,
|
|
291
294
|
segments,
|
|
292
|
-
staticCount
|
|
295
|
+
staticCount,
|
|
296
|
+
catchAllCount
|
|
293
297
|
};
|
|
294
298
|
}
|
|
295
299
|
function matchRoute(entry, pathname) {
|
|
296
300
|
const targetSegments = splitSegments(pathname);
|
|
297
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
301
|
const params = {};
|
|
301
302
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
302
303
|
const routeSegment = entry.segments[index];
|
|
304
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
305
|
+
if (isCatchAll) {
|
|
306
|
+
const paramName = routeSegment.slice(4, -1);
|
|
307
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
const restSegments = targetSegments.slice(index);
|
|
311
|
+
if (restSegments.length === 0) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
315
|
+
return params;
|
|
316
|
+
}
|
|
303
317
|
const targetSegment = targetSegments[index];
|
|
318
|
+
if (typeof targetSegment !== "string") {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
304
321
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
305
322
|
const paramName = routeSegment.slice(1, -1);
|
|
306
323
|
if (!paramName) {
|
|
@@ -313,6 +330,9 @@ function matchRoute(entry, pathname) {
|
|
|
313
330
|
return null;
|
|
314
331
|
}
|
|
315
332
|
}
|
|
333
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
316
336
|
return params;
|
|
317
337
|
}
|
|
318
338
|
function mergeHead(...configs) {
|
|
@@ -392,6 +412,9 @@ function findBestMatch(entries, pathname) {
|
|
|
392
412
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
393
413
|
return b.entry.staticCount - a.entry.staticCount;
|
|
394
414
|
}
|
|
415
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
416
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
417
|
+
}
|
|
395
418
|
return b.entry.segments.length - a.entry.segments.length;
|
|
396
419
|
});
|
|
397
420
|
return matches[0] ?? null;
|
|
@@ -436,6 +459,9 @@ function createFileRouter(options) {
|
|
|
436
459
|
if (b.staticCount !== a.staticCount) {
|
|
437
460
|
return b.staticCount - a.staticCount;
|
|
438
461
|
}
|
|
462
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
463
|
+
return a.catchAllCount - b.catchAllCount;
|
|
464
|
+
}
|
|
439
465
|
return b.segments.length - a.segments.length;
|
|
440
466
|
});
|
|
441
467
|
}
|
|
@@ -652,6 +678,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
652
678
|
paths: [process.cwd()]
|
|
653
679
|
});
|
|
654
680
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
681
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
682
|
+
return Promise.resolve();
|
|
683
|
+
};
|
|
684
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
685
|
+
if (typeof id !== "string") {
|
|
686
|
+
return require(id);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (id.startsWith("./")) {
|
|
690
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
return require(id);
|
|
694
|
+
};
|
|
655
695
|
|
|
656
696
|
function renderHtml(model) {
|
|
657
697
|
return new Promise((resolve, reject) => {
|
|
@@ -962,7 +1002,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
962
1002
|
consumerManifest[key] = {
|
|
963
1003
|
"*": {
|
|
964
1004
|
id: entry.id,
|
|
965
|
-
chunks:
|
|
1005
|
+
chunks: [],
|
|
966
1006
|
name: entry.name ?? "*",
|
|
967
1007
|
...entry.async ? { async: entry.async } : {}
|
|
968
1008
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -344,21 +344,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
344
344
|
const relativeDir = import_node_path2.default.dirname(import_node_path2.default.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
345
345
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
346
346
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
347
|
+
const catchAllCount = segments.filter(
|
|
348
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
349
|
+
).length;
|
|
347
350
|
return {
|
|
348
351
|
filePath,
|
|
349
352
|
segments,
|
|
350
|
-
staticCount
|
|
353
|
+
staticCount,
|
|
354
|
+
catchAllCount
|
|
351
355
|
};
|
|
352
356
|
}
|
|
353
357
|
function matchRoute(entry, pathname) {
|
|
354
358
|
const targetSegments = splitSegments(pathname);
|
|
355
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
359
|
const params = {};
|
|
359
360
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
360
361
|
const routeSegment = entry.segments[index];
|
|
362
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
363
|
+
if (isCatchAll) {
|
|
364
|
+
const paramName = routeSegment.slice(4, -1);
|
|
365
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
const restSegments = targetSegments.slice(index);
|
|
369
|
+
if (restSegments.length === 0) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
373
|
+
return params;
|
|
374
|
+
}
|
|
361
375
|
const targetSegment = targetSegments[index];
|
|
376
|
+
if (typeof targetSegment !== "string") {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
362
379
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
363
380
|
const paramName = routeSegment.slice(1, -1);
|
|
364
381
|
if (!paramName) {
|
|
@@ -371,6 +388,9 @@ function matchRoute(entry, pathname) {
|
|
|
371
388
|
return null;
|
|
372
389
|
}
|
|
373
390
|
}
|
|
391
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
374
394
|
return params;
|
|
375
395
|
}
|
|
376
396
|
function mergeHead(...configs) {
|
|
@@ -450,6 +470,9 @@ function findBestMatch(entries, pathname) {
|
|
|
450
470
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
451
471
|
return b.entry.staticCount - a.entry.staticCount;
|
|
452
472
|
}
|
|
473
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
474
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
475
|
+
}
|
|
453
476
|
return b.entry.segments.length - a.entry.segments.length;
|
|
454
477
|
});
|
|
455
478
|
return matches[0] ?? null;
|
|
@@ -494,6 +517,9 @@ function createFileRouter(options) {
|
|
|
494
517
|
if (b.staticCount !== a.staticCount) {
|
|
495
518
|
return b.staticCount - a.staticCount;
|
|
496
519
|
}
|
|
520
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
521
|
+
return a.catchAllCount - b.catchAllCount;
|
|
522
|
+
}
|
|
497
523
|
return b.segments.length - a.segments.length;
|
|
498
524
|
});
|
|
499
525
|
}
|
|
@@ -714,6 +740,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
714
740
|
paths: [process.cwd()]
|
|
715
741
|
});
|
|
716
742
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
743
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
744
|
+
return Promise.resolve();
|
|
745
|
+
};
|
|
746
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
747
|
+
if (typeof id !== "string") {
|
|
748
|
+
return require(id);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (id.startsWith("./")) {
|
|
752
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return require(id);
|
|
756
|
+
};
|
|
717
757
|
|
|
718
758
|
function renderHtml(model) {
|
|
719
759
|
return new Promise((resolve, reject) => {
|
|
@@ -1024,7 +1064,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
1024
1064
|
consumerManifest[key] = {
|
|
1025
1065
|
"*": {
|
|
1026
1066
|
id: entry.id,
|
|
1027
|
-
chunks:
|
|
1067
|
+
chunks: [],
|
|
1028
1068
|
name: entry.name ?? "*",
|
|
1029
1069
|
...entry.async ? { async: entry.async } : {}
|
|
1030
1070
|
}
|
package/dist/index.js
CHANGED
|
@@ -308,21 +308,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
308
308
|
const relativeDir = path2.dirname(path2.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
309
309
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
310
310
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
311
|
+
const catchAllCount = segments.filter(
|
|
312
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
313
|
+
).length;
|
|
311
314
|
return {
|
|
312
315
|
filePath,
|
|
313
316
|
segments,
|
|
314
|
-
staticCount
|
|
317
|
+
staticCount,
|
|
318
|
+
catchAllCount
|
|
315
319
|
};
|
|
316
320
|
}
|
|
317
321
|
function matchRoute(entry, pathname) {
|
|
318
322
|
const targetSegments = splitSegments(pathname);
|
|
319
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
323
|
const params = {};
|
|
323
324
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
324
325
|
const routeSegment = entry.segments[index];
|
|
326
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
327
|
+
if (isCatchAll) {
|
|
328
|
+
const paramName = routeSegment.slice(4, -1);
|
|
329
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
const restSegments = targetSegments.slice(index);
|
|
333
|
+
if (restSegments.length === 0) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
337
|
+
return params;
|
|
338
|
+
}
|
|
325
339
|
const targetSegment = targetSegments[index];
|
|
340
|
+
if (typeof targetSegment !== "string") {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
326
343
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
327
344
|
const paramName = routeSegment.slice(1, -1);
|
|
328
345
|
if (!paramName) {
|
|
@@ -335,6 +352,9 @@ function matchRoute(entry, pathname) {
|
|
|
335
352
|
return null;
|
|
336
353
|
}
|
|
337
354
|
}
|
|
355
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
338
358
|
return params;
|
|
339
359
|
}
|
|
340
360
|
function mergeHead(...configs) {
|
|
@@ -414,6 +434,9 @@ function findBestMatch(entries, pathname) {
|
|
|
414
434
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
415
435
|
return b.entry.staticCount - a.entry.staticCount;
|
|
416
436
|
}
|
|
437
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
438
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
439
|
+
}
|
|
417
440
|
return b.entry.segments.length - a.entry.segments.length;
|
|
418
441
|
});
|
|
419
442
|
return matches[0] ?? null;
|
|
@@ -458,6 +481,9 @@ function createFileRouter(options) {
|
|
|
458
481
|
if (b.staticCount !== a.staticCount) {
|
|
459
482
|
return b.staticCount - a.staticCount;
|
|
460
483
|
}
|
|
484
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
485
|
+
return a.catchAllCount - b.catchAllCount;
|
|
486
|
+
}
|
|
461
487
|
return b.segments.length - a.segments.length;
|
|
462
488
|
});
|
|
463
489
|
}
|
|
@@ -678,6 +704,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
678
704
|
paths: [process.cwd()]
|
|
679
705
|
});
|
|
680
706
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
707
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
708
|
+
return Promise.resolve();
|
|
709
|
+
};
|
|
710
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
711
|
+
if (typeof id !== "string") {
|
|
712
|
+
return require(id);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (id.startsWith("./")) {
|
|
716
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return require(id);
|
|
720
|
+
};
|
|
681
721
|
|
|
682
722
|
function renderHtml(model) {
|
|
683
723
|
return new Promise((resolve, reject) => {
|
|
@@ -988,7 +1028,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
988
1028
|
consumerManifest[key] = {
|
|
989
1029
|
"*": {
|
|
990
1030
|
id: entry.id,
|
|
991
|
-
chunks:
|
|
1031
|
+
chunks: [],
|
|
992
1032
|
name: entry.name ?? "*",
|
|
993
1033
|
...entry.async ? { async: entry.async } : {}
|
|
994
1034
|
}
|
package/dist/router.cjs
CHANGED
|
@@ -202,21 +202,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
202
202
|
const relativeDir = import_node_path.default.dirname(import_node_path.default.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
203
203
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
204
204
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
205
|
+
const catchAllCount = segments.filter(
|
|
206
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
207
|
+
).length;
|
|
205
208
|
return {
|
|
206
209
|
filePath,
|
|
207
210
|
segments,
|
|
208
|
-
staticCount
|
|
211
|
+
staticCount,
|
|
212
|
+
catchAllCount
|
|
209
213
|
};
|
|
210
214
|
}
|
|
211
215
|
function matchRoute(entry, pathname) {
|
|
212
216
|
const targetSegments = splitSegments(pathname);
|
|
213
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
217
|
const params = {};
|
|
217
218
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
218
219
|
const routeSegment = entry.segments[index];
|
|
220
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
221
|
+
if (isCatchAll) {
|
|
222
|
+
const paramName = routeSegment.slice(4, -1);
|
|
223
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const restSegments = targetSegments.slice(index);
|
|
227
|
+
if (restSegments.length === 0) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
231
|
+
return params;
|
|
232
|
+
}
|
|
219
233
|
const targetSegment = targetSegments[index];
|
|
234
|
+
if (typeof targetSegment !== "string") {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
220
237
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
221
238
|
const paramName = routeSegment.slice(1, -1);
|
|
222
239
|
if (!paramName) {
|
|
@@ -229,6 +246,9 @@ function matchRoute(entry, pathname) {
|
|
|
229
246
|
return null;
|
|
230
247
|
}
|
|
231
248
|
}
|
|
249
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
232
252
|
return params;
|
|
233
253
|
}
|
|
234
254
|
function mergeHead(...configs) {
|
|
@@ -308,6 +328,9 @@ function findBestMatch(entries, pathname) {
|
|
|
308
328
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
309
329
|
return b.entry.staticCount - a.entry.staticCount;
|
|
310
330
|
}
|
|
331
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
332
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
333
|
+
}
|
|
311
334
|
return b.entry.segments.length - a.entry.segments.length;
|
|
312
335
|
});
|
|
313
336
|
return matches[0] ?? null;
|
|
@@ -352,6 +375,9 @@ function createFileRouter(options) {
|
|
|
352
375
|
if (b.staticCount !== a.staticCount) {
|
|
353
376
|
return b.staticCount - a.staticCount;
|
|
354
377
|
}
|
|
378
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
379
|
+
return a.catchAllCount - b.catchAllCount;
|
|
380
|
+
}
|
|
355
381
|
return b.segments.length - a.segments.length;
|
|
356
382
|
});
|
|
357
383
|
}
|
package/dist/router.js
CHANGED
|
@@ -172,21 +172,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
172
172
|
const relativeDir = path.dirname(path.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
173
173
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
174
174
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
175
|
+
const catchAllCount = segments.filter(
|
|
176
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
177
|
+
).length;
|
|
175
178
|
return {
|
|
176
179
|
filePath,
|
|
177
180
|
segments,
|
|
178
|
-
staticCount
|
|
181
|
+
staticCount,
|
|
182
|
+
catchAllCount
|
|
179
183
|
};
|
|
180
184
|
}
|
|
181
185
|
function matchRoute(entry, pathname) {
|
|
182
186
|
const targetSegments = splitSegments(pathname);
|
|
183
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
187
|
const params = {};
|
|
187
188
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
188
189
|
const routeSegment = entry.segments[index];
|
|
190
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
191
|
+
if (isCatchAll) {
|
|
192
|
+
const paramName = routeSegment.slice(4, -1);
|
|
193
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const restSegments = targetSegments.slice(index);
|
|
197
|
+
if (restSegments.length === 0) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
201
|
+
return params;
|
|
202
|
+
}
|
|
189
203
|
const targetSegment = targetSegments[index];
|
|
204
|
+
if (typeof targetSegment !== "string") {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
190
207
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
191
208
|
const paramName = routeSegment.slice(1, -1);
|
|
192
209
|
if (!paramName) {
|
|
@@ -199,6 +216,9 @@ function matchRoute(entry, pathname) {
|
|
|
199
216
|
return null;
|
|
200
217
|
}
|
|
201
218
|
}
|
|
219
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
202
222
|
return params;
|
|
203
223
|
}
|
|
204
224
|
function mergeHead(...configs) {
|
|
@@ -278,6 +298,9 @@ function findBestMatch(entries, pathname) {
|
|
|
278
298
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
279
299
|
return b.entry.staticCount - a.entry.staticCount;
|
|
280
300
|
}
|
|
301
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
302
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
303
|
+
}
|
|
281
304
|
return b.entry.segments.length - a.entry.segments.length;
|
|
282
305
|
});
|
|
283
306
|
return matches[0] ?? null;
|
|
@@ -322,6 +345,9 @@ function createFileRouter(options) {
|
|
|
322
345
|
if (b.staticCount !== a.staticCount) {
|
|
323
346
|
return b.staticCount - a.staticCount;
|
|
324
347
|
}
|
|
348
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
349
|
+
return a.catchAllCount - b.catchAllCount;
|
|
350
|
+
}
|
|
325
351
|
return b.segments.length - a.segments.length;
|
|
326
352
|
});
|
|
327
353
|
}
|
package/dist/types.d.ts
CHANGED
package/dist/webframez-core.cjs
CHANGED
|
@@ -314,21 +314,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
314
314
|
const relativeDir = import_node_path2.default.dirname(import_node_path2.default.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
315
315
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
316
316
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
317
|
+
const catchAllCount = segments.filter(
|
|
318
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
319
|
+
).length;
|
|
317
320
|
return {
|
|
318
321
|
filePath,
|
|
319
322
|
segments,
|
|
320
|
-
staticCount
|
|
323
|
+
staticCount,
|
|
324
|
+
catchAllCount
|
|
321
325
|
};
|
|
322
326
|
}
|
|
323
327
|
function matchRoute(entry, pathname) {
|
|
324
328
|
const targetSegments = splitSegments(pathname);
|
|
325
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
329
|
const params = {};
|
|
329
330
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
330
331
|
const routeSegment = entry.segments[index];
|
|
332
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
333
|
+
if (isCatchAll) {
|
|
334
|
+
const paramName = routeSegment.slice(4, -1);
|
|
335
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
const restSegments = targetSegments.slice(index);
|
|
339
|
+
if (restSegments.length === 0) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
343
|
+
return params;
|
|
344
|
+
}
|
|
331
345
|
const targetSegment = targetSegments[index];
|
|
346
|
+
if (typeof targetSegment !== "string") {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
332
349
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
333
350
|
const paramName = routeSegment.slice(1, -1);
|
|
334
351
|
if (!paramName) {
|
|
@@ -341,6 +358,9 @@ function matchRoute(entry, pathname) {
|
|
|
341
358
|
return null;
|
|
342
359
|
}
|
|
343
360
|
}
|
|
361
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
344
364
|
return params;
|
|
345
365
|
}
|
|
346
366
|
function mergeHead(...configs) {
|
|
@@ -420,6 +440,9 @@ function findBestMatch(entries, pathname) {
|
|
|
420
440
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
421
441
|
return b.entry.staticCount - a.entry.staticCount;
|
|
422
442
|
}
|
|
443
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
444
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
445
|
+
}
|
|
423
446
|
return b.entry.segments.length - a.entry.segments.length;
|
|
424
447
|
});
|
|
425
448
|
return matches[0] ?? null;
|
|
@@ -464,6 +487,9 @@ function createFileRouter(options) {
|
|
|
464
487
|
if (b.staticCount !== a.staticCount) {
|
|
465
488
|
return b.staticCount - a.staticCount;
|
|
466
489
|
}
|
|
490
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
491
|
+
return a.catchAllCount - b.catchAllCount;
|
|
492
|
+
}
|
|
467
493
|
return b.segments.length - a.segments.length;
|
|
468
494
|
});
|
|
469
495
|
}
|
|
@@ -680,6 +706,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
680
706
|
paths: [process.cwd()]
|
|
681
707
|
});
|
|
682
708
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
709
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
710
|
+
return Promise.resolve();
|
|
711
|
+
};
|
|
712
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
713
|
+
if (typeof id !== "string") {
|
|
714
|
+
return require(id);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
if (id.startsWith("./")) {
|
|
718
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return require(id);
|
|
722
|
+
};
|
|
683
723
|
|
|
684
724
|
function renderHtml(model) {
|
|
685
725
|
return new Promise((resolve, reject) => {
|
|
@@ -990,7 +1030,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
990
1030
|
consumerManifest[key] = {
|
|
991
1031
|
"*": {
|
|
992
1032
|
id: entry.id,
|
|
993
|
-
chunks:
|
|
1033
|
+
chunks: [],
|
|
994
1034
|
name: entry.name ?? "*",
|
|
995
1035
|
...entry.async ? { async: entry.async } : {}
|
|
996
1036
|
}
|
package/dist/webframez-core.js
CHANGED
|
@@ -286,21 +286,38 @@ function toRouteEntry(pagesDir, filePath) {
|
|
|
286
286
|
const relativeDir = path2.dirname(path2.relative(pagesDir, filePath)).replace(/\\/g, "/");
|
|
287
287
|
const segments = relativeDir === "." ? [] : relativeDir.split("/").filter(Boolean);
|
|
288
288
|
const staticCount = segments.filter((segment) => !segment.startsWith("[")).length;
|
|
289
|
+
const catchAllCount = segments.filter(
|
|
290
|
+
(segment) => segment.startsWith("[...") && segment.endsWith("]")
|
|
291
|
+
).length;
|
|
289
292
|
return {
|
|
290
293
|
filePath,
|
|
291
294
|
segments,
|
|
292
|
-
staticCount
|
|
295
|
+
staticCount,
|
|
296
|
+
catchAllCount
|
|
293
297
|
};
|
|
294
298
|
}
|
|
295
299
|
function matchRoute(entry, pathname) {
|
|
296
300
|
const targetSegments = splitSegments(pathname);
|
|
297
|
-
if (entry.segments.length !== targetSegments.length) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
301
|
const params = {};
|
|
301
302
|
for (let index = 0; index < entry.segments.length; index += 1) {
|
|
302
303
|
const routeSegment = entry.segments[index];
|
|
304
|
+
const isCatchAll = routeSegment.startsWith("[...") && routeSegment.endsWith("]");
|
|
305
|
+
if (isCatchAll) {
|
|
306
|
+
const paramName = routeSegment.slice(4, -1);
|
|
307
|
+
if (!paramName || index !== entry.segments.length - 1) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
const restSegments = targetSegments.slice(index);
|
|
311
|
+
if (restSegments.length === 0) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
params[paramName] = restSegments.map((segment) => decodeURIComponent(segment));
|
|
315
|
+
return params;
|
|
316
|
+
}
|
|
303
317
|
const targetSegment = targetSegments[index];
|
|
318
|
+
if (typeof targetSegment !== "string") {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
304
321
|
if (routeSegment.startsWith("[") && routeSegment.endsWith("]")) {
|
|
305
322
|
const paramName = routeSegment.slice(1, -1);
|
|
306
323
|
if (!paramName) {
|
|
@@ -313,6 +330,9 @@ function matchRoute(entry, pathname) {
|
|
|
313
330
|
return null;
|
|
314
331
|
}
|
|
315
332
|
}
|
|
333
|
+
if (entry.segments.length !== targetSegments.length) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
316
336
|
return params;
|
|
317
337
|
}
|
|
318
338
|
function mergeHead(...configs) {
|
|
@@ -392,6 +412,9 @@ function findBestMatch(entries, pathname) {
|
|
|
392
412
|
if (b.entry.staticCount !== a.entry.staticCount) {
|
|
393
413
|
return b.entry.staticCount - a.entry.staticCount;
|
|
394
414
|
}
|
|
415
|
+
if (a.entry.catchAllCount !== b.entry.catchAllCount) {
|
|
416
|
+
return a.entry.catchAllCount - b.entry.catchAllCount;
|
|
417
|
+
}
|
|
395
418
|
return b.entry.segments.length - a.entry.segments.length;
|
|
396
419
|
});
|
|
397
420
|
return matches[0] ?? null;
|
|
@@ -436,6 +459,9 @@ function createFileRouter(options) {
|
|
|
436
459
|
if (b.staticCount !== a.staticCount) {
|
|
437
460
|
return b.staticCount - a.staticCount;
|
|
438
461
|
}
|
|
462
|
+
if (a.catchAllCount !== b.catchAllCount) {
|
|
463
|
+
return a.catchAllCount - b.catchAllCount;
|
|
464
|
+
}
|
|
439
465
|
return b.segments.length - a.segments.length;
|
|
440
466
|
});
|
|
441
467
|
}
|
|
@@ -652,6 +678,20 @@ const reactDomPkg = require.resolve("react-dom/package.json", {
|
|
|
652
678
|
paths: [process.cwd()]
|
|
653
679
|
});
|
|
654
680
|
const reactDomServer = require(path.join(path.dirname(reactDomPkg), "server.node.js"));
|
|
681
|
+
globalThis.__webpack_chunk_load__ = function __webframezNoopChunkLoad() {
|
|
682
|
+
return Promise.resolve();
|
|
683
|
+
};
|
|
684
|
+
globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
|
|
685
|
+
if (typeof id !== "string") {
|
|
686
|
+
return require(id);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (id.startsWith("./")) {
|
|
690
|
+
return require(path.resolve(process.cwd(), id.slice(2)));
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
return require(id);
|
|
694
|
+
};
|
|
655
695
|
|
|
656
696
|
function renderHtml(model) {
|
|
657
697
|
return new Promise((resolve, reject) => {
|
|
@@ -962,7 +1002,7 @@ function createServerConsumerManifest(manifest) {
|
|
|
962
1002
|
consumerManifest[key] = {
|
|
963
1003
|
"*": {
|
|
964
1004
|
id: entry.id,
|
|
965
|
-
chunks:
|
|
1005
|
+
chunks: [],
|
|
966
1006
|
name: entry.name ?? "*",
|
|
967
1007
|
...entry.async ? { async: entry.async } : {}
|
|
968
1008
|
}
|