🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

View file

@ -0,0 +1,9 @@
/**
* @param {Record<string, string>} attributes
* @param {string} property
* @returns {string}
*/
export function caseInsensitiveTransform(
attributes: Record<string, string>,
property: string
): string

View file

@ -0,0 +1,10 @@
import {caseSensitiveTransform} from './case-sensitive-transform.js'
/**
* @param {Record<string, string>} attributes
* @param {string} property
* @returns {string}
*/
export function caseInsensitiveTransform(attributes, property) {
return caseSensitiveTransform(attributes, property.toLowerCase())
}

View file

@ -0,0 +1,9 @@
/**
* @param {Record<string, string>} attributes
* @param {string} attribute
* @returns {string}
*/
export function caseSensitiveTransform(
attributes: Record<string, string>,
attribute: string
): string

View file

@ -0,0 +1,8 @@
/**
* @param {Record<string, string>} attributes
* @param {string} attribute
* @returns {string}
*/
export function caseSensitiveTransform(attributes, attribute) {
return attribute in attributes ? attributes[attribute] : attribute
}

16
node_modules/property-information/lib/util/create.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* @param {Definition} definition
* @returns {Schema}
*/
export function create(definition: Definition): Schema
export type Properties = import('./schema.js').Properties
export type Normal = import('./schema.js').Normal
export type Attributes = Record<string, string>
export type Definition = {
properties: Record<string, number | null>
transform: (attributes: Attributes, property: string) => string
space?: string | undefined
attributes?: Attributes | undefined
mustUseProperty?: string[] | undefined
}
import {Schema} from './schema.js'

58
node_modules/property-information/lib/util/create.js generated vendored Normal file
View file

@ -0,0 +1,58 @@
/**
* @typedef {import('./schema.js').Properties} Properties
* @typedef {import('./schema.js').Normal} Normal
*
* @typedef {Record<string, string>} Attributes
*
* @typedef {Object} Definition
* @property {Record<string, number|null>} properties
* @property {(attributes: Attributes, property: string) => string} transform
* @property {string} [space]
* @property {Attributes} [attributes]
* @property {Array<string>} [mustUseProperty]
*/
import {normalize} from '../normalize.js'
import {Schema} from './schema.js'
import {DefinedInfo} from './defined-info.js'
const own = {}.hasOwnProperty
/**
* @param {Definition} definition
* @returns {Schema}
*/
export function create(definition) {
/** @type {Properties} */
const property = {}
/** @type {Normal} */
const normal = {}
/** @type {string} */
let prop
for (prop in definition.properties) {
if (own.call(definition.properties, prop)) {
const value = definition.properties[prop]
const info = new DefinedInfo(
prop,
definition.transform(definition.attributes || {}, prop),
value,
definition.space
)
if (
definition.mustUseProperty &&
definition.mustUseProperty.includes(prop)
) {
info.mustUseProperty = true
}
property[prop] = info
normal[normalize(prop)] = prop
normal[normalize(info.attribute)] = prop
}
}
return new Schema(property, normal, definition.space)
}

View file

@ -0,0 +1,16 @@
export class DefinedInfo extends Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
* @param {number|null} [mask]
* @param {string} [space]
*/
constructor(
property: string,
attribute: string,
mask?: number | null | undefined,
space?: string | undefined
)
}
import {Info} from './info.js'

View file

@ -0,0 +1,44 @@
import {Info} from './info.js'
import * as types from './types.js'
/** @type {Array<keyof types>} */
// @ts-expect-error: hush.
const checks = Object.keys(types)
export class DefinedInfo extends Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
* @param {number|null} [mask]
* @param {string} [space]
*/
constructor(property, attribute, mask, space) {
let index = -1
super(property, attribute)
mark(this, 'space', space)
if (typeof mask === 'number') {
while (++index < checks.length) {
const check = checks[index]
mark(this, checks[index], (mask & types[check]) === types[check])
}
}
}
}
DefinedInfo.prototype.defined = true
/**
* @param {DefinedInfo} values
* @param {string} key
* @param {unknown} value
*/
function mark(values, key, value) {
if (value) {
// @ts-expect-error: assume `value` matches the expected value of `key`.
values[key] = value
}
}

23
node_modules/property-information/lib/util/info.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
export class Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
*/
constructor(property: string, attribute: string)
/** @type {string} */
property: string
/** @type {string} */
attribute: string
/** @type {string|null} */
space: string | null
boolean: boolean
booleanish: boolean
overloadedBoolean: boolean
number: boolean
commaSeparated: boolean
spaceSeparated: boolean
commaOrSpaceSeparated: boolean
mustUseProperty: boolean
defined: boolean
}

25
node_modules/property-information/lib/util/info.js generated vendored Normal file
View file

@ -0,0 +1,25 @@
export class Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
*/
constructor(property, attribute) {
/** @type {string} */
this.property = property
/** @type {string} */
this.attribute = attribute
}
}
/** @type {string|null} */
Info.prototype.space = null
Info.prototype.boolean = false
Info.prototype.booleanish = false
Info.prototype.overloadedBoolean = false
Info.prototype.number = false
Info.prototype.commaSeparated = false
Info.prototype.spaceSeparated = false
Info.prototype.commaOrSpaceSeparated = false
Info.prototype.mustUseProperty = false
Info.prototype.defined = false

View file

@ -0,0 +1,9 @@
/**
* @param {Schema[]} definitions
* @param {string} [space]
* @returns {Schema}
*/
export function merge(definitions: Schema[], space?: string | undefined): Schema
export type Properties = import('./schema.js').Properties
export type Normal = import('./schema.js').Normal
import {Schema} from './schema.js'

26
node_modules/property-information/lib/util/merge.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
/**
* @typedef {import('./schema.js').Properties} Properties
* @typedef {import('./schema.js').Normal} Normal
*/
import {Schema} from './schema.js'
/**
* @param {Schema[]} definitions
* @param {string} [space]
* @returns {Schema}
*/
export function merge(definitions, space) {
/** @type {Properties} */
const property = {}
/** @type {Normal} */
const normal = {}
let index = -1
while (++index < definitions.length) {
Object.assign(property, definitions[index].property)
Object.assign(normal, definitions[index].normal)
}
return new Schema(property, normal, space)
}

20
node_modules/property-information/lib/util/schema.d.ts generated vendored Normal file
View file

@ -0,0 +1,20 @@
/**
* @typedef {import('./info.js').Info} Info
* @typedef {Record<string, Info>} Properties
* @typedef {Record<string, string>} Normal
*/
export class Schema {
/**
* @constructor
* @param {Properties} property
* @param {Normal} normal
* @param {string} [space]
*/
constructor(property: Properties, normal: Normal, space?: string | undefined)
property: Properties
normal: Normal
space: string | null
}
export type Info = import('./info.js').Info
export type Properties = Record<string, Info>
export type Normal = Record<string, string>

28
node_modules/property-information/lib/util/schema.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
/**
* @typedef {import('./info.js').Info} Info
* @typedef {Record<string, Info>} Properties
* @typedef {Record<string, string>} Normal
*/
export class Schema {
/**
* @constructor
* @param {Properties} property
* @param {Normal} normal
* @param {string} [space]
*/
constructor(property, normal, space) {
this.property = property
this.normal = normal
if (space) {
this.space = space
}
}
}
/** @type {Properties} */
Schema.prototype.property = {}
/** @type {Normal} */
Schema.prototype.normal = {}
/** @type {string|null} */
Schema.prototype.space = null

View file

@ -0,0 +1,7 @@
export const boolean: number
export const booleanish: number
export const overloadedBoolean: number
export const number: number
export const spaceSeparated: number
export const commaSeparated: number
export const commaOrSpaceSeparated: number

13
node_modules/property-information/lib/util/types.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
let powers = 0
export const boolean = increment()
export const booleanish = increment()
export const overloadedBoolean = increment()
export const number = increment()
export const spaceSeparated = increment()
export const commaSeparated = increment()
export const commaOrSpaceSeparated = increment()
function increment() {
return 2 ** ++powers
}