added fonts
This commit is contained in:
1 parent
4134e3a234
commit
142d2986b6
9079 files changed
+1498421
-2
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
import type { Segment as FlightRouterStateSegment } from '../../../server/app-render/types';
|
||||
type Opaque<K, T> = T & {
|
||||
__brand: K;
|
||||
};
|
||||
export type EncodedSegment = Opaque<'EncodedSegment', string>;
|
||||
export declare function encodeSegment(segment: FlightRouterStateSegment): EncodedSegment;
|
||||
export declare const ROOT_SEGMENT_KEY = "";
|
||||
export declare function encodeChildSegmentKey(parentSegmentKey: string, parallelRouteKey: string, segment: EncodedSegment): string;
|
||||
export declare function convertSegmentPathToStaticExportFilename(segmentPath: string): string;
|
||||
export {};
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
ROOT_SEGMENT_KEY: null,
|
||||
convertSegmentPathToStaticExportFilename: null,
|
||||
encodeChildSegmentKey: null,
|
||||
encodeSegment: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
ROOT_SEGMENT_KEY: function() {
|
||||
return ROOT_SEGMENT_KEY;
|
||||
},
|
||||
convertSegmentPathToStaticExportFilename: function() {
|
||||
return convertSegmentPathToStaticExportFilename;
|
||||
},
|
||||
encodeChildSegmentKey: function() {
|
||||
return encodeChildSegmentKey;
|
||||
},
|
||||
encodeSegment: function() {
|
||||
return encodeSegment;
|
||||
}
|
||||
});
|
||||
const _segment = require("../segment");
|
||||
function encodeSegment(segment) {
|
||||
if (typeof segment === 'string') {
|
||||
if (segment.startsWith(_segment.PAGE_SEGMENT_KEY)) {
|
||||
// The Flight Router State type sometimes includes the search params in
|
||||
// the page segment. However, the Segment Cache tracks this as a separate
|
||||
// key. So, we strip the search params here, and then add them back when
|
||||
// the cache entry is turned back into a FlightRouterState. This is an
|
||||
// unfortunate consequence of the FlightRouteState being used both as a
|
||||
// transport type and as a cache key; we'll address this once more of the
|
||||
// Segment Cache implementation has settled.
|
||||
// TODO: We should hoist the search params out of the FlightRouterState
|
||||
// type entirely, This is our plan for dynamic route params, too.
|
||||
return _segment.PAGE_SEGMENT_KEY;
|
||||
}
|
||||
const safeName = // TODO: FlightRouterState encodes Not Found routes as "/_not-found".
|
||||
// But params typically don't include the leading slash. We should use
|
||||
// a different encoding to avoid this special case.
|
||||
segment === '/_not-found' ? '_not-found' : encodeToFilesystemAndURLSafeString(segment);
|
||||
// Since this is not a dynamic segment, it's fully encoded. It does not
|
||||
// need to be "hydrated" with a param value.
|
||||
return safeName;
|
||||
}
|
||||
const name = segment[0];
|
||||
const paramValue = segment[1];
|
||||
const paramType = segment[2];
|
||||
const safeName = encodeToFilesystemAndURLSafeString(name);
|
||||
const safeValue = encodeToFilesystemAndURLSafeString(paramValue);
|
||||
const encodedName = '$' + paramType + '$' + safeName + '$' + safeValue;
|
||||
return encodedName;
|
||||
}
|
||||
const ROOT_SEGMENT_KEY = '';
|
||||
function encodeChildSegmentKey(// TODO: Make segment keys an opaque type, too?
|
||||
parentSegmentKey, parallelRouteKey, segment) {
|
||||
// Aside from being filesystem safe, segment keys are also designed so that
|
||||
// each segment and parallel route creates its own subdirectory. Roughly in
|
||||
// the same shape as the source app directory. This is mostly just for easier
|
||||
// debugging (you can open up the build folder and navigate the output); if
|
||||
// we wanted to do we could just use a flat structure.
|
||||
// Omit the parallel route key for children, since this is the most
|
||||
// common case. Saves some bytes (and it's what the app directory does).
|
||||
const slotKey = parallelRouteKey === 'children' ? segment : "@" + encodeToFilesystemAndURLSafeString(parallelRouteKey) + "/" + segment;
|
||||
return parentSegmentKey + '/' + slotKey;
|
||||
}
|
||||
// Define a regex pattern to match the most common characters found in a route
|
||||
// param. It excludes anything that might not be cross-platform filesystem
|
||||
// compatible, like |. It does not need to be precise because the fallback is to
|
||||
// just base64url-encode the whole parameter, which is fine; we just don't do it
|
||||
// by default for compactness, and for easier debugging.
|
||||
const simpleParamValueRegex = /^[a-zA-Z0-9\-_@]+$/;
|
||||
function encodeToFilesystemAndURLSafeString(value) {
|
||||
if (simpleParamValueRegex.test(value)) {
|
||||
return value;
|
||||
}
|
||||
// If there are any unsafe characters, base64url-encode the entire value.
|
||||
// We also add a ! prefix so it doesn't collide with the simple case.
|
||||
const base64url = btoa(value).replace(/\+/g, '-') // Replace '+' with '-'
|
||||
.replace(/\//g, '_') // Replace '/' with '_'
|
||||
.replace(/=+$/, '') // Remove trailing '='
|
||||
;
|
||||
return '!' + base64url;
|
||||
}
|
||||
function convertSegmentPathToStaticExportFilename(segmentPath) {
|
||||
return "__next" + segmentPath.replace(/\//g, '.') + ".txt";
|
||||
}
|
||||
|
||||
//# sourceMappingURL=segment-value-encoding.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/segment-cache/segment-value-encoding.ts"],"sourcesContent":["import { PAGE_SEGMENT_KEY } from '../segment'\nimport type { Segment as FlightRouterStateSegment } from '../../../server/app-render/types'\n\n// TypeScript trick to simulate opaque types, like in Flow.\ntype Opaque<K, T> = T & { __brand: K }\n\nexport type EncodedSegment = Opaque<'EncodedSegment', string>\n\nexport function encodeSegment(\n segment: FlightRouterStateSegment\n): EncodedSegment {\n if (typeof segment === 'string') {\n if (segment.startsWith(PAGE_SEGMENT_KEY)) {\n // The Flight Router State type sometimes includes the search params in\n // the page segment. However, the Segment Cache tracks this as a separate\n // key. So, we strip the search params here, and then add them back when\n // the cache entry is turned back into a FlightRouterState. This is an\n // unfortunate consequence of the FlightRouteState being used both as a\n // transport type and as a cache key; we'll address this once more of the\n // Segment Cache implementation has settled.\n // TODO: We should hoist the search params out of the FlightRouterState\n // type entirely, This is our plan for dynamic route params, too.\n return PAGE_SEGMENT_KEY as EncodedSegment\n }\n const safeName =\n // TODO: FlightRouterState encodes Not Found routes as \"/_not-found\".\n // But params typically don't include the leading slash. We should use\n // a different encoding to avoid this special case.\n segment === '/_not-found'\n ? '_not-found'\n : encodeToFilesystemAndURLSafeString(segment)\n // Since this is not a dynamic segment, it's fully encoded. It does not\n // need to be \"hydrated\" with a param value.\n return safeName as EncodedSegment\n }\n const name = segment[0]\n const paramValue = segment[1]\n const paramType = segment[2]\n const safeName = encodeToFilesystemAndURLSafeString(name)\n const safeValue = encodeToFilesystemAndURLSafeString(paramValue)\n\n const encodedName = '$' + paramType + '$' + safeName + '$' + safeValue\n return encodedName as EncodedSegment\n}\n\nexport const ROOT_SEGMENT_KEY = ''\n\nexport function encodeChildSegmentKey(\n // TODO: Make segment keys an opaque type, too?\n parentSegmentKey: string,\n parallelRouteKey: string,\n segment: EncodedSegment\n): string {\n // Aside from being filesystem safe, segment keys are also designed so that\n // each segment and parallel route creates its own subdirectory. Roughly in\n // the same shape as the source app directory. This is mostly just for easier\n // debugging (you can open up the build folder and navigate the output); if\n // we wanted to do we could just use a flat structure.\n\n // Omit the parallel route key for children, since this is the most\n // common case. Saves some bytes (and it's what the app directory does).\n const slotKey =\n parallelRouteKey === 'children'\n ? segment\n : `@${encodeToFilesystemAndURLSafeString(parallelRouteKey)}/${segment}`\n\n return parentSegmentKey + '/' + slotKey\n}\n\n// Define a regex pattern to match the most common characters found in a route\n// param. It excludes anything that might not be cross-platform filesystem\n// compatible, like |. It does not need to be precise because the fallback is to\n// just base64url-encode the whole parameter, which is fine; we just don't do it\n// by default for compactness, and for easier debugging.\nconst simpleParamValueRegex = /^[a-zA-Z0-9\\-_@]+$/\n\nfunction encodeToFilesystemAndURLSafeString(value: string) {\n if (simpleParamValueRegex.test(value)) {\n return value\n }\n // If there are any unsafe characters, base64url-encode the entire value.\n // We also add a ! prefix so it doesn't collide with the simple case.\n const base64url = btoa(value)\n .replace(/\\+/g, '-') // Replace '+' with '-'\n .replace(/\\//g, '_') // Replace '/' with '_'\n .replace(/=+$/, '') // Remove trailing '='\n return '!' + base64url\n}\n\nexport function convertSegmentPathToStaticExportFilename(\n segmentPath: string\n): string {\n return `__next${segmentPath.replace(/\\//g, '.')}.txt`\n}\n"],"names":["ROOT_SEGMENT_KEY","convertSegmentPathToStaticExportFilename","encodeChildSegmentKey","encodeSegment","segment","startsWith","PAGE_SEGMENT_KEY","safeName","encodeToFilesystemAndURLSafeString","name","paramValue","paramType","safeValue","encodedName","parentSegmentKey","parallelRouteKey","slotKey","simpleParamValueRegex","value","test","base64url","btoa","replace","segmentPath"],"mappings":";;;;;;;;;;;;;;;;;IA6CaA,gBAAgB;eAAhBA;;IA4CGC,wCAAwC;eAAxCA;;IA1CAC,qBAAqB;eAArBA;;IAvCAC,aAAa;eAAbA;;;yBARiB;AAQ1B,SAASA,cACdC,OAAiC;IAEjC,IAAI,OAAOA,YAAY,UAAU;QAC/B,IAAIA,QAAQC,UAAU,CAACC,yBAAgB,GAAG;YACxC,uEAAuE;YACvE,yEAAyE;YACzE,wEAAwE;YACxE,sEAAsE;YACtE,uEAAuE;YACvE,yEAAyE;YACzE,4CAA4C;YAC5C,uEAAuE;YACvE,iEAAiE;YACjE,OAAOA,yBAAgB;QACzB;QACA,MAAMC,Line truncated
|
||||
Reference in new issue
Block a user