This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

21
node_modules/@riotjs/util/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Gianluca Guarini
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

19
node_modules/@riotjs/util/README.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
# @riotjs/util
Riot.js shared util scripts
[![Build Status][ci-image]][ci-url]
[![Issue Count][codeclimate-image]][codeclimate-url]
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]
[ci-image]:https://img.shields.io/github/workflow/status/riot/util/test?style=flat-square
[ci-url]:https://github.com/riot/util/actions
[license-image]: https://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
[license-url]: LICENSE
[npm-version-image]: https://img.shields.io/npm/v/@riotjs/util.svg?style=flat-square
[npm-downloads-image]: https://img.shields.io/npm/dm/@riotjs/util.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@riotjs/util
[codeclimate-image]: https://api.codeclimate.com/v1/badges/352cc9afc317e20f7f0a/maintainability
[codeclimate-url]: https://codeclimate.com/github/riot/util

13
node_modules/@riotjs/util/binding-types.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export const EACH = 0
export const IF = 1
export const SIMPLE = 2
export const TAG = 3
export const SLOT = 4
export default {
EACH,
IF,
SIMPLE,
TAG,
SLOT
}

73
node_modules/@riotjs/util/checks.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/**
* Quick type checking
* @param {*} element - anything
* @param {string} type - type definition
* @returns {boolean} true if the type corresponds
*/
export function checkType(element, type) {
return typeof element === type
}
/**
* Check if an element is part of an svg
* @param {HTMLElement} el - element to check
* @returns {boolean} true if we are in an svg context
*/
export function isSvg(el) {
const owner = el.ownerSVGElement
return !!owner || owner === null
}
/**
* Check if an element is a template tag
* @param {HTMLElement} el - element to check
* @returns {boolean} true if it's a <template>
*/
export function isTemplate(el) {
return el.tagName.toLowerCase() === 'template'
}
/**
* Check that will be passed if its argument is a function
* @param {*} value - value to check
* @returns {boolean} - true if the value is a function
*/
export function isFunction(value) {
return checkType(value, 'function')
}
/**
* Check if a value is a Boolean
* @param {*} value - anything
* @returns {boolean} true only for the value is a boolean
*/
export function isBoolean(value) {
return checkType(value, 'boolean')
}
/**
* Check if a value is an Object
* @param {*} value - anything
* @returns {boolean} true only for the value is an object
*/
export function isObject(value) {
return !isNil(value) && value.constructor === Object
}
/**
* Check if a value is null or undefined
* @param {*} value - anything
* @returns {boolean} true only for the 'undefined' and 'null' types
*/
export function isNil(value) {
return value === null || value === undefined
}
/**
* Detect node js environements
* @returns {boolean} true if the runtime is node
*/
export function isNode() {
return typeof process !== 'undefined'
}

27
node_modules/@riotjs/util/constants.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
// Riot.js constants that can be used accross more modules
export const
COMPONENTS_IMPLEMENTATION_MAP = new Map(),
DOM_COMPONENT_INSTANCE_PROPERTY = Symbol('riot-component'),
PLUGINS_SET = new Set(),
IS_DIRECTIVE = 'is',
VALUE_ATTRIBUTE = 'value',
MOUNT_METHOD_KEY = 'mount',
UPDATE_METHOD_KEY = 'update',
UNMOUNT_METHOD_KEY = 'unmount',
SHOULD_UPDATE_KEY = 'shouldUpdate',
ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
ON_MOUNTED_KEY = 'onMounted',
ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
ON_UPDATED_KEY = 'onUpdated',
ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
ON_UNMOUNTED_KEY = 'onUnmounted',
PROPS_KEY = 'props',
STATE_KEY = 'state',
SLOTS_KEY = 'slots',
ROOT_KEY = 'root',
IS_PURE_SYMBOL = Symbol('pure'),
IS_COMPONENT_UPDATING = Symbol('is_updating'),
PARENT_KEY_SYMBOL = Symbol('parent'),
ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
TEMPLATE_KEY_SYMBOL = Symbol('template')

70
node_modules/@riotjs/util/dom.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import {dashToCamelCase} from './strings'
/**
* Get all the element attributes as object
* @param {HTMLElement} element - DOM node we want to parse
* @returns {Object} all the attributes found as a key value pairs
*/
export function DOMattributesToObject(element) {
return Array.from(element.attributes).reduce((acc, attribute) => {
acc[dashToCamelCase(attribute.name)] = attribute.value
return acc
}, {})
}
/**
* Move all the child nodes from a source tag to another
* @param {HTMLElement} source - source node
* @param {HTMLElement} target - target node
* @returns {undefined} it's a void method ¯\_(ツ)_/¯
*/
// Ignore this helper because it's needed only for svg tags
export function moveChildren(source, target) {
if (source.firstChild) {
target.appendChild(source.firstChild)
moveChildren(source, target)
}
}
/**
* Remove the child nodes from any DOM node
* @param {HTMLElement} node - target node
* @returns {undefined}
*/
export function cleanNode(node) {
clearChildren(node.childNodes)
}
/**
* Clear multiple children in a node
* @param {HTMLElement[]} children - direct children nodes
* @returns {undefined}
*/
export function clearChildren(children) {
Array.from(children).forEach(removeChild)
}
/**
* Remove a node
* @param {HTMLElement}node - node to remove
* @returns {undefined}
*/
export const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node)
/**
* Insert before a node
* @param {HTMLElement} newNode - node to insert
* @param {HTMLElement} refNode - ref child
* @returns {undefined}
*/
export const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode)
/**
* Replace a node
* @param {HTMLElement} newNode - new node to add to the DOM
* @param {HTMLElement} replaced - node to replace
* @returns {undefined}
*/
export const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced)

11
node_modules/@riotjs/util/expression-types.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export const ATTRIBUTE = 0
export const EVENT = 1
export const TEXT = 2
export const VALUE = 3
export default {
ATTRIBUTE,
EVENT,
TEXT,
VALUE
}

31
node_modules/@riotjs/util/functions.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import {isFunction} from './checks'
// does simply nothing
export function noop() {
return this
}
/**
* Autobind the methods of a source object to itself
* @param {Object} source - probably a riot tag instance
* @param {Array<string>} methods - list of the methods to autobind
* @returns {Object} the original object received
*/
export function autobindMethods(source, methods) {
methods.forEach(method => {
source[method] = source[method].bind(source)
})
return source
}
/**
* Call the first argument received only if it's a function otherwise return it as it is
* @param {*} source - anything
* @returns {*} anything
*/
export function callOrAssign(source) {
return isFunction(source) ? (source.prototype && source.prototype.constructor ?
new source() : source()
) : source
}

9
node_modules/@riotjs/util/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export * from './binding-types'
export * from './checks'
export * from './constants'
export * from './dom'
export * from './expression-types'
export * from './functions'
export * from './misc'
export * from './objects'
export * from './strings'

54
node_modules/@riotjs/util/misc.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
import {ATTRIBUTE, VALUE} from './expression-types'
import {dashToCamelCase} from './strings'
/**
* Throw an error with a descriptive message
* @param { string } message - error message
* @returns { undefined } hoppla.. at this point the program should stop working
*/
export function panic(message) {
throw new Error(message)
}
/**
* Returns the memoized (cached) function.
* // borrowed from https://www.30secondsofcode.org/js/s/memoize
* @param {Function} fn - function to memoize
* @returns {Function} memoize function
*/
export function memoize(fn) {
const cache = new Map()
const cached = val => {
return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)
}
cached.cache = cache
return cached
}
/**
* Evaluate a list of attribute expressions
* @param {Array} attributes - attribute expressions generated by the riot compiler
* @returns {Object} key value pairs with the result of the computation
*/
export function evaluateAttributeExpressions(attributes) {
return attributes.reduce((acc, attribute) => {
const {value, type} = attribute
switch (true) {
// spread attribute
case !attribute.name && type === ATTRIBUTE:
return {
...acc,
...value
}
// value attribute
case type === VALUE:
acc.value = attribute.value
break
// normal attributes
default:
acc[dashToCamelCase(attribute.name)] = attribute.value
}
return acc
}, {})
}

60
node_modules/@riotjs/util/objects.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/**
* Helper function to set an immutable property
* @param {Object} source - object where the new property will be set
* @param {string} key - object key where the new property will be stored
* @param {*} value - value of the new property
* @param {Object} options - set the propery overriding the default options
* @returns {Object} - the original object modified
*/
export function defineProperty(source, key, value, options = {}) {
/* eslint-disable fp/no-mutating-methods */
Object.defineProperty(source, key, {
value,
enumerable: false,
writable: false,
configurable: true,
...options
})
/* eslint-enable fp/no-mutating-methods */
return source
}
/**
* Define multiple properties on a target object
* @param {Object} source - object where the new properties will be set
* @param {Object} properties - object containing as key pair the key + value properties
* @param {Object} options - set the propery overriding the default options
* @returns {Object} the original object modified
*/
export function defineProperties(source, properties, options) {
Object.entries(properties).forEach(([key, value]) => {
defineProperty(source, key, value, options)
})
return source
}
/**
* Define default properties if they don't exist on the source object
* @param {Object} source - object that will receive the default properties
* @param {Object} defaults - object containing additional optional keys
* @returns {Object} the original object received enhanced
*/
export function defineDefaults(source, defaults) {
Object.entries(defaults).forEach(([key, value]) => {
if (!source[key]) source[key] = value
})
return source
}
/**
* Simple clone deep function, do not use it for classes or recursive objects!
* @param {*} source - possibily an object to clone
* @returns {*} the object we wanted to clone
*/
export function cloneDeep(source) {
return JSON.parse(JSON.stringify(source))
}

47
node_modules/@riotjs/util/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "@riotjs/util",
"version": "2.1.1",
"description": "Riot.js util functions",
"main": "index.js",
"module": "index.js",
"scripts": {
"prepublishOnly": "npm test",
"lint": "eslint *.js",
"test": "npm run lint && mocha -r jsdom-global/register -r esm *.spec.js"
},
"files": [
"dom.js",
"functions.js",
"constants.js",
"strings.js",
"objects.js",
"checks.js",
"expression-types.js",
"binding-types.js",
"misc.js"
],
"repository": {
"type": "git",
"url": "git+https://github.com/GianlucaGuarini/@riotjs/util.git"
},
"keywords": [
"Riot.js",
"shared",
"Riot util"
],
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/GianlucaGuarini/@riotjs/util/issues"
},
"homepage": "https://github.com/GianlucaGuarini/@riotjs/util#readme",
"devDependencies": {
"chai": "^4.3.6",
"eslint": "^8.20.0",
"eslint-config-riot": "^3.0.0",
"esm": "^3.2.25",
"jsdom": "20.0.0",
"jsdom-global": "3.0.2",
"mocha": "^8.4.0"
}
}

17
node_modules/@riotjs/util/strings.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/**
* Convert a string from camel case to dash-case
* @param {string} string - probably a component tag name
* @returns {string} component name normalized
*/
export function camelToDashCase(string) {
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
}
/**
* Convert a string containing dashes to camel case
* @param {string} string - input string
* @returns {string} my-string -> myString
*/
export function dashToCamelCase(string) {
return string.replace(/-(\w)/g, (_, c) => c.toUpperCase())
}