@studiometa/js-toolkit 2.0.0-alpha.1 → 2.0.0-alpha.10
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/Base/index.d.ts +29 -47
- package/Base/index.js +144 -171
- package/Base/managers/ChildrenManager.d.ts +6 -6
- package/Base/managers/ChildrenManager.js +95 -119
- package/Base/managers/EventsManager.d.ts +9 -9
- package/Base/managers/EventsManager.js +128 -161
- package/Base/managers/OptionsManager.d.ts +50 -5
- package/Base/managers/OptionsManager.js +115 -116
- package/Base/managers/RefsManager.js +62 -73
- package/Base/managers/ServicesManager.d.ts +14 -3
- package/Base/managers/ServicesManager.js +78 -77
- package/Base/utils.js +5 -8
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +4 -4
- package/decorators/withBreakpointManager.js +37 -75
- package/decorators/withBreakpointObserver.d.ts +2 -2
- package/decorators/withBreakpointObserver.js +54 -77
- package/decorators/withDrag.d.ts +3 -3
- package/decorators/withDrag.js +17 -41
- package/decorators/withExtraConfig.d.ts +3 -3
- package/decorators/withExtraConfig.js +2 -24
- package/decorators/withIntersectionObserver.d.ts +2 -2
- package/decorators/withIntersectionObserver.js +17 -56
- package/decorators/withMountWhenInView.d.ts +3 -3
- package/decorators/withMountWhenInView.js +23 -51
- package/helpers/createApp.d.ts +3 -3
- package/helpers/createApp.js +10 -12
- package/helpers/importOnInteraction.d.ts +3 -3
- package/helpers/importOnInteraction.js +7 -8
- package/helpers/importWhenIdle.d.ts +3 -3
- package/helpers/importWhenIdle.js +7 -8
- package/helpers/importWhenVisible.d.ts +3 -3
- package/helpers/importWhenVisible.js +9 -16
- package/helpers/index.d.ts +1 -3
- package/helpers/index.js +1 -4
- package/helpers/utils.js +1 -2
- package/index.d.ts +14 -4
- package/index.js +4 -4
- package/index.modern.js +1 -2
- package/index.umd.js +1 -2
- package/package.json +4 -6
- package/services/Service.js +48 -67
- package/services/drag.js +143 -179
- package/services/index.js +1 -2
- package/services/key.js +55 -97
- package/services/load.d.ts +1 -1
- package/services/load.js +21 -50
- package/services/pointer.js +117 -156
- package/services/raf.js +36 -64
- package/services/resize.js +47 -86
- package/services/scroll.js +81 -120
- package/utils/collide/boundingRectToCircle.js +7 -6
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +3 -8
- package/utils/css/transition.js +67 -140
- package/utils/debounce.js +3 -4
- package/utils/focusTrap.js +4 -5
- package/utils/history.js +13 -20
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +4 -9
- package/utils/object/autoBind.js +11 -19
- package/utils/object/getAllProperties.js +3 -11
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +2 -4
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +2 -3
- package/Base/index.js.map +0 -1
- package/Base/managers/ChildrenManager.js.map +0 -1
- package/Base/managers/EventsManager.js.map +0 -1
- package/Base/managers/OptionsManager.js.map +0 -1
- package/Base/managers/RefsManager.js.map +0 -1
- package/Base/managers/ServicesManager.js.map +0 -1
- package/Base/utils.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -121
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -327
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -39
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -167
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -77
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -270
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -195
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/createBase.d.ts +0 -7
- package/helpers/createBase.js +0 -7
- package/helpers/createBase.js.map +0 -1
- package/helpers/defineComponent.d.ts +0 -11
- package/helpers/defineComponent.js +0 -68
- package/helpers/defineComponent.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/Service.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- package/utils/throttle.js.map +0 -1
package/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../packages/js-toolkit/utils/object/getAllProperties.js","../packages/js-toolkit/Base/utils.js","../packages/js-toolkit/Base/managers/ChildrenManager.js","../packages/js-toolkit/Base/managers/RefsManager.js","../packages/js-toolkit/services/Service.js","../packages/js-toolkit/services/pointer.js","../packages/js-toolkit/services/raf.js","../packages/js-toolkit/utils/nextFrame.js","../packages/js-toolkit/utils/debounce.js","../packages/js-toolkit/services/resize.js","../packages/js-toolkit/services/scroll.js","../packages/js-toolkit/utils/keyCodes.js","../packages/js-toolkit/services/key.js","../packages/js-toolkit/services/load.js","../packages/js-toolkit/Base/managers/ServicesManager.js","../packages/js-toolkit/Base/managers/EventsManager.js","../node_modules/deepmerge/dist/cjs.js","../node_modules/lower-case/dist.es2015/index.js","../node_modules/no-case/dist.es2015/index.js","../packages/js-toolkit/node_modules/mimic-fn/index.js","../node_modules/p-defer/index.js","../node_modules/map-age-cleaner/dist/index.js","../packages/js-toolkit/node_modules/mem/dist/index.js","../packages/js-toolkit/Base/managers/OptionsManager.js","../packages/js-toolkit/utils/object/isObject.js","../packages/js-toolkit/Base/index.js","../packages/js-toolkit/utils/object/autoBind.js","../packages/js-toolkit/helpers/defineComponent.js","../packages/js-toolkit/helpers/utils.js","../packages/js-toolkit/helpers/createApp.js","../packages/js-toolkit/helpers/createBase.js","../packages/js-toolkit/helpers/importOnInteraction.js","../packages/js-toolkit/helpers/importWhenIdle.js","../packages/js-toolkit/helpers/importWhenVisible.js"],"sourcesContent":["/**\n * Gets all non-builtin properties up the prototype chain.\n *\n * @param {Object} object\n * The object to get the propeties from.\n * @param {Array=} [props=[]]\n * The already existing properties.\n * @param {(name:string, proto:any) => boolean} testFn\n * @return {Array<[String, Object]>} An array of properties and the prototype they belong to.\n */\nexport default function getAllProperties(object, props = [], testFn = null) {\n const proto = Object.getPrototypeOf(object);\n\n if (proto === Object.prototype) {\n return props;\n }\n\n let foundProps = Object.getOwnPropertyNames(proto);\n\n if (typeof testFn === 'function') {\n foundProps = foundProps.filter((name) => testFn(name, proto));\n }\n\n foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);\n\n return getAllProperties(proto, foundProps, testFn);\n}\n","/**\n * @typedef {import('./index.js').default} Base\n */\n\n/**\n * Test if an object has a method.\n *\n * @param {Object} obj The object to test\n * @param {String} name The method's name\n * @return {Boolean}\n */\nexport function hasMethod(obj, name) {\n return typeof obj[name] === 'function';\n}\n\n/**\n * Call the given method while applying the given arguments.\n *\n * @param {Base} instance The Base instance on which to trigger the method.\n * @param {String} method The method to call.\n * @param {...any} args The arguments to pass to the method.\n */\nexport function callMethod(instance, method, ...args) {\n instance.__debug('callMethod', method, ...args);\n\n // Prevent duplicate call of `mounted` and `destroyed`\n // methods based on the component status\n if (\n (method === 'destroyed' && !instance.$isMounted) ||\n (method === 'mounted' && instance.$isMounted)\n ) {\n instance.__debug('not', method, 'because the method has already been triggered once.');\n return instance;\n }\n\n instance.$emit(method, ...args);\n\n // We always emit an event, but we do not call the method if it does not exist\n if (!hasMethod(instance, method)) {\n return instance;\n }\n\n instance[method].call(instance, ...args);\n instance.__debug(method, instance, ...args);\n\n return instance;\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {String} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @return {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(nameOrSelector, element = document) {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n","import { getComponentElements } from '../utils.js';\n\n/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('../index.js').BaseComponent} BaseComponent\n * @typedef {import('../index.js').BaseAsyncComponent} BaseAsyncComponent\n * @typedef {import('../index.js').BaseConfigComponents} BaseConfigComponents\n * @typedef {import('./EventsManager.js').default} EventsManager\n */\n\n/**\n * Children manager.\n */\nexport default class ChildrenManager {\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * @type {BaseConfigComponents}\n * @private\n */\n __components;\n\n /**\n * @type {EventsManager}\n * @private\n */\n __eventsManager;\n\n /**\n * @return {string[]}\n */\n get registeredNames() {\n return Object.keys(this).filter((key) => !key.startsWith('__'));\n }\n\n /**\n * Class constructor.\n * @param {Base} base\n * The component's instance.\n * @param {HTMLElement} element\n * The component's root element\n * @param {BaseConfigComponents} components\n * The children components' classes\n * @param {EventsManager} eventsManager\n */\n constructor(base, element, components, eventsManager) {\n this.__base = base;\n this.__element = element;\n this.__components = components;\n this.__eventsManager = eventsManager;\n }\n\n /**\n * Register instances of all children components.\n */\n registerAll() {\n Object.entries(this.__components).forEach(([name, component]) =>\n this.__register(name, component)\n );\n }\n\n /**\n * Register instance of a child component.\n *\n * @param {string} name\n * The name of the child component.\n * @param {BaseComponent|BaseAsyncComponent} component\n * A Base class or a Promise for async components.\n * @private\n */\n __register(name, component) {\n Object.defineProperty(this, name, {\n enumerable: true,\n configurable: true,\n get: () => {\n const elements = getComponentElements(name, this.__element);\n\n if (elements.length === 0) {\n return [];\n }\n\n return elements\n .map((element) => this.__getChild(element, component, name))\n .filter((instance) => instance !== 'terminated');\n },\n });\n }\n\n /**\n * Get a child component's instance.\n *\n * @param {HTMLElement & { __base__?: Base | 'terminated' }} el\n * The root element of the child component.\n * @param {BaseComponent|BaseAsyncComponent} ComponentClass\n * A Base class or a Promise for async components.\n * @param {string} name\n * The name of the child component.\n * @return {Base|Promise|'terminated'}\n * A Base instance or a Promise resolving to a Base instance.\n * @private\n */\n __getChild(el, ComponentClass, name) {\n // Return existing instance if it exists\n if (el.__base__) {\n return el.__base__;\n }\n\n // Return a new instance if the component class is a child of the Base class\n if ('$isBase' in ComponentClass) {\n const child = new ComponentClass(el);\n Object.defineProperty(child, '$parent', { get: () => this.__base });\n return child;\n }\n\n // Resolve async components\n return ComponentClass(this.__base).then((module) => {\n // @ts-ignore\n return this.__getChild(el, module.default ?? module, name);\n });\n }\n\n /**\n * Mount all child component instances.\n */\n mountAll() {\n this.__triggerHookForAll('$mount');\n }\n\n /**\n * Update all child component instances.\n */\n updateAll() {\n this.__triggerHookForAll('$update');\n }\n\n /**\n * Destroy all child component instances.\n */\n destroyAll() {\n this.__triggerHookForAll('$destroy');\n }\n\n /**\n * Execute the given hook for all children instances.\n *\n * @param {'$mount'|'$update'|'$destroy'} hook The hook to execute.\n * @private\n */\n __triggerHookForAll(hook) {\n this.registeredNames.forEach((name) => {\n this[name].forEach((instance) => {\n if (instance instanceof Promise) {\n instance.then((resolvedInstance) => this.__triggerHook(hook, resolvedInstance, name));\n } else {\n this.__triggerHook(hook, instance, name);\n }\n });\n });\n }\n\n /**\n * Execute the given hook for the given instance.\n *\n * @param {'$mount'|'$update'|'$destroy'} hook The hook to trigger.\n * @param {Base} instance The target instance.\n * @param {string} name The name of the component.\n * @private\n */\n __triggerHook(hook, instance, name) {\n if (hook === '$update' && !instance.$isMounted) {\n // eslint-disable-next-line no-param-reassign\n hook = '$mount';\n }\n\n if (hook === '$update' || hook === '$destroy') {\n this.__eventsManager.unbindChild(name, instance);\n }\n\n if (hook === '$update' || hook === '$mount') {\n this.__eventsManager.bindChild(name, instance);\n }\n\n instance[hook]();\n }\n}\n","/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('./EventsManager.js').default} EventsManager\n */\n\n/**\n * Refs Manager\n */\nexport default class RefsManager {\n /**\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * @type {string[]}\n * @private\n */\n __refs;\n\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {EventsManager}\n * @private\n */\n __eventsManager;\n\n /**\n * Class constructor.\n *\n * @param {Base} base\n * The base instance tied to this manager.\n * @param {HTMLElement} element\n * The root element of a Base component.\n * @param {string[]} refs\n * The list of refs of this component.\n * @param {EventsManager} eventsManager\n */\n constructor(base, element, refs, eventsManager) {\n this.__element = element;\n this.__refs = refs;\n this.__base = base;\n this.__eventsManager = eventsManager;\n }\n\n /**\n * Register all refs.\n *\n * @return {void}\n */\n registerAll() {\n this.__refs.forEach((refName) => this.__register(refName));\n }\n\n /**\n * Unregister all refs.\n *\n * @return {void}\n */\n unregisterAll() {\n this.__refs.forEach((refName) => this.__unregister(refName));\n }\n\n /**\n * Register one ref.\n *\n * @param {string} refName The ref name.\n * @private\n */\n __register(refName) {\n const isMultiple = refName.endsWith('[]');\n const propName = RefsManager.normalizeRefName(refName);\n\n const refs = /** @type {HTMLElement[]} */ (\n Array.from(this.__element.querySelectorAll(`[data-ref=\"${refName}\"]`))\n ).filter(\n /**\n * @param {HTMLElement} ref\n */\n (ref) => this.__filterRefsBelongingToInstance(ref)\n );\n\n if (!isMultiple && refs.length > 1) {\n console.warn(\n `[${this.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?'\n );\n }\n\n this.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(this, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n }\n\n /**\n * Unregister one ref.\n *\n * @param {string} refName The ref name.\n * @private\n */\n __unregister(refName) {\n const propName = RefsManager.normalizeRefName(refName);\n const refs = Array.isArray(this[propName]) ? this[propName] : [this[propName]];\n this.__eventsManager.unbindRef(refName, refs);\n }\n\n /**\n * Normalize the name of ref.\n *\n * @param {string} name The original name.\n * @return {string} The normalized name.\n */\n static normalizeRefName(name) {\n return name.endsWith('[]') ? name.replace(/\\[\\]$/, '') : name;\n }\n\n /**\n * Filter refs belonging to the related Base instance.\n *\n * @param {HTMLElement} ref The ref to test.\n * @return {boolean}\n * @private\n */\n __filterRefsBelongingToInstance(ref) {\n let ancestor = ref.parentElement;\n\n while (ancestor && ancestor.dataset.component === undefined) {\n ancestor = ancestor.parentElement;\n }\n\n return ancestor === null || ancestor === this.__element;\n }\n}\n","/**\n * Service abstract class\n */\nexport default class Service {\n /**\n * Class constructor, used to test the abstract class implementation.\n */\n constructor() {\n this.callbacks = new Map();\n this.isInit = false;\n }\n\n /**\n * Getter to get the services properties.\n * This getter MUST be implementer by the service extending this class.\n * @return {Object}\n */\n get props() {\n throw new Error('The `props` getter must be implemented.');\n }\n\n /**\n * Method to initialize the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n init() {\n throw new Error('The `init` method must be implemented.');\n }\n\n /**\n * Method to kill the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n kill() {\n throw new Error('The `kill` method must be implemented.');\n }\n\n /**\n * Add a callback.\n *\n * @param {String} key The callback's identifier\n * @param {Function} callback The callback function\n * @return {this} The current instance\n */\n add(key, callback) {\n if (this.has(key)) {\n throw new Error(`A callback with the key \\`${key}\\` has already been registered.`);\n }\n\n // Initialize the service when we add the first callback\n if (this.callbacks.size === 0 && !this.isInit) {\n this.init();\n this.isInit = true;\n }\n\n this.callbacks.set(key, callback);\n return this;\n }\n\n /**\n * Test if a callback with the given key has already been added.\n *\n * @param {String} key The identifier to test\n * @return {Boolean} Whether or not the identifier already exists\n */\n has(key) {\n return this.callbacks.has(key);\n }\n\n /**\n * Get the callback tied to the given key.\n *\n * @param {String} key The identifier to get\n * @return {Function} The callback function\n */\n get(key) {\n return this.callbacks.get(key);\n }\n\n /**\n * Remove the callback tied to the given key.\n *\n * @param {String} key The identifier to remove\n * @return {Service} The current instance\n */\n remove(key) {\n this.callbacks.delete(key);\n\n // Kill the service when we remove the last callback\n if (this.callbacks.size === 0 && this.isInit) {\n this.kill();\n this.isInit = false;\n }\n\n return this;\n }\n\n /**\n * Trigger each added callback with the given arguments.\n *\n * @param {Array} args All the arguments to apply to the callback\n * @return {Service} The current instance\n */\n trigger(...args) {\n this.callbacks.forEach(function forEachCallback(callback) {\n callback(...args);\n });\n\n return this;\n }\n}\n","import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} PointerServiceProps\n * @property {MouseEvent | TouchEvent} event\n * @property {Boolean} isDown\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n */\n\n/**\n * @typedef {Object} PointerService\n * @property {(key:String, callback:(props:PointerServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => PointerServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Test if an event is an instance of TouchEvent.\n *\n * @param {TouchEvent|MouseEvent} event The event instance to test.\n * @return {Boolean} Is it a TouchEvent?\n */\nfunction isTouchEvent(event) {\n return typeof TouchEvent !== 'undefined' && event instanceof TouchEvent;\n}\n\n/**\n * Pointer service\n */\nclass Pointer extends Service {\n /** @type {Boolean} State of the pointer. */\n isDown = false;\n\n /** @type {Number} The y pointer position. */\n y = window.innerHeight / 2;\n\n /** @type {Number} The y previous pointer position. */\n yLast = window.innerHeight / 2;\n\n /** @type {Number} The x pointer position. */\n x = window.innerWidth / 2;\n\n /** @type {Number} The x previous pointer position. */\n xLast = window.innerWidth / 2;\n\n /** @type {MouseEvent|TouchEvent} The latest event emitted from the pointer. */\n event;\n\n /**\n * Whether or not the raf service is running.\n * @type {Boolean}\n */\n hasRaf = false;\n\n /**\n * Bind the handler to the mousemove and touchmove events.\n * Bind the up and down handler to the mousedown, mouseup, touchstart and touchend events.\n *\n * @return {Pointer}\n */\n init() {\n document.documentElement.addEventListener('mouseenter', this, {\n once: true,\n capture: true,\n });\n\n const options = { passive: true, capture: true };\n document.addEventListener('mousemove', this, options);\n document.addEventListener('touchmove', this, options);\n document.addEventListener('mousedown', this, options);\n document.addEventListener('touchstart', this, options);\n document.addEventListener('mouseup', this, options);\n document.addEventListener('touchend', this, options);\n return this;\n }\n\n /**\n * Handle events.\n * @param {MouseEvent|TouchEvent} event The event object.\n */\n handleEvent(event) {\n // eslint-disable-next-line default-case\n switch (event.type) {\n case 'mouseenter':\n case 'mousemove':\n case 'touchmove':\n this.handler(event);\n break;\n case 'mousedown':\n case 'touchstart':\n this.downHandler();\n break;\n case 'mouseup':\n case 'touchend':\n this.upHandler();\n break;\n }\n }\n\n /**\n * Unbind all handlers from their bounded event.\n *\n * @return {Pointer}\n */\n kill() {\n document.removeEventListener('mousemove', this);\n document.removeEventListener('touchmove', this);\n document.removeEventListener('mousedown', this);\n document.removeEventListener('touchstart', this);\n document.removeEventListener('mouseup', this);\n document.removeEventListener('touchend', this);\n return this;\n }\n\n /**\n * The service handler.\n * @param {MouseEvent|TouchEvent} event The mouse event object.\n */\n handler(event) {\n this.updateValues(event);\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's down action.\n *\n * @return {void}\n */\n downHandler() {\n this.isDown = true;\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's up action.\n *\n * @return {void}\n */\n upHandler() {\n this.isDown = false;\n this.trigger(this.props);\n }\n\n /**\n * Update the pointer positions.\n *\n * @param {MouseEvent|TouchEvent} event The event object.\n * @return {void}\n */\n updateValues(event) {\n this.event = event;\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check pointer Y\n // We either get data from a touch event `event.touches[0].clientY` or from\n // a mouse event `event.clientY`.\n const y = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientY\n : /** @type {MouseEvent} */ (event).clientY;\n if (y !== this.y) {\n this.y = y;\n }\n\n // Check pointer X\n // We either get data from a touch event `event.touches[0].clientX` or from\n // a mouse event `event.clientX`.\n const x = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientX\n : /** @type {MouseEvent} */ (event).clientX;\n if (x !== this.x) {\n this.x = x;\n }\n }\n\n /**\n * Get the pointer props.\n *\n * @type {Object}\n */\n get props() {\n return {\n event: this.event,\n isDown: this.isDown,\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.x / window.innerWidth,\n y: this.y / window.innerHeight,\n },\n max: {\n x: window.innerWidth,\n y: window.innerHeight,\n },\n };\n }\n}\n\nlet pointer = null;\n\n/**\n * Use the pointer.\n *\n * ```js\n * import usePointer from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = usePointer();\n * add('id', () => {});\n * remove('id');\n * props();\n * ```\n *\n * @return {ServiceInterface & PointerService}\n */\nexport default function usePointer() {\n if (!pointer) {\n pointer = new Pointer();\n }\n\n const add = pointer.add.bind(pointer);\n const remove = pointer.remove.bind(pointer);\n const has = pointer.has.bind(pointer);\n const props = () => pointer.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\nimport { getRaf, getCancelRaf } from '../utils/nextFrame.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} RafServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} RafService\n * @property {(key:String, callback:(props:RafServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => RafServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Tick service\n */\nclass Raf extends Service {\n /** @type {Boolean} Whether the loop is running or not. */\n isTicking = false;\n\n /** @type {number} */\n id = 0;\n\n raf = getRaf();\n\n cancelRaf = getCancelRaf();\n\n /**\n * Bind loop to the instance.\n */\n constructor() {\n super();\n this.loop = this.loop.bind(this);\n }\n\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n init() {\n this.isTicking = true;\n this.loop();\n return this;\n }\n\n /**\n * Loop method.\n */\n loop() {\n this.trigger(this.props);\n\n if (!this.isTicking) {\n return;\n }\n\n this.id = this.raf(this.loop);\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n kill() {\n this.cancelRaf(this.id);\n this.isTicking = false;\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {\n time: window.performance.now(),\n };\n }\n}\n\nlet instance = null;\n\n/**\n * Use the RequestAnimationFrame (raf) service.\n *\n * ```js\n * import { useRaf } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & RafService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Raf();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","/**\n * RequestAnimation frame polyfill.\n * @see https://github.com/vuejs/vue/blob/ec78fc8b6d03e59da669be1adf4b4b5abf670a34/dist/vue.runtime.esm.js#L7355\n * @return {(handler: Function) => number}\n */\nexport function getRaf() {\n return typeof window !== 'undefined' && window.requestAnimationFrame\n ? window.requestAnimationFrame.bind(window)\n : setTimeout;\n}\n\n/**\n * Get a function to cancel the method returned by `getRaf()`.\n *\n * @return {(id:number) => void}\n */\nexport function getCancelRaf() {\n return typeof window !== 'undefined' && window.cancelAnimationFrame\n ? window.cancelAnimationFrame.bind(window)\n : clearTimeout;\n}\n\n/**\n * Wait for the next frame to execute a function.\n *\n * @param {Function=} [fn=() => {}] The callback function to execute.\n * @return {Promise} A Promise resolving when the next frame is reached.\n *\n * @example\n * ```js\n * nextFrame(() => console.log('hello world'));\n *\n * await nextFrame();\n * console.log('hello world');\n * ```\n */\nexport default function nextFrame(fn = () => {}) {\n const raf = getRaf();\n return new Promise((resolve) => {\n raf(() => raf(() => resolve(fn())));\n });\n}\n","/**\n * Returns a function, that, as long as it continues to be invoked,\n * will not be triggered. The function will be called after it stops\n * being called for N milliseconds.\n *\n * @param {(...args:any[]) => void} fn The function to call.\n * @param {Number=} [delay=300] The delay in ms to wait before calling the function.\n * @return {(...args:any[]) => void} The debounced function.\n */\nexport default function debounce(fn, delay = 300) {\n let timeout;\n return function debounced(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n fn(...args);\n }, delay);\n };\n}\n","import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ResizeServiceProps\n * @property {Number} width\n * @property {Number} height\n * @property {Number} ratio\n * @property {'square'|'landscape'|'portrait'} orientation\n * @property {String} [breakpoint]\n * @property {String[]} [breakpoints]\n */\n\n/**\n * @typedef {Object} ResizeService\n * @property {(key:String, callback:(props:ResizeServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ResizeServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Resize service\n *\n * ```\n * import { useResize } from '@studiometa/js/services';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n */\nclass Resize extends Service {\n /**\n * Bind the handler to the resize event.\n *\n * @return {this}\n */\n init() {\n this.handler = debounce(() => {\n this.trigger(this.props);\n }).bind(this);\n\n window.addEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Unbind the handler from the resize event.\n *\n * @return {this}\n */\n kill() {\n window.removeEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Get resize props.\n *\n * @type {ResizeServiceProps}\n */\n get props() {\n /** @type {ResizeServiceProps} [description] */\n const props = {\n width: window.innerWidth,\n height: window.innerHeight,\n ratio: window.innerWidth / window.innerHeight,\n orientation: 'square',\n };\n\n if (props.ratio > 1) {\n props.orientation = 'landscape';\n }\n\n if (props.ratio < 1) {\n props.orientation = 'portrait';\n }\n\n if (this.breakpointElement) {\n props.breakpoint = this.breakpoint;\n props.breakpoints = this.breakpoints;\n }\n\n return props;\n }\n\n /**\n * The element holding the breakpoints data.\n * @return {HTMLElement}\n */\n get breakpointElement() {\n return document.querySelector('[data-breakpoint]') || null;\n }\n\n /**\n * Get the current breakpoint.\n * @return {String}\n */\n get breakpoint() {\n return window\n .getComputedStyle(this.breakpointElement, '::before')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n }\n\n /**\n * Get all breakpoints.\n * @return {Array}\n */\n get breakpoints() {\n const breakpoints = window\n .getComputedStyle(this.breakpointElement, '::after')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n\n return breakpoints.split(',');\n }\n\n /**\n * Test if we can use the `ResizeObserver` API.\n * @return {Boolean}\n */\n get canUseResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n }\n}\n\nlet resize = null;\n\n/**\n * Use the resize service.\n *\n * ```js\n * import useResize from '@studiometa/js-toolkit/services/resize';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n * @return {ServiceInterface & ResizeService}\n */\nexport default function useResize() {\n if (!resize) {\n resize = new Resize();\n }\n\n const add = resize.add.bind(resize);\n const remove = resize.remove.bind(resize);\n const has = resize.has.bind(resize);\n const props = () => resize.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ScrollServiceProps\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n * @property {{ x: 'LEFT'|'RIGHT'|'NONE', y: 'UP'|'DOWN'|'NONE' }} direction\n */\n\n/**\n * @typedef {Object} ScrollService\n * @property {(key:String, callback:(props:ScrollServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ScrollServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Scroll extends Service {\n /** @type {Number} The y scroll position. */\n y = window.pageYOffset;\n\n /** @type {Number} The y previous scroll position. */\n yLast = window.pageYOffset;\n\n /** @type {Number} The x scroll position. */\n x = window.pageXOffset;\n\n /** @type {Number} The x previous scroll position. */\n xLast = window.pageXOffset;\n\n /**\n * Bind the handler to the scroll event.\n *\n * @return {Scroll}\n */\n init() {\n document.addEventListener('scroll', this, { passive: true, capture: true });\n return this;\n }\n\n /**\n * Debounced handler.\n *\n * @return {() => void}\n */\n get debouncedHandler() {\n const debounced = debounce(() => {\n this.trigger(this.props);\n }, 0);\n\n // Define property to avoid multiple call to the getter\n Object.defineProperty(this, 'debouncedHandler', {\n value: debounced,\n });\n\n return debounced;\n }\n\n /**\n * Scroll event handler.\n *\n * @return {void}\n */\n handleEvent() {\n this.trigger(this.props);\n\n this.debouncedHandler();\n }\n\n /**\n * Unbind the handler from the scroll event.\n *\n * @return {Scroll}\n */\n kill() {\n document.removeEventListener('scroll', this);\n return this;\n }\n\n /**\n * Get scroll props.\n *\n * @type {Object}\n */\n get props() {\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check scroll Y\n if (window.pageYOffset !== this.y) {\n this.y = window.pageYOffset;\n }\n\n // Check scroll x\n if (window.pageXOffset !== this.x) {\n this.x = window.pageXOffset;\n }\n\n return {\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.max.x === 0 ? 1 : this.x / this.max.x,\n y: this.max.y === 0 ? 1 : this.y / this.max.y,\n },\n direction: {\n /* eslint-disable no-nested-ternary */\n x: this.x > this.xLast ? 'RIGHT' : this.x < this.xLast ? 'LEFT' : 'NONE',\n y: this.y > this.yLast ? 'DOWN' : this.y < this.yLast ? 'UP' : 'NONE',\n /* eslint-enable no-nested-ternary */\n },\n max: this.max,\n };\n }\n\n /**\n * Get scroll max values.\n *\n * @type {Object}\n */\n get max() {\n return {\n x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,\n y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,\n };\n }\n}\n\nlet scroll = null;\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & ScrollService}\n */\nexport default function useScroll() {\n if (!scroll) {\n scroll = new Scroll();\n }\n\n const add = scroll.add.bind(scroll);\n const remove = scroll.remove.bind(scroll);\n const has = scroll.has.bind(scroll);\n const props = () => scroll.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","export default {\n ENTER: 13,\n SPACE: 32,\n TAB: 9,\n ESC: 27,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40,\n};\n","import Service from './Service.js';\nimport keyCodes from '../utils/keyCodes.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} KeyServiceProps\n * @property {KeyboardEvent} event\n * @property {Number} triggered\n * @property {Boolean} isUp\n * @property {Boolean} isDown\n * @property {Boolean} ENTER\n * @property {Boolean} SPACE\n * @property {Boolean} TAB\n * @property {Boolean} ESC\n * @property {Boolean} LEFT\n * @property {Boolean} UP\n * @property {Boolean} RIGHT\n * @property {Boolean} DOWN\n */\n\n/**\n * @typedef {Object} KeyService\n * @property {(key:String, callback:(props:KeyServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => KeyServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Key extends Service {\n /** @type {Object} The event object. */\n event = {};\n\n /**\n * Used to accumulate the number of times the `keydown` event has been triggered.\n * @type {Number}\n */\n triggered = 0;\n\n /** @type {Object} The previous event object. */\n previousEvent = {};\n\n /**\n * Bind the handler to the keyboard event.\n *\n * @return {Key}\n */\n init() {\n this.handler = (event) => {\n this.event = event;\n this.trigger(this.props);\n };\n document.addEventListener('keydown', this.handler, { passive: false });\n document.addEventListener('keyup', this.handler, { passive: false });\n return this;\n }\n\n /**\n * Unbind the handler from the keyboard event.\n *\n * @return {Key}\n */\n kill() {\n document.removeEventListener('keydown', this.handler);\n document.removeEventListener('keyup', this.handler);\n return this;\n }\n\n /**\n * Get keyboard props.\n *\n * @type {Object}\n */\n get props() {\n const keys = Object.entries(keyCodes).reduce((acc, [name, code]) => {\n acc[name] = code === this.event.keyCode;\n return acc;\n }, {});\n\n if (!this.previousEvent.type) {\n this.triggered = 0;\n }\n\n if (this.event.type === 'keydown' && this.previousEvent.type === 'keydown') {\n this.triggered += 1;\n } else {\n this.triggered = 1;\n }\n\n this.previousEvent = this.event;\n\n return {\n event: this.event,\n triggered: this.triggered,\n direction: this.event.type === 'keydown' ? 'down' : 'up',\n isUp: this.event.type === 'keyup',\n isDown: this.event.type === 'keydown',\n ...keys,\n };\n }\n}\n\nlet key = null;\n\n/**\n * Use the keyboard service.\n *\n * ```js\n * import { useKey } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useKey();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & KeyService}\n */\nexport default function useKey() {\n if (!key) {\n key = new Key();\n }\n\n const add = key.add.bind(key);\n const remove = key.remove.bind(key);\n const has = key.has.bind(key);\n const props = () => key.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} LoadServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} LoadService\n * @property {(key:String, callback:(props:LoadServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => LoadServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Load service\n */\nclass Load extends Service {\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n init() {\n this.handler = () => {\n this.trigger(this.props);\n };\n\n window.addEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n kill() {\n window.removeEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {};\n }\n}\n\nlet instance = null;\n\n/**\n * Use the load service.\n *\n * ```js\n * import { useLoad } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & LoadService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Load();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n","import usePointer from '../../services/pointer.js';\nimport useRaf from '../../services/raf.js';\nimport useResize from '../../services/resize.js';\nimport useScroll from '../../services/scroll.js';\nimport useKey from '../../services/key.js';\nimport useLoad from '../../services/load.js';\nimport { hasMethod, callMethod } from '../utils.js';\n\n/**\n * @typedef {import('../index').default} Base\n * @typedef {import('../../services').ServiceInterface} ServiceInterface\n */\n\n/**\n * @type {Record<string, () => ServiceInterface>}\n */\nconst SERVICES_MAP = {\n scrolled: useScroll,\n resized: useResize,\n ticked: useRaf,\n moved: usePointer,\n keyed: useKey,\n loaded: useLoad,\n};\n\n/**\n * @typedef {keyof SERVICES_MAP} ServiceName\n */\n\n/**\n * Services management for the Base class.\n */\nexport default class ServicesManager {\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * Class constructor.\n * @param {Base} instance The Base instance.\n */\n constructor(instance) {\n this.__base = instance;\n }\n\n /**\n * Test if the given service is registered.\n *\n * @param {ServiceName} service The name of the service.\n * @return {Boolean}\n */\n has(service) {\n if (!hasMethod(this.__base, service) && !SERVICES_MAP[service]) {\n return false;\n }\n\n const { has } = SERVICES_MAP[service]();\n return has(this.__base.$id);\n }\n\n /**\n * Init the given service and bind it to the given instance.\n *\n * @param {ServiceName} service The name of the service.\n * @return {() => void} A function to unbind the service.\n */\n enable(service) {\n if (this.has(service)) {\n return this.disable.bind(this, service);\n }\n\n if (!hasMethod(this.__base, service) || !SERVICES_MAP[service]) {\n return function noop() {};\n }\n\n const { add } = SERVICES_MAP[service]();\n const self = this;\n\n /**\n * @param {any[]} args\n */\n function serviceHandler(...args) {\n callMethod(self.__base, service, ...args);\n }\n\n add(this.__base.$id, serviceHandler);\n\n return this.disable.bind(this, service);\n }\n\n /**\n * Enable all services and return methods to disable them.\n *\n * @return {Function[]}\n */\n enableAll() {\n return Object.keys(SERVICES_MAP).map(\n /** @param {ServiceName} serviceName */\n (serviceName) => this.enable(serviceName)\n );\n }\n\n /**\n * Disable all services.\n *\n * @return {void}\n */\n disableAll() {\n Object.keys(SERVICES_MAP).forEach(\n /** @param {ServiceName} serviceName */\n (serviceName) => {\n this.disable(serviceName);\n }\n );\n }\n\n /**\n * Disable a service.\n *\n * @param {String} service The name of the service.\n * @return {void}\n */\n disable(service) {\n if (!SERVICES_MAP[service]) {\n return;\n }\n\n const { remove } = SERVICES_MAP[service]();\n remove(this.__base.$id);\n }\n\n /**\n * Register a new service to be enabled/disabled.\n *\n * @param {string} name The name of the service hook.\n * @param {() => ServiceInterface} useFunction The `use...` function for the service.\n */\n register(name, useFunction) {\n SERVICES_MAP[name] = useFunction;\n }\n\n /**\n * Unregister a new service to be enabled disabled.\n *\n * @param {string} name The name of the service hooK\n */\n unregister(name) {\n delete SERVICES_MAP[name];\n }\n}\n","import getAllProperties from '../../utils/object/getAllProperties.js';\nimport RefsManager from './RefsManager.js';\n\n/**\n * @typedef {import('../index.js').default} Base\n * @typedef {import('./ChildrenManager.js').default} ChildrenManager\n */\n\n/**\n * Event management class.\n */\nexport default class EventsManager {\n /**\n * @type {HTMLElement}\n * @private\n */\n __rootElement;\n\n /**\n * @type {Base}\n * @private\n */\n __base;\n\n /**\n * @type {WeakMap}\n * @private\n */\n __methodsCache = new WeakMap();\n\n /**\n * Event listener object for the root element.\n *\n * @type {EventListenerObject}\n */\n __rootElementHandler = {\n handleEvent: (event) => {\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n this.__base[method](event);\n }\n },\n };\n\n /**\n * Event listener object for the refs.\n *\n * @type {EventListenerObject}\n */\n __refsHandler = {\n handleEvent: (event) => {\n const ref = /** @type {HTMLElement} */ (event.currentTarget);\n const refName = RefsManager.normalizeRefName(ref.dataset.ref);\n\n const normalizedRefName = EventsManager.normalizeName(refName);\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedRefName}${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n let index = 0;\n if (Array.isArray(this.__base.$refs[refName])) {\n index = this.__base.$refs[refName].indexOf(ref);\n }\n\n this.__base[method](event, index);\n }\n },\n };\n\n /**\n * Event listener object for the children.\n *\n * @type {EventListenerObject}\n */\n __childrenHandler = {\n /**\n * @param {CustomEvent} event\n * @return {void}\n */\n handleEvent: (event) => {\n const child = /** @type {HTMLElement & { __base__: Base }} */ (event.currentTarget).__base__;\n let childName;\n let index = 0;\n\n const childrenManager = this.__base.$children;\n\n childrenManager.registeredNames.find((name) => {\n if (childrenManager[name].includes(child)) {\n childName = name;\n index = childrenManager[name].indexOf(child);\n return true;\n }\n\n return false;\n });\n\n const normalizedRefName = EventsManager.normalizeName(childName);\n const normalizedEventName = EventsManager.normalizeName(event.type);\n const method = `on${normalizedRefName}${normalizedEventName}`;\n\n if (typeof this.__base[method] === 'function') {\n const args = event.detail ?? [];\n this.__base[method](...args, index, event);\n }\n },\n };\n\n /**\n * Class constructor.\n *\n * @param {HTMLElement} rootElement\n * @param {Base} base\n */\n constructor(rootElement, base) {\n this.__rootElement = rootElement;\n this.__base = base;\n }\n\n /**\n * Manage a ref event methods.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageRef(name, elements, mode = 'add') {\n const action = `${mode}EventListener`;\n const methods = this.__getEventMethodsByName(name);\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method, name);\n elements.forEach((element) => element[action](event, this.__refsHandler));\n });\n }\n\n /**\n * Bind event methods to the given ref elements.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n *\n * @return {void}\n */\n bindRef(name, elements) {\n this.__manageRef(name, elements);\n }\n\n /**\n * Bind event methods to the given ref elements.\n *\n * @param {string} name\n * The name of the ref.\n * @param {HTMLElement[]} elements\n * The elements of the ref.\n *\n * @return {void}\n */\n unbindRef(name, elements) {\n this.__manageRef(name, elements, 'remove');\n }\n\n /**\n * Manage event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageChild(name, instance, mode = 'add') {\n const action = mode === 'add' ? '$on' : '$off';\n const methods = this.__getEventMethodsByName(name);\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method, name);\n instance[action](event, this.__childrenHandler);\n });\n }\n\n /**\n * Bind event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n *\n * @return {void}\n */\n bindChild(name, instance) {\n this.__manageChild(name, instance);\n }\n\n /**\n * Unbind event methods to the given child instance.\n *\n * @param {string} name\n * The name of the ref.\n * @param {Base} instance\n * A base instance.\n *\n * @return {void}\n */\n unbindChild(name, instance) {\n this.__manageChild(name, instance, 'remove');\n }\n\n /**\n * Manage event methods on the root element.\n *\n * @param {'add'|'remove'} [mode]\n * The action to perform: add or remove the event listeners.\n *\n * @return {void}\n * @private\n */\n __manageRootElement(mode = 'add') {\n const modeMethod = `${mode}EventListener`;\n const methods = this.__getEventMethodsByName();\n methods.forEach((method) => {\n const event = this.__getEventNameByMethod(method);\n this.__rootElement[modeMethod](event, this.__rootElementHandler);\n });\n }\n\n /**\n * Bind event methods on the root element.\n *\n * @return {void}\n */\n bindRootElement() {\n this.__manageRootElement();\n }\n\n /**\n * Unbind event method from the root element.\n *\n * @return {void}\n */\n unbindRootElement() {\n this.__manageRootElement('remove');\n }\n\n /**\n * Get the event name from the given method and its tied ref or children name.\n *\n * @param {string} method\n * @param {string} name\n * @return {string}\n * @private\n */\n __getEventNameByMethod(method, name = '') {\n const normalizedName = EventsManager.normalizeName(name);\n const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);\n const [, event] = method.match(regex);\n return EventsManager.normalizeEventName(event);\n }\n\n /**\n * Get the base instance methods matching the `onSomething` pattern.\n *\n * @param {string} [name]\n * @return {string[]}\n * @private\n */\n __getEventMethodsByName(name = '') {\n const normalizedName = EventsManager.normalizeName(name);\n const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);\n\n let methods = this.__methodsCache.get(regex);\n\n if (!methods) {\n methods = getAllProperties(this.__base, [], (method) => regex.test(method));\n this.__methodsCache.set(regex, methods);\n }\n\n return methods.reduce((acc, [method]) => {\n if (!acc.includes(method)) {\n acc.push(method);\n }\n return acc;\n }, []);\n }\n\n /**\n * Normalize the given name to PascalCase, such as:\n *\n * ```\n * sentence case => SentenceCase\n * lowercase => Lowercase\n * UPPERCASE => Uppercase\n * kebab-case => KebabCase\n * snake_case => SnakeCase\n * camelCase => CamelCase\n * PascalCase => PascalCase\n * .class-selector => ClassSelector\n * .bem__selector => BemSelector\n * __id-selector => IdSelector\n * .complex[class^ =\"__\"] => ComplexClass\n * ```\n *\n * @param {string} name\n * @return {string}\n */\n static normalizeName(name) {\n return name\n .replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase())\n .replace(/[^a-zA-Z\\d\\s:]/g, ' ')\n .replace(/(^\\w|\\s+\\w)/g, (c) => c.trim().toUpperCase())\n .trim();\n }\n\n /**\n * Normalize the event names from PascalCase to kebab-case.\n *\n * @param {string} name\n * @return {string}\n */\n static normalizeEventName(name) {\n return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, '');\n }\n}\n","'use strict';\n\nvar isMergeableObject = function isMergeableObject(value) {\n\treturn isNonNullObject(value)\n\t\t&& !isSpecial(value)\n};\n\nfunction isNonNullObject(value) {\n\treturn !!value && typeof value === 'object'\n}\n\nfunction isSpecial(value) {\n\tvar stringValue = Object.prototype.toString.call(value);\n\n\treturn stringValue === '[object RegExp]'\n\t\t|| stringValue === '[object Date]'\n\t\t|| isReactElement(value)\n}\n\n// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25\nvar canUseSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;\n\nfunction isReactElement(value) {\n\treturn value.$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction emptyTarget(val) {\n\treturn Array.isArray(val) ? [] : {}\n}\n\nfunction cloneUnlessOtherwiseSpecified(value, options) {\n\treturn (options.clone !== false && options.isMergeableObject(value))\n\t\t? deepmerge(emptyTarget(value), value, options)\n\t\t: value\n}\n\nfunction defaultArrayMerge(target, source, options) {\n\treturn target.concat(source).map(function(element) {\n\t\treturn cloneUnlessOtherwiseSpecified(element, options)\n\t})\n}\n\nfunction getMergeFunction(key, options) {\n\tif (!options.customMerge) {\n\t\treturn deepmerge\n\t}\n\tvar customMerge = options.customMerge(key);\n\treturn typeof customMerge === 'function' ? customMerge : deepmerge\n}\n\nfunction getEnumerableOwnPropertySymbols(target) {\n\treturn Object.getOwnPropertySymbols\n\t\t? Object.getOwnPropertySymbols(target).filter(function(symbol) {\n\t\t\treturn target.propertyIsEnumerable(symbol)\n\t\t})\n\t\t: []\n}\n\nfunction getKeys(target) {\n\treturn Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))\n}\n\nfunction propertyIsOnObject(object, property) {\n\ttry {\n\t\treturn property in object\n\t} catch(_) {\n\t\treturn false\n\t}\n}\n\n// Protects from prototype poisoning and unexpected merging up the prototype chain.\nfunction propertyIsUnsafe(target, key) {\n\treturn propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,\n\t\t&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,\n\t\t\t&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.\n}\n\nfunction mergeObject(target, source, options) {\n\tvar destination = {};\n\tif (options.isMergeableObject(target)) {\n\t\tgetKeys(target).forEach(function(key) {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n\t\t});\n\t}\n\tgetKeys(source).forEach(function(key) {\n\t\tif (propertyIsUnsafe(target, key)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {\n\t\t\tdestination[key] = getMergeFunction(key, options)(target[key], source[key], options);\n\t\t} else {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(source[key], options);\n\t\t}\n\t});\n\treturn destination\n}\n\nfunction deepmerge(target, source, options) {\n\toptions = options || {};\n\toptions.arrayMerge = options.arrayMerge || defaultArrayMerge;\n\toptions.isMergeableObject = options.isMergeableObject || isMergeableObject;\n\t// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n\t// implementations can use it. The caller may not replace it.\n\toptions.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;\n\n\tvar sourceIsArray = Array.isArray(source);\n\tvar targetIsArray = Array.isArray(target);\n\tvar sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n\tif (!sourceAndTargetTypesMatch) {\n\t\treturn cloneUnlessOtherwiseSpecified(source, options)\n\t} else if (sourceIsArray) {\n\t\treturn options.arrayMerge(target, source, options)\n\t} else {\n\t\treturn mergeObject(target, source, options)\n\t}\n}\n\ndeepmerge.all = function deepmergeAll(array, options) {\n\tif (!Array.isArray(array)) {\n\t\tthrow new Error('first argument should be an array')\n\t}\n\n\treturn array.reduce(function(prev, next) {\n\t\treturn deepmerge(prev, next, options)\n\t}, {})\n};\n\nvar deepmerge_1 = deepmerge;\n\nmodule.exports = deepmerge_1;\n","/**\n * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt\n */\nvar SUPPORTED_LOCALE = {\n tr: {\n regexp: /\\u0130|\\u0049|\\u0049\\u0307/g,\n map: {\n İ: \"\\u0069\",\n I: \"\\u0131\",\n İ: \"\\u0069\",\n },\n },\n az: {\n regexp: /\\u0130/g,\n map: {\n İ: \"\\u0069\",\n I: \"\\u0131\",\n İ: \"\\u0069\",\n },\n },\n lt: {\n regexp: /\\u0049|\\u004A|\\u012E|\\u00CC|\\u00CD|\\u0128/g,\n map: {\n I: \"\\u0069\\u0307\",\n J: \"\\u006A\\u0307\",\n Į: \"\\u012F\\u0307\",\n Ì: \"\\u0069\\u0307\\u0300\",\n Í: \"\\u0069\\u0307\\u0301\",\n Ĩ: \"\\u0069\\u0307\\u0303\",\n },\n },\n};\n/**\n * Localized lower case.\n */\nexport function localeLowerCase(str, locale) {\n var lang = SUPPORTED_LOCALE[locale.toLowerCase()];\n if (lang)\n return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));\n return lowerCase(str);\n}\n/**\n * Lower case as a function.\n */\nexport function lowerCase(str) {\n return str.toLowerCase();\n}\n//# sourceMappingURL=index.js.map","import { lowerCase } from \"lower-case\";\n// Support camel case (\"camelCase\" -> \"camel Case\" and \"CAMELCase\" -> \"CAMEL Case\").\nvar DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];\n// Remove all non-word characters.\nvar DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n/**\n * Normalize the string into something other libraries can manipulate easier.\n */\nexport function noCase(input, options) {\n if (options === void 0) { options = {}; }\n var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? \" \" : _d;\n var result = replace(replace(input, splitRegexp, \"$1\\0$2\"), stripRegexp, \"\\0\");\n var start = 0;\n var end = result.length;\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === \"\\0\")\n start++;\n while (result.charAt(end - 1) === \"\\0\")\n end--;\n // Transform each token independently.\n return result.slice(start, end).split(\"\\0\").map(transform).join(delimiter);\n}\n/**\n * Replace `re` in the input string with the replacement value.\n */\nfunction replace(input, re, value) {\n if (re instanceof RegExp)\n return input.replace(re, value);\n return re.reduce(function (input, re) { return input.replace(re, value); }, input);\n}\n//# sourceMappingURL=index.js.map","const copyProperty = (to, from, property, ignoreNonConfigurable) => {\n\t// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.\n\t// `Function#prototype` is non-writable and non-configurable so can never be modified.\n\tif (property === 'length' || property === 'prototype') {\n\t\treturn;\n\t}\n\n\t// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.\n\tif (property === 'arguments' || property === 'caller') {\n\t\treturn;\n\t}\n\n\tconst toDescriptor = Object.getOwnPropertyDescriptor(to, property);\n\tconst fromDescriptor = Object.getOwnPropertyDescriptor(from, property);\n\n\tif (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {\n\t\treturn;\n\t}\n\n\tObject.defineProperty(to, property, fromDescriptor);\n};\n\n// `Object.defineProperty()` throws if the property exists, is not configurable and either:\n// - one its descriptors is changed\n// - it is non-writable and its value is changed\nconst canCopyProperty = function (toDescriptor, fromDescriptor) {\n\treturn toDescriptor === undefined || toDescriptor.configurable || (\n\t\ttoDescriptor.writable === fromDescriptor.writable &&\n\t\ttoDescriptor.enumerable === fromDescriptor.enumerable &&\n\t\ttoDescriptor.configurable === fromDescriptor.configurable &&\n\t\t(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)\n\t);\n};\n\nconst changePrototype = (to, from) => {\n\tconst fromPrototype = Object.getPrototypeOf(from);\n\tif (fromPrototype === Object.getPrototypeOf(to)) {\n\t\treturn;\n\t}\n\n\tObject.setPrototypeOf(to, fromPrototype);\n};\n\nconst wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\\n${fromBody}`;\n\nconst toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');\nconst toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');\n\n// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.\n// We use `bind()` instead of a closure for the same reason.\n// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.\nconst changeToString = (to, from, name) => {\n\tconst withName = name === '' ? '' : `with ${name.trim()}() `;\n\tconst newToString = wrappedToString.bind(null, withName, from.toString());\n\t// Ensure `to.toString.toString` is non-enumerable and has the same `same`\n\tObject.defineProperty(newToString, 'name', toStringName);\n\tObject.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});\n};\n\nexport default function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {\n\tconst {name} = to;\n\n\tfor (const property of Reflect.ownKeys(from)) {\n\t\tcopyProperty(to, from, property, ignoreNonConfigurable);\n\t}\n\n\tchangePrototype(to, from);\n\tchangeToString(to, from, name);\n\n\treturn to;\n}\n","'use strict';\nmodule.exports = () => {\n\tconst ret = {};\n\n\tret.promise = new Promise((resolve, reject) => {\n\t\tret.resolve = resolve;\n\t\tret.reject = reject;\n\t});\n\n\treturn ret;\n};\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst p_defer_1 = __importDefault(require(\"p-defer\"));\nfunction mapAgeCleaner(map, property = 'maxAge') {\n let processingKey;\n let processingTimer;\n let processingDeferred;\n const cleanup = () => __awaiter(this, void 0, void 0, function* () {\n if (processingKey !== undefined) {\n // If we are already processing an item, we can safely exit\n return;\n }\n const setupTimer = (item) => __awaiter(this, void 0, void 0, function* () {\n processingDeferred = p_defer_1.default();\n const delay = item[1][property] - Date.now();\n if (delay <= 0) {\n // Remove the item immediately if the delay is equal to or below 0\n map.delete(item[0]);\n processingDeferred.resolve();\n return;\n }\n // Keep track of the current processed key\n processingKey = item[0];\n processingTimer = setTimeout(() => {\n // Remove the item when the timeout fires\n map.delete(item[0]);\n if (processingDeferred) {\n processingDeferred.resolve();\n }\n }, delay);\n // tslint:disable-next-line:strict-type-predicates\n if (typeof processingTimer.unref === 'function') {\n // Don't hold up the process from exiting\n processingTimer.unref();\n }\n return processingDeferred.promise;\n });\n try {\n for (const entry of map) {\n yield setupTimer(entry);\n }\n }\n catch (_a) {\n // Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing\n }\n processingKey = undefined;\n });\n const reset = () => {\n processingKey = undefined;\n if (processingTimer !== undefined) {\n clearTimeout(processingTimer);\n processingTimer = undefined;\n }\n if (processingDeferred !== undefined) { // tslint:disable-line:early-exit\n processingDeferred.reject(undefined);\n processingDeferred = undefined;\n }\n };\n const originalSet = map.set.bind(map);\n map.set = (key, value) => {\n if (map.has(key)) {\n // If the key already exist, remove it so we can add it back at the end of the map.\n map.delete(key);\n }\n // Call the original `map.set`\n const result = originalSet(key, value);\n // If we are already processing a key and the key added is the current processed key, stop processing it\n if (processingKey && processingKey === key) {\n reset();\n }\n // Always run the cleanup method in case it wasn't started yet\n cleanup(); // tslint:disable-line:no-floating-promises\n return result;\n };\n cleanup(); // tslint:disable-line:no-floating-promises\n return map;\n}\nexports.default = mapAgeCleaner;\n// Add support for CJS\nmodule.exports = mapAgeCleaner;\nmodule.exports.default = mapAgeCleaner;\n","import mimicFn from 'mimic-fn';\nimport mapAgeCleaner from 'map-age-cleaner';\nconst cacheStore = new WeakMap();\n/**\n[Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.\n\n@param fn - Function to be memoized.\n\n@example\n```\nimport mem from 'mem';\n\nlet index = 0;\nconst counter = () => ++index;\nconst memoized = mem(counter);\n\nmemoized('foo');\n//=> 1\n\n// Cached as it's the same argument\nmemoized('foo');\n//=> 1\n\n// Not cached anymore as the arguments changed\nmemoized('bar');\n//=> 2\n\nmemoized('bar');\n//=> 2\n```\n*/\nexport default function mem(fn, { cacheKey, cache = new Map(), maxAge, } = {}) {\n if (typeof maxAge === 'number') {\n mapAgeCleaner(cache);\n }\n const memoized = function (...arguments_) {\n const key = cacheKey ? cacheKey(arguments_) : arguments_[0];\n const cacheItem = cache.get(key);\n if (cacheItem) {\n return cacheItem.data; // eslint-disable-line @typescript-eslint/no-unsafe-return\n }\n const result = fn.apply(this, arguments_);\n cache.set(key, {\n data: result,\n maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY,\n });\n return result; // eslint-disable-line @typescript-eslint/no-unsafe-return\n };\n mimicFn(memoized, fn, {\n ignoreNonConfigurable: true,\n });\n cacheStore.set(memoized, cache);\n return memoized;\n}\n/**\n@returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.\n\n@example\n```\nimport {memDecorator} from 'mem';\n\nclass Example {\n index = 0\n\n @memDecorator()\n counter() {\n return ++this.index;\n }\n}\n\nclass ExampleWithOptions {\n index = 0\n\n @memDecorator({maxAge: 1000})\n counter() {\n return ++this.index;\n }\n}\n```\n*/\nexport function memDecorator(options = {}) {\n const instanceMap = new WeakMap();\n return (target, propertyKey, descriptor) => {\n const input = target[propertyKey]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n if (typeof input !== 'function') {\n throw new TypeError('The decorated value must be a function');\n }\n delete descriptor.value;\n delete descriptor.writable;\n descriptor.get = function () {\n if (!instanceMap.has(this)) {\n const value = mem(input, options);\n instanceMap.set(this, value);\n return value;\n }\n return instanceMap.get(this);\n };\n };\n}\n/**\nClear all cached data of a memoized function.\n\n@param fn - Memoized function.\n*/\nexport function memClear(fn) {\n const cache = cacheStore.get(fn);\n if (!cache) {\n throw new TypeError('Can\\'t clear a function that was not memoized!');\n }\n if (typeof cache.clear !== 'function') {\n throw new TypeError('The cache Map can\\'t be cleared!');\n }\n cache.clear();\n}\n","import deepmerge from 'deepmerge';\nimport { noCase } from 'no-case';\nimport mem from 'mem';\nimport isObject from '../../utils/object/isObject.js';\n\n/**\n * @typedef {import('../index.js').BaseConfig} BaseConfig\n * @typedef {StringConstructor|NumberConstructor|BooleanConstructor|ArrayConstructor|ObjectConstructor} OptionType\n * @typedef {{ [name:string]: OptionType | { type: OptionType, default: String|Number|Boolean|(() => Array|Object)} }} OptionsSchema\n * @typedef {{ [optionName:string]: any }} OptionsInterface\n */\n\n/**\n * Get the attribute name based on the given option name.\n * @param {String} name The option name.\n */\nfunction getAttributeName(name) {\n return `data-option-${noCase(name, { delimiter: '-' })}`;\n}\n\nconst memoizedGetAttributeName = mem(getAttributeName);\n\n/**\n * Class options to manage options as data attributes on an HTML element.\n * @augments {OptionsInterface}\n */\nexport default class OptionsManager {\n /**\n * The HTML element holding the options attributes.\n * @type {HTMLElement}\n * @private\n */\n __element;\n\n /**\n * An object to store Array and Object values for reference.\n * @type {Object}\n * @private\n */\n __values = {};\n\n /**\n * List of allowed types.\n * @type {Array}\n * @private\n */\n static types = [String, Number, Boolean, Array, Object];\n\n /**\n * The default values to return for each available type.\n * @type {Object}\n * @private\n */\n __defaultValues = {\n String: '',\n Number: 0,\n Boolean: false,\n Array: () => [],\n Object: () => ({}),\n };\n\n /**\n * Default value for the name property.\n * @type {string}\n */\n name = 'Base';\n\n /**\n * Default value for the debug property.\n * @type {boolean}\n */\n debug = false;\n\n /**\n * Default value for the log property.\n * @type {Boolean}\n */\n log = false;\n\n /**\n * Class constructor.\n *\n * @param {HTMLElement} element The HTML element storing the options.\n * @param {OptionsSchema} schema A Base class config options.\n * @param {BaseConfig} baseConfig A Base class config.\n */\n constructor(element, schema, baseConfig) {\n this.__element = element;\n this.name = baseConfig.name;\n\n schema.debug = {\n type: Boolean,\n default: baseConfig.debug ?? false,\n };\n\n schema.log = {\n type: Boolean,\n default: baseConfig.log ?? false,\n };\n\n Object.entries(schema).forEach(([name, config]) => {\n const isObjectConfig = !OptionsManager.types.includes(config);\n /** @type {OptionType} */\n // @ts-ignore\n const type = isObjectConfig ? config.type : config;\n\n if (!OptionsManager.types.includes(type)) {\n throw new Error(\n `The \"${name}\" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`\n );\n }\n\n // @ts-ignore\n const defaultValue = isObjectConfig ? config.default : this.__defaultValues[type.name];\n\n if ((type === Array || type === Object) && typeof defaultValue !== 'function') {\n throw new Error(\n `The default value for options of type \"${type.name}\" must be returned by a function.`\n );\n }\n\n Object.defineProperty(this, name, {\n get: () => {\n return this.get(name, type, defaultValue);\n },\n set: (value) => {\n this.set(name, type, value, defaultValue);\n },\n enumerable: true,\n });\n });\n\n return this;\n }\n\n /**\n * Get an option value.\n *\n * @param {String} name The option name.\n * @param {ArrayConstructor|ObjectConstructor|StringConstructor|NumberConstructor|BooleanConstructor} type The option data's type.\n * @param {any} defaultValue The default value for this option.\n */\n get(name, type, defaultValue) {\n const attributeName = memoizedGetAttributeName(name);\n const hasAttribute = this.__element.hasAttribute(attributeName);\n\n if (type === Boolean) {\n if (defaultValue) {\n const negatedAttributeName = memoizedGetAttributeName(`no-${name}`);\n const hasNegatedAttribute = this.__element.hasAttribute(negatedAttributeName);\n\n return !hasNegatedAttribute;\n }\n\n return hasAttribute || defaultValue;\n }\n\n const value = this.__element.getAttribute(attributeName);\n\n if (type === Number) {\n return hasAttribute ? Number(value) : defaultValue;\n }\n\n if (type === Array || type === Object) {\n const val = deepmerge(\n defaultValue(),\n hasAttribute ? JSON.parse(value) : this.__defaultValues[type.name]()\n );\n\n if (!this.__values[name]) {\n this.__values[name] = val;\n } else if (val !== this.__values[name]) {\n // When getting the value, wait for the next loop to update the data attribute\n // with the new value. This is a simple trick to avoid using a Proxy to watch\n // for any deep changes on an array or object. It should not break anything as\n // the original value is read once from the data attribute and is then read from\n // the private property `__values`.\n setTimeout(() => {\n this.__element.setAttribute(attributeName, JSON.stringify(this.__values[name]));\n }, 0);\n }\n\n return this.__values[name];\n }\n\n return hasAttribute ? value : defaultValue;\n }\n\n /**\n * Set an option value.\n *\n * @param {String} name The option name.\n * @param {ArrayConstructor|ObjectConstructor|StringConstructor|NumberConstructor|BooleanConstructor} type The option data's type.\n * @param {any} value The new value for this option.\n */\n set(name, type, value, defaultValue) {\n const attributeName = memoizedGetAttributeName(name);\n\n if (value.constructor.name !== type.name) {\n const val = Array.isArray(value) || isObject(value) ? JSON.stringify(value) : value;\n throw new TypeError(\n `The \"${val}\" value for the \"${name}\" option must be of type \"${type.name}\"`\n );\n }\n\n switch (type) {\n case Boolean:\n if (defaultValue) {\n const negatedAttributeName = memoizedGetAttributeName(`no-${name}`);\n\n if (value) {\n this.__element.removeAttribute(negatedAttributeName);\n } else {\n this.__element.setAttribute(negatedAttributeName, '');\n }\n } else if (value) {\n this.__element.setAttribute(attributeName, '');\n } else {\n this.__element.removeAttribute(attributeName);\n }\n break;\n case Array:\n case Object:\n this.__values[name] = value;\n this.__element.setAttribute(attributeName, JSON.stringify(value));\n break;\n default:\n this.__element.setAttribute(attributeName, value);\n }\n }\n}\n","/**\n * Test if the given value is an object.\n *\n * @param {*} value The value to test.\n * @return {Boolean} Whether or not the value is an object.\n */\nexport default function isObject(value) {\n return typeof value === 'object' && !!value && value.toString() === '[object Object]';\n}\n","import autoBind from '../utils/object/autoBind.js';\nimport { callMethod, getComponentElements } from './utils.js';\nimport ChildrenManager from './managers/ChildrenManager.js';\nimport RefsManager from './managers/RefsManager.js';\nimport ServicesManager from './managers/ServicesManager.js';\nimport EventsManager from './managers/EventsManager.js';\nimport OptionsManager from './managers/OptionsManager.js';\n\nlet id = 0;\n\nconst noop = function noop() {};\n\n/**\n * @typedef {typeof Base} BaseComponent\n * @typedef {(Base) => Promise<BaseComponent | { default: BaseComponent }>} BaseAsyncComponent\n * @typedef {OptionsManager & { [name:string]: any }} BaseOptions\n * @typedef {{ [name:string]: HTMLElement | HTMLElement[] }} BaseRefs\n * @typedef {{ [nameOrSelector:string]: Base[] | Promise<Base>[] }} BaseChildren\n * @typedef {{ [nameOrSelector:string]: BaseComponent | BaseAsyncComponent }} BaseConfigComponents\n * @typedef {import('./managers/OptionsManager').OptionsSchema} BaseConfigOptions\n * @typedef {import('./managers/ServicesManager.js').ServiceName} ServiceName\n */\n\n/**\n * @typedef {Object} BaseConfig\n * @property {String} name\n * @property {Boolean} [debug]\n * @property {Boolean} [log]\n * @property {String[]} [refs]\n * @property {BaseConfigComponents} [components]\n * @property {BaseConfigOptions} [options]\n */\n\n/**\n * Base class to easily create components.\n *\n * @example\n * ```js\n * class Component extends Base {\n * static config = {\n * name: 'Component',\n * log: true,\n * };\n *\n * mounted() {\n * this.$log('Component is mounted!');\n * }\n * }\n *\n * class App extends Base {\n * static config = {\n * name: 'App',\n * components: {\n * Component,\n * },\n * };\n * }\n *\n * new App(document.body).$mount();\n * ```\n */\nexport default class Base {\n /**\n * The instance parent.\n * @type {Base}\n */\n $parent = null;\n\n /**\n * The instance id.\n * @type {string}\n */\n $id;\n\n /**\n * The root element.\n * @type {HTMLElement}\n */\n $el;\n\n /**\n * The state of the component.\n * @type {Boolean}\n */\n $isMounted = false;\n\n /**\n * This is a Base instance.\n * @type {Boolean}\n */\n static $isBase = true;\n\n /**\n * Get properties to exclude from the autobind call.\n * @return {Array<String|RegExp>}\n */\n get __excludeFromAutoBind() {\n return [\n '$mount',\n '$update',\n '$destroy',\n '$terminate',\n '$log',\n '$on',\n '$once',\n '$off',\n '$emit',\n 'mounted',\n 'loaded',\n 'ticked',\n 'resized',\n 'moved',\n 'keyed',\n 'scrolled',\n 'destroyed',\n 'terminated',\n ];\n }\n\n /**\n * Merge configuration with the parents' configurations.\n *\n * @return {BaseConfig}\n * @private\n */\n get __config() {\n let proto = Object.getPrototypeOf(this);\n let { config } = proto.constructor;\n\n while (proto.constructor.config && proto.constructor.$isBase) {\n config = {\n ...proto.constructor.config,\n ...config,\n };\n\n if (proto.constructor.config.options) {\n config.options = {\n ...proto.constructor.config.options,\n ...config.options,\n };\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return config;\n }\n\n /**\n * @type {BaseConfig}\n */\n static config;\n\n /**\n * @type {ServicesManager}\n */\n __services;\n\n /**\n * The instance services.\n * @type {ServicesManager}\n */\n get $services() {\n const services = this.__services;\n this.$emit('get:services', services);\n return services;\n }\n\n /**\n * @type {RefsManager}\n */\n __refs;\n\n /**\n * @return {RefsManager}\n */\n get $refs() {\n const refs = this.__refs;\n this.$emit('get:refs', refs);\n return refs;\n }\n\n /**\n * @type {BaseOptions}\n */\n __options;\n\n /**\n * @return {BaseOptions}\n */\n get $options() {\n const options = this.__options;\n this.$emit('get:options', options);\n return options;\n }\n\n /**\n * @type {ChildrenManager}\n */\n __children;\n\n /**\n * @return {ChildrenManager}\n */\n get $children() {\n this.__debug('before:getChildren', this.$el, this.__config.components);\n\n const children = this.__children;\n this.$emit('get:children', children);\n\n this.__debug(this, 'after:getChildren', children);\n\n return children;\n }\n\n /**\n * @type {EventsManager}\n */\n __events;\n\n /**\n * Small helper to log stuff.\n *\n * @return {(...args: any) => void}\n */\n get $log() {\n return this.__options.log ? window.console.log.bind(window, `[${this.__config.name}]`) : noop;\n }\n\n /**\n * Small helper to debug information.\n *\n * @return {(...args:any) => void}\n */\n get __debug() {\n return this.__options.debug && typeof window.__DEV__ !== 'undefined' && window.__DEV__\n ? window.console.log.bind(window, `[debug] [${this.$id}]`)\n : noop;\n }\n\n /**\n * Class constructor where all the magic takes place.\n *\n * @param {HTMLElement} element The component's root element dd.\n */\n constructor(element) {\n if (!element) {\n throw new Error('The root element must be defined.');\n }\n\n const { __config } = this;\n\n if (!__config) {\n throw new Error('The `config` static property must be defined.');\n }\n\n if (!__config.name) {\n throw new Error('The `config.name` property is required.');\n }\n\n this.$id = `${__config.name}-${id}`;\n id += 1;\n\n this.$el = element;\n\n if (!('__base__' in this.$el)) {\n Object.defineProperty(this.$el, '__base__', {\n get: () => this,\n configurable: true,\n });\n }\n\n this.__options = new OptionsManager(element, __config.options || {}, __config);\n this.__services = new ServicesManager(this);\n this.__events = new EventsManager(element, this);\n this.__children = new ChildrenManager(this, element, __config.components || {}, this.__events);\n this.__refs = new RefsManager(this, element, __config.refs || [], this.__events);\n\n // Autobind all methods to the instance\n // @todo Maybe remove for performance reason? This pattern can use a lot of memory when creating\n // a large number of instances.\n autoBind(this, {\n exclude: [...this.__excludeFromAutoBind],\n });\n\n this.__debug('constructor', this);\n\n return this;\n }\n\n /**\n * Trigger the `mounted` callback.\n */\n $mount() {\n this.__debug('$mount');\n\n this.$children.registerAll();\n this.$refs.registerAll();\n this.__events.bindRootElement();\n this.$services.enableAll();\n this.$children.mountAll();\n\n callMethod(this, 'mounted');\n this.$isMounted = true;\n return this;\n }\n\n /**\n * Update the instance children.\n */\n $update() {\n this.__debug('$update');\n\n // Undo\n this.$refs.unregisterAll();\n this.$services.disableAll();\n\n // Redo\n this.$children.registerAll();\n this.$refs.registerAll();\n this.$services.enableAll();\n\n // Update\n this.$children.updateAll();\n\n callMethod(this, 'updated');\n return this;\n }\n\n /**\n * Trigger the `destroyed` callback.\n */\n $destroy() {\n this.__debug('$destroy');\n\n this.__events.unbindRootElement();\n this.$refs.unregisterAll();\n this.$services.disableAll();\n this.$children.destroyAll();\n callMethod(this, 'destroyed');\n this.$isMounted = false;\n return this;\n }\n\n /**\n * Terminate a child instance when it is not needed anymore.\n * @return {void}\n */\n $terminate() {\n this.__debug('$terminate');\n\n // First, destroy the component.\n this.$destroy();\n\n // Execute the `terminated` hook if it exists\n callMethod(this, 'terminated');\n\n // Delete the reference to the instance\n // delete this.$el.__base__;\n\n // And update its status to prevent re-instantiation when accessing the\n // parent's `$children` property\n Object.defineProperty(this.$el, '__base__', {\n value: 'terminated',\n configurable: false,\n writable: false,\n });\n }\n\n /**\n * Factory method to generate multiple instance of the class.\n *\n * @param {String} nameOrSelector The selector on which to mount each instance.\n * @return {Array<Base>} A list of the created instance.\n */\n static $factory(nameOrSelector) {\n if (!nameOrSelector) {\n throw new Error(\n 'The $factory method requires a component’s name or selector to be specified.'\n );\n }\n\n return getComponentElements(nameOrSelector).map((el) => new this(el).$mount());\n }\n\n /**\n * Bind a listener function to an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {EventListenerOrEventListenerObject} listener\n * Function to be called.\n * @param {boolean|AddEventListenerOptions} [options]\n * Options for the `removeEventListener` method.\n * @return {() => void}\n * A function to unbind the listener.\n */\n $on(event, listener, options) {\n this.__debug('$on', event, listener, options);\n\n this.$el.addEventListener(event, listener, options);\n\n return () => {\n this.$off(event, listener, options);\n };\n }\n\n /**\n * Unbind a listener function from an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {EventListenerOrEventListenerObject} listener\n * Function to be removed.\n * @param {boolean|EventListenerOptions} [options]\n * Options for the `removeEventListener` method.\n *\n * @return {void}\n */\n $off(event, listener, options) {\n this.__debug('$off', event, listener);\n\n this.$el.removeEventListener(event, listener, options);\n }\n\n /**\n * Emits an event.\n *\n * @param {string} event\n * Name of the event.\n * @param {any[]} args The arguments to apply to the functions bound to this event.\n * @return {void}\n */\n $emit(event, ...args) {\n this.__debug('$emit', event, args);\n\n this.$el.dispatchEvent(\n new CustomEvent(event, {\n detail: args,\n })\n );\n }\n}\n","import getAllProperties from './getAllProperties.js';\n\n/**\n * Auto-bind methods to an instance.\n *\n * @param {Object} instance The instance.\n * @param {Object} options Define specific methods to include or exlude.\n * @param {Array<String|RegExp>} [options.include] Methods to include.\n * @param {Array<String|RegExp>} [options.exclude] Methods to exclude.\n * @return {Object} The instance.\n */\nexport default function autoBind(instance, options) {\n const { exclude, include } = options || {};\n const filter = (key) => {\n const match = (pattern) => (typeof pattern === 'string' ? key === pattern : pattern.test(key));\n\n if (include) {\n return include.some(match);\n }\n\n if (exclude) {\n return !exclude.some(match);\n }\n\n return true;\n };\n\n getAllProperties(instance)\n .filter(([key]) => key !== 'constructor' && filter(key))\n .forEach(([key, object]) => {\n const descriptor = Object.getOwnPropertyDescriptor(object, key);\n if (descriptor && typeof descriptor.value === 'function') {\n instance[key] = instance[key].bind(instance);\n }\n });\n\n return instance;\n}\n","import Base from '../Base/index.js';\n\n/**\n * @typedef {import('../Base').BaseComponent} BaseComponent\n */\n\n/**\n * Define a component without a class.\n *\n * @param {Object} options The component's object\n * @return {BaseComponent} A component's class.\n */\nexport default function defineComponent(options) {\n const { config, methods, ...hooks } = options;\n\n if (!config) {\n throw new Error('The `config` property is required.');\n }\n\n if (!config.name) {\n throw new Error('The `config.name` property is required.');\n }\n\n /**\n * Component class.\n */\n class Component extends Base {\n /**\n * Component config.\n */\n static config = config;\n }\n\n const allowedHooks = [\n 'mounted',\n 'loaded',\n 'ticked',\n 'resized',\n 'moved',\n 'keyed',\n 'scrolled',\n 'destroyed',\n 'terminated',\n ];\n\n const filteredHooks = Object.entries(hooks).reduce((acc, [name, fn]) => {\n if (allowedHooks.includes(name)) {\n acc[name] = fn;\n } else {\n throw new Error(\n `\n The \"${name}\" method is not a Base lifecycle hook,\n it should be placed in the \"method\" property.\n The following hooks are available: ${allowedHooks.join(', ')}\n `\n );\n }\n\n return acc;\n }, {});\n\n [...Object.entries(methods || {}), ...Object.entries(filteredHooks)].forEach(([name, fn]) => {\n Component.prototype[name] = fn;\n });\n\n return Component;\n}\n","/* eslint-disable import/prefer-default-export */\nimport { getComponentElements } from '../Base/utils.js';\n\n/**\n * Get the target elements for the lazy import helper functions.\n *\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The original selector or element, or list of elements.\n * @param {HTMLElement=} [context]\n * The optional context to use to query for elements.\n *\n * @return {HTMLElement[]} A normalized list of elements.\n */\nexport function getTargetElements(nameOrSelectorOrElement, context) {\n if (typeof nameOrSelectorOrElement === 'string') {\n return getComponentElements(nameOrSelectorOrElement, context);\n }\n\n if (!Array.isArray(nameOrSelectorOrElement)) {\n return [nameOrSelectorOrElement];\n }\n\n return nameOrSelectorOrElement;\n}\n","/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n */\n\n/**\n * Instantiate and mount the given component on the given root element when the page has been loaded\n * and return a function to use the app instance when it is ready.\n *\n * @usage\n * ```js\n * // app.js\n * import Base, { createApp } from '@studiometa/js-toolkit';\n *\n * class App extends Base {\n * static config = {\n * name: 'App',\n * }\n * }\n *\n * export default createApp(App, document.body);\n * ```\n * ```js\n * // other.js\n * import useApp from './app.js';\n *\n * const app = await useApp();\n * console.log(app.$options.name); // 'App'\n * ```\n *\n * @template {BaseComponent} T\n * @param {T} App\n * @param {HTMLElement} rootElement\n *\n * @return {() => Promise<InstanceType<T>>}\n *\n */\nexport default function createApp(App, rootElement) {\n let isLoaded = document.readyState === 'complete';\n let app;\n\n if (!isLoaded) {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n app = new App(rootElement).$mount();\n isLoaded = true;\n }\n });\n } else {\n app = new App(rootElement).$mount();\n }\n\n return function useApp() {\n if (isLoaded) {\n return Promise.resolve(app);\n }\n\n return new Promise((resolve) => {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n setTimeout(() => resolve(app), 0);\n }\n });\n });\n };\n}\n","import defineComponent from './defineComponent.js';\n\n/**\n * Create a Base instance with the given object configuration.\n *\n * @param {HTMLElement|String} elementOrSelector The instance root HTML element.\n * @param {Object} options The Base class configuration.\n */\nexport default function createBase(elementOrSelector, options) {\n const Component = defineComponent(options);\n /** @type {HTMLElement} */\n const element =\n typeof elementOrSelector === 'string'\n ? document.querySelector(elementOrSelector)\n : elementOrSelector;\n return new Component(element);\n}\n","import { getTargetElements } from './utils.js';\n\n/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n * @typedef {import('../Base/index.js').default} Base\n */\n\n/**\n * Import a component on an interaction.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The name or selector for the component.\n * @param {string|string[]} events\n * The events to listen to to trigger the import.\n * @param {Base=} [parent]\n * The parent component.\n *\n * @return {Promise<T>}\n */\nexport default function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {\n const normalizedEvents = typeof events === 'string' ? [events] : events;\n\n let ResolvedClass;\n\n const resolver = (resolve) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n });\n };\n\n return new Promise((resolve) => {\n const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);\n const eventListenerOptions = {\n capture: true,\n passive: true,\n once: true,\n };\n const handler = () => {\n resolver(resolve);\n };\n\n elements.forEach((element) => {\n normalizedEvents.forEach((event) => {\n element.addEventListener(event, handler, eventListenerOptions);\n });\n });\n });\n}\n","/**\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n * @typedef {{ timeout?: number }} ImportWhenIdleOptions\n */\n\n/**\n * Import a component when user is idle.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {ImportWhenIdleOptions=} [options]\n * The time to wait before triggering the callback if never idle.\n *\n * @return {Promise<T>}\n */\nexport default function importWhenIdle(fn, options) {\n let ResolvedClass;\n\n const resolver = (resolve) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n });\n };\n\n return new Promise((resolve) => {\n const timeout = options?.timeout ?? 1;\n\n if (!('requestIdleCallback' in window)) {\n setTimeout(() => {\n resolver(resolve);\n }, timeout);\n } else {\n window.requestIdleCallback(\n () => {\n setTimeout(() => {\n resolver(resolve);\n }, 0);\n },\n { timeout: options?.timeout }\n );\n }\n });\n}\n","import { getTargetElements } from './utils.js';\n\n/**\n * @typedef {import('../Base/index.js').default} Base\n * @typedef {import('../Base/index.js').BaseComponent} BaseComponent\n */\n\n/**\n * Import a component when it is visible.\n *\n * @template {BaseComponent} T\n *\n * @param {() => Promise<T|{default:T}>} fn\n * The import function.\n * @param {string|HTMLElement|HTMLElement[]} nameOrSelectorOrElement\n * The name or selector for the component.\n * @param {Base=} [parent]\n * The parent component.\n * @param {IntersectionObserverInit=} [observerOptions]\n * Options for the `IntersectionObserver` instance.\n *\n * @return {Promise<T>}\n */\nexport default function importWhenVisible(\n fn,\n nameOrSelectorOrElement,\n parent,\n observerOptions = {}\n) {\n let ResolvedClass;\n\n const resolver = (resolve, cb) => {\n fn().then((module) => {\n ResolvedClass = 'default' in module ? module.default : module;\n resolve(ResolvedClass);\n\n if (typeof cb === 'function') {\n cb();\n }\n });\n };\n\n return new Promise((resolve) => {\n const observer = new IntersectionObserver((entries) => {\n const someEntriesAreVisible = entries.some((entry) => entry.isIntersecting);\n if (someEntriesAreVisible) {\n setTimeout(() => {\n resolver(resolve, () => observer.disconnect());\n }, 0);\n }\n }, observerOptions);\n\n const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);\n elements.forEach((element) => observer.observe(element));\n });\n}\n"],"names":["getAllProperties","object","props","testFn","proto","Object","getPrototypeOf","prototype","foundProps","getOwnPropertyNames","filter","name","map","reduce","acc","val","hasMethod","obj","callMethod","instance","method","args","__debug","$isMounted","$emit","call","getComponentElements","nameOrSelector","element","document","selector","elements","Array","from","querySelectorAll","length","ChildrenManager","base","components","eventsManager","this","__base","__element","__components","__eventsManager","registerAll","entries","forEach","_this","__register","component","defineProperty","enumerable","configurable","get","_this2","__getChild","el","ComponentClass","__base__","child","_this3","then","module","default","mountAll","__triggerHookForAll","updateAll","destroyAll","hook","registeredNames","_this4","Promise","resolvedInstance","__triggerHook","unbindChild","bindChild","keys","key","startsWith","RefsManager","refs","__refs","refName","unregisterAll","__unregister","isMultiple","endsWith","propName","normalizeRefName","ref","__filterRefsBelongingToInstance","console","warn","$options","bindRef","value","isArray","unbindRef","replace","ancestor","parentElement","undefined","dataset","Service","callbacks","Map","isInit","init","Error","kill","add","callback","has","size","set","remove","delete","trigger","isTouchEvent","event","TouchEvent","Pointer","isDown","y","window","innerHeight","yLast","x","innerWidth","xLast","hasRaf","documentElement","addEventListener","once","capture","options","passive","handleEvent","type","handler","downHandler","upHandler","removeEventListener","updateValues","touches","_event$touches$","clientY","_event$touches$2","clientX","changed","last","delta","progress","max","pointer","Raf","isTicking","id","raf","requestAnimationFrame","bind","setTimeout","cancelRaf","cancelAnimationFrame","clearTimeout","loop","time","performance","now","debounce","fn","delay","timeout","Resize","width","height","ratio","orientation","breakpointElement","breakpoint","breakpoints","querySelector","getComputedStyle","getPropertyValue","split","ResizeObserver","resize","Scroll","pageYOffset","pageXOffset","debouncedHandler","debounced","direction","scrollingElement","body","scrollWidth","scrollHeight","scroll","ENTER","SPACE","TAB","ESC","LEFT","UP","RIGHT","DOWN","Key","triggered","previousEvent","keyCodes","keyCode","isUp","Load","SERVICES_MAP","scrolled","resized","ticked","moved","keyed","loaded","ServicesManager","service","$id","enable","disable","self","enableAll","serviceName","disableAll","register","useFunction","unregister","EventsManager","rootElement","__methodsCache","WeakMap","__rootElementHandler","normalizeName","__refsHandler","currentTarget","index","$refs","indexOf","__childrenHandler","childName","childrenManager","$children","find","includes","detail","__rootElement","__manageRef","mode","action","__getEventMethodsByName","__getEventNameByMethod","__manageChild","__manageRootElement","modeMethod","bindRootElement","unbindRootElement","normalizedName","regex","RegExp","match","normalizeEventName","methods","test","push","c","toLowerCase","trim","toUpperCase","isMergeableObject","isNonNullObject","stringValue","toString","$$typeof","REACT_ELEMENT_TYPE","isReactElement","isSpecial","Symbol","for","cloneUnlessOtherwiseSpecified","clone","deepmerge","defaultArrayMerge","target","source","concat","getKeys","getOwnPropertySymbols","symbol","propertyIsEnumerable","getEnumerableOwnPropertySymbols","propertyIsOnObject","property","_","arrayMerge","sourceIsArray","destination","hasOwnProperty","propertyIsUnsafe","customMerge","getMergeFunction","mergeObject","all","array","prev","next","lowerCase","str","DEFAULT_SPLIT_REGEXP","DEFAULT_STRIP_REGEXP","input","re","copyProperty","to","ignoreNonConfigurable","toDescriptor","getOwnPropertyDescriptor","fromDescriptor","canCopyProperty","writable","wrappedToString","withName","fromBody","toStringDescriptor","Function","toStringName","ret","promise","resolve","reject","__awaiter","thisArg","_arguments","P","generator","fulfilled","step","e","rejected","result","done","apply","__importDefault","mod","__esModule","p_defer_1","require$$0","mapAgeCleaner","processingKey","processingTimer","processingDeferred","cleanup","setupTimer","item","Date","unref","entry","_a","originalSet","exports","cacheStore","memoizedGetAttributeName","cacheKey","cache","maxAge","memoized","arguments_","cacheItem","data","Number","POSITIVE_INFINITY","Reflect","ownKeys","fromPrototype","setPrototypeOf","changePrototype","newToString","changeToString","mimicFn","mem","splitRegexp","_b","stripRegexp","_c","transform","_d","delimiter","start","end","charAt","slice","join","noCase","OptionsManager","schema","baseConfig","__values","__defaultValues","String","Boolean","debug","log","config","isObjectConfig","types","defaultValue","attributeName","hasAttribute","negatedAttributeName","getAttribute","JSON","parse","setAttribute","stringify","constructor","isObject","TypeError","removeAttribute","noop","Base","$parent","__config","$el","__options","__services","__events","__children","exclude","include","pattern","some","descriptor","autoBind","__excludeFromAutoBind","$mount","$services","$update","$destroy","$terminate","$factory","$on","listener","$off","dispatchEvent","CustomEvent","$isBase","services","children","__DEV__","defineComponent","hooks","Component","allowedHooks","filteredHooks","getTargetElements","nameOrSelectorOrElement","context","App","app","isLoaded","readyState","elementOrSelector","events","parent","normalizedEvents","eventListenerOptions","resolver","requestIdleCallback","observerOptions","observer","IntersectionObserver","isIntersecting","cb","disconnect","observe"],"mappings":"m7BAUwBA,EAAiBC,EAAQC,EAAYC,YAAZD,IAAAA,EAAQ,aAAIC,IAAAA,EAAS,MACpE,IAAMC,EAAQC,OAAOC,eAAeL,GAEpC,GAAIG,IAAUC,OAAOE,UACnB,OAAOL,EAGT,IAAIM,EAAaH,OAAOI,oBAAoBL,GAQ5C,MANsB,mBAAXD,IACTK,EAAaA,EAAWE,OAAO,SAACC,UAASR,EAAOQ,EAAMP,MAGxDI,EAAaA,EAAWI,IAAI,SAACD,SAAS,CAACA,EAAMP,KAAQS,OAAO,SAACC,EAAKC,mBAAYD,GAAKC,KAAMb,GAElFF,EAAiBI,EAAOI,EAAYL,YCd7Ba,EAAUC,EAAKN,GAC7B,MAA4B,mBAAdM,EAAIN,YAUJO,EAAWC,EAAUC,SAAWC,6BAK9C,OAJAF,EAASG,cAATH,GAAiB,aAAcC,UAAWC,IAK5B,cAAXD,IAA2BD,EAASI,YACzB,YAAXH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AkB,QAePjZ,QAAQ,SAACqQ,GAClB,IAAM6I,EAAW,IAAIC,qBAAqB,SAAC7a,GACXA,EAAQqY,KAAK,SAAC1E,UAAUA,EAAMmH,kBAE1D1T,WAAW,YAfA,SAAC2K,EAASgJ,GACzBlT,IAAK7G,KAAK,SAACC,GAET8Q,EADgB,YAAa9Q,EAASA,EAAOC,QAAUD,GAc3B2Z,EAASI,eAAjCP,CAAS1I,IACR,IAEJ4I,GAEcd,GAAkBC,QAAyBQ,SAAAA,EAAQzC,KAC3D5X,QAAQ,SAACnB,UAAY8b,EAASK,QAAQnc"}
|
package/services/Service.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/Service.js"],"names":["Service","callbacks","Map","isInit","Error","key","callback","has","size","init","set","get","delete","kill","args","forEach","forEachCallback"],"mappings":";;;IAGqBA,O;AAInB,qBAAc;AAAA;;AACZ,SAAKC,SAAL,GAAiB,IAAIC,GAAJ,EAAjB;AACA,SAAKC,MAAL,GAAc,KAAd;AACD;;;;SAOD,eAAY;AACV,YAAM,IAAIC,KAAJ,CAAU,yCAAV,CAAN;AACD;;;WAQD,gBAAO;AACL,YAAM,IAAIA,KAAJ,CAAU,wCAAV,CAAN;AACD;;;WAQD,gBAAO;AACL,YAAM,IAAIA,KAAJ,CAAU,wCAAV,CAAN;AACD;;;WASD,aAAIC,GAAJ,EAASC,QAAT,EAAmB;AACjB,UAAI,KAAKC,GAAL,CAASF,GAAT,CAAJ,EAAmB;AACjB,cAAM,IAAID,KAAJ,oCAAuCC,GAAvC,oCAAN;AACD;;AAGD,UAAI,KAAKJ,SAAL,CAAeO,IAAf,KAAwB,CAAxB,IAA6B,CAAC,KAAKL,MAAvC,EAA+C;AAC7C,aAAKM,IAAL;AACA,aAAKN,MAAL,GAAc,IAAd;AACD;;AAED,WAAKF,SAAL,CAAeS,GAAf,CAAmBL,GAAnB,EAAwBC,QAAxB;AACA,aAAO,IAAP;AACD;;;WAQD,aAAID,GAAJ,EAAS;AACP,aAAO,KAAKJ,SAAL,CAAeM,GAAf,CAAmBF,GAAnB,CAAP;AACD;;;WAQD,aAAIA,GAAJ,EAAS;AACP,aAAO,KAAKJ,SAAL,CAAeU,GAAf,CAAmBN,GAAnB,CAAP;AACD;;;WAQD,gBAAOA,GAAP,EAAY;AACV,WAAKJ,SAAL,CAAeW,MAAf,CAAsBP,GAAtB;;AAGA,UAAI,KAAKJ,SAAL,CAAeO,IAAf,KAAwB,CAAxB,IAA6B,KAAKL,MAAtC,EAA8C;AAC5C,aAAKU,IAAL;AACA,aAAKV,MAAL,GAAc,KAAd;AACD;;AAED,aAAO,IAAP;AACD;;;WAQD,mBAAiB;AAAA,wCAANW,IAAM;AAANA,QAAAA,IAAM;AAAA;;AACf,WAAKb,SAAL,CAAec,OAAf,CAAuB,SAASC,eAAT,CAAyBV,QAAzB,EAAmC;AACxDA,QAAAA,QAAQ,MAAR,SAAYQ,IAAZ;AACD,OAFD;AAIA,aAAO,IAAP;AACD;;;;;;SA9GkBd,O","sourcesContent":["/**\n * Service abstract class\n */\nexport default class Service {\n /**\n * Class constructor, used to test the abstract class implementation.\n */\n constructor() {\n this.callbacks = new Map();\n this.isInit = false;\n }\n\n /**\n * Getter to get the services properties.\n * This getter MUST be implementer by the service extending this class.\n * @return {Object}\n */\n get props() {\n throw new Error('The `props` getter must be implemented.');\n }\n\n /**\n * Method to initialize the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n init() {\n throw new Error('The `init` method must be implemented.');\n }\n\n /**\n * Method to kill the service behaviors.\n * This method MUST be implemented by the service extending this class.\n *\n * @return {Service} The current instance\n */\n kill() {\n throw new Error('The `kill` method must be implemented.');\n }\n\n /**\n * Add a callback.\n *\n * @param {String} key The callback's identifier\n * @param {Function} callback The callback function\n * @return {this} The current instance\n */\n add(key, callback) {\n if (this.has(key)) {\n throw new Error(`A callback with the key \\`${key}\\` has already been registered.`);\n }\n\n // Initialize the service when we add the first callback\n if (this.callbacks.size === 0 && !this.isInit) {\n this.init();\n this.isInit = true;\n }\n\n this.callbacks.set(key, callback);\n return this;\n }\n\n /**\n * Test if a callback with the given key has already been added.\n *\n * @param {String} key The identifier to test\n * @return {Boolean} Whether or not the identifier already exists\n */\n has(key) {\n return this.callbacks.has(key);\n }\n\n /**\n * Get the callback tied to the given key.\n *\n * @param {String} key The identifier to get\n * @return {Function} The callback function\n */\n get(key) {\n return this.callbacks.get(key);\n }\n\n /**\n * Remove the callback tied to the given key.\n *\n * @param {String} key The identifier to remove\n * @return {Service} The current instance\n */\n remove(key) {\n this.callbacks.delete(key);\n\n // Kill the service when we remove the last callback\n if (this.callbacks.size === 0 && this.isInit) {\n this.kill();\n this.isInit = false;\n }\n\n return this;\n }\n\n /**\n * Trigger each added callback with the given arguments.\n *\n * @param {Array} args All the arguments to apply to the callback\n * @return {Service} The current instance\n */\n trigger(...args) {\n this.callbacks.forEach(function forEachCallback(callback) {\n callback(...args);\n });\n\n return this;\n }\n}\n"],"file":"Service.js"}
|
package/services/drag.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/drag.js"],"names":["Service","usePointer","useRaf","inertiaFinalValue","MODES","START","DRAG","DROP","INERTIA","STOP","instanceIds","Drag","target","options","x","y","factor","id","pointerHandler","bind","rafHandler","passive","addEventListener","pointer","add","removeEventListener","remove","event","MouseEvent","clientX","touches","clientY","start","origin","delta","distance","final","mode","isGrabbing","trigger","props","hasInertia","setTimeout","raf","Math","abs","stop","isDown","drop","instances","WeakMap","useDrag","drag","get","set","has"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,oCAA9B;AAaA,IAAMC,KAAK,GAAG;AACZC,EAAAA,KAAK,EAAE,OADK;AAEZC,EAAA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AAI,CAAC1B,MAAL,CAAYP,IAAZ,CAAiBiC,IAAjB,CAAf;AACA,MAAMG,GAAG,GAAGH,IAAI,CAACG,GAAL,CAASpC,IAAT,CAAciC,IAAd,CAAZ;;AACA,MAAMZ,KAAK,GAAG,SAARA,KAAQ;AAAA,WAAMY,IAAI,CAACZ,KAAX;AAAA,GAAd;;AAEA,SAAO;AACLhB,IAAAA,GAAG,EAAHA,GADK;AAELE,IAAAA,MAAM,EAANA,MAFK;AAGL6B,IAAAA,GAAG,EAAHA,GAHK;AAILf,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\nimport usePointer from './pointer.js';\nimport useRaf from './raf.js';\nimport inertiaFinalValue from '../utils/math/inertiaFinalValue.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {import('./pointer.js').PointerServiceProps} PointerServiceProps\n */\n\n/**\n * @type {Record<Uppercase<DragLifecycle>, DragLifecycle>}\n */\nconst MODES = {\n START: 'start',\n DRAG: 'drag',\n DROP: 'drop',\n INERTIA: 'inertia',\n STOP: 'stop',\n};\n\n/**\n * @typedef {'start'|'drag'|'drop'|'inertia'|'stop'} DragLifecycle\n */\n\n/**\n * @typedef {Object} DragServiceProps\n * @property {DragLifecycle} mode\n * The current mode of the dragging logic.\n * @property {HTMLElement} target\n * The target element of the drag.\n * @property {boolean} isGrabbing\n * Whether the user is currently grabbing the targeted element or not.\n * @property {boolean} hasInertia\n * Whether the drag currently has inertia or not.\n * @property {number} x\n * The current horizontal position in the viewport.\n * @property {number} y\n * The current vertical position in the viewport.\n * @property {{ x: number, y: number }} delta\n * The delta between the current position and the last.\n * @property {{ x: number, y: number }} origin\n * The initial position where the dragging started.\n * @property {{ x: number, y: number }} distance\n * The distance from the current position to the origin.\n * @property {{ x: number, y: number }} final\n * The final position that will be reached at the end of the inertia.\n */\n\n/**\n * @typedef {Object} DragServiceOptions\n * @property {number=} [factor]\n */\n\n/**\n * @typedef {Object} DragService\n * @property {(target:HTMLElement, callback:(props:DragServiceProps) => void, options?:DragServiceOptions) => void} add\n * Add a callback function to the service. The key must be the HTML element targeted by the drag.\n * @property {(target:HTMLElement) => void} remove\n * Remove a callback function to the service.\n * @property {() => DragServiceProps} props\n * Get the current values of the resize service props.\n */\n\nlet instanceIds = 0;\n\n/**\n * Drag service\n */\nclass Drag extends Service {\n /**\n * The instance ID.\n * @type {string}\n */\n id;\n\n /**\n * The target element\n * @type {HTMLElement}\n */\n target;\n\n /**\n * The drag mode, use it to follow the different parts of the drag.\n * @type {DragLifecycle}\n */\n mode;\n\n /**\n * Whether we are currently dragging or not.\n * @type {Boolean}\n */\n isGrabbing = false;\n\n /**\n * Whether we are currently runnnig with inertia.\n * @type {Boolean}\n */\n hasInertia = false;\n\n /**\n * The horizontal position of the drag.\n * @type {Number}\n */\n x = 0;\n\n /**\n * The vertical position of the drag.\n * @type {Number}\n */\n y = 0;\n\n /**\n * The velocity of the drag.\n * @type {{ x: number, y: number }}\n */\n delta = {\n x: 0,\n y: 0,\n };\n\n /**\n * The origin of the drag.\n * @type {{ x: number, y: number }}\n */\n origin = {\n x: 0,\n y: 0,\n };\n\n /**\n * The origin of the drag.\n * @type {{ x: number, y: number }}\n */\n distance = {\n x: 0,\n y: 0,\n };\n\n /**\n * The final position of the inertia.\n * @type {{ x: number, y: number }}\n */\n final = {\n x: 0,\n y: 0,\n };\n\n /**\n * Options.\n * @type {DragServiceOptions}\n */\n options = {\n factor: 0.85,\n };\n\n /**\n * Class constructor.\n * @param {HTMLElement} target The drag target.\n * @param {DragServiceOptions} options The drag options.\n */\n constructor(target, options = {}) {\n super();\n instanceIds += 1;\n this.id = `drag-${instanceIds}`;\n this.target = target;\n this.options = { ...this.options, ...options };\n this.pointerHandler = this.pointerHandler.bind(this);\n this.rafHandler = this.rafHandler.bind(this);\n return this;\n }\n\n /**\n * Bind the handler to the mousemove and touchmove events.\n * Bind the up and down handler to the mousedown, mouseup, touchstart and touchend events.\n *\n * @return {this}\n */\n init() {\n const options = { passive: true };\n this.target.addEventListener('mousedown', this, options);\n this.target.addEventListener('touchstart', this, options);\n\n const pointer = usePointer();\n pointer.add(this.id, this.pointerHandler);\n\n return this;\n }\n\n /**\n * Unbind all handlers from their bounded event.\n *\n * @return {this}\n */\n kill() {\n this.target.removeEventListener('mousemove', this);\n this.target.removeEventListener('touchmove', this);\n\n const pointer = usePointer();\n pointer.remove(this.id);\n return this;\n }\n\n /**\n * Handle any event.\n * @param {MouseEvent|TouchEvent} event [description]\n */\n handleEvent(event) {\n const x = event instanceof MouseEvent ? event.clientX : event.touches[0].clientX;\n const y = event instanceof MouseEvent ? event.clientY : event.touches[0].clientY;\n this.start(x, y);\n }\n\n /**\n * Start the drag.\n * @param {number} x The initial horizontal position.\n * @param {number} y The initial vertical position.\n * @return {void}\n */\n start(x, y) {\n // Reset state\n this.x = x;\n this.y = y;\n this.origin.x = x;\n this.origin.y = y;\n this.delta.x = 0;\n this.delta.y = 0;\n this.distance.x = 0;\n this.distance.y = 0;\n this.final.x = x;\n this.final.y = y;\n\n this.mode = MODES.START;\n\n // Enable grabbing\n this.isGrabbing = true;\n\n this.trigger(this.props);\n }\n\n /**\n * Stop the drag, or drop.\n * @return {void}\n */\n drop() {\n this.isGrabbing = false;\n this.mode = MODES.DROP;\n\n this.hasInertia = true;\n this.final.x = inertiaFinalValue(this.x, this.delta.x, this.options.factor);\n this.final.y = inertiaFinalValue(this.y, this.delta.y, this.options.factor);\n\n this.trigger(this.props);\n\n setTimeout(() => {\n const raf = useRaf();\n raf.remove(this.id);\n raf.add(this.id, this.rafHandler);\n }, 0);\n }\n\n /**\n * Stop the drag.\n */\n stop() {\n useRaf().remove(this.id);\n this.hasInertia = false;\n this.mode = MODES.STOP;\n this.trigger(this.props);\n }\n\n /**\n * Raf service handler.\n * @return {void}\n */\n rafHandler() {\n if (!this.isGrabbing) {\n this.x += this.delta.x;\n this.y += this.delta.y;\n this.distance.x = this.x - this.origin.x;\n this.distance.y = this.y - this.origin.y;\n\n this.delta.x *= this.options.factor;\n this.delta.y *= this.options.factor;\n\n if (this.mode !== MODES.INERTIA) {\n this.mode = MODES.INERTIA;\n }\n\n this.trigger(this.props);\n\n if (Math.abs(this.delta.x) < 0.1 && Math.abs(this.delta.y) < 0.1) {\n this.stop();\n }\n }\n }\n\n /**\n * Pointer service handler.\n * @param {PointerServiceProps} props\n * @return {void}\n */\n pointerHandler(props) {\n if (this.isGrabbing) {\n this.x = props.x;\n this.y = props.y;\n this.delta.x = props.delta.x;\n this.delta.y = props.delta.y;\n this.final.x = props.x;\n this.final.y = props.y;\n this.distance.x = this.x - this.origin.x;\n this.distance.y = this.y - this.origin.y;\n\n if (this.mode !== MODES.DRAG) {\n this.mode = MODES.DRAG;\n }\n\n this.trigger(this.props);\n\n if (!props.isDown) {\n this.drop();\n }\n }\n }\n\n /**\n * Get the pointer props.\n *\n * @type {Object}\n */\n get props() {\n return {\n target: this.target,\n mode: this.mode,\n isGrabbing: this.isGrabbing,\n hasInertia: this.hasInertia,\n x: this.x,\n y: this.y,\n delta: this.delta,\n origin: this.origin,\n distance: this.distance,\n final: this.final,\n };\n }\n}\n\nconst instances = new WeakMap();\n\n/**\n * Use the pointer.\n *\n * ```js\n * import { useDrag } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useDrag();\n * const draggableElement = document.querySelector('.draggable');\n * add(draggableElement, (props) => {}, { factor: 0.8 });\n * remove(draggableElement);\n * props(draggableElement);\n * ```\n *\n * @param {HTMLElement} target\n * @param {DragServiceOptions} options\n * @return {ServiceInterface & DragService}\n */\nexport default function useDrag(target, options) {\n let drag = instances.get(target);\n\n if (!drag) {\n drag = new Drag(target, options);\n instances.set(target, drag);\n }\n\n const add = drag.add.bind(drag);\n const remove = drag.remove.bind(drag);\n const has = drag.has.bind(drag);\n const props = () => drag.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"drag.js"}
|
package/services/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/index.js"],"names":["useDrag","useKey","useLoad","usePointer","useRaf","useResize","useScroll"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,WAApB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AAYA,SAASL,MAAT,EAAiBE,UAAjB,EAA6BH,OAA7B,EAAsCE,OAAtC,EAA+CE,MAA/C,EAAuDC,SAAvD,EAAkEC,SAAlE","sourcesContent":["import useDrag from './drag.js';\nimport useKey from './key.js';\nimport useLoad from './load.js';\nimport usePointer from './pointer.js';\nimport useRaf from './raf.js';\nimport useResize from './resize.js';\nimport useScroll from './scroll.js';\n\n/**\n * @typedef {Object} ServiceInterface\n * @property {(key:String) => void} remove\n * Remove a function from the resize service by its key.\n * @property {(key:String, cb: (props: Object) => void) => Boolean} add\n * Add a callback to the service. The callback will receive the current service props as parameter.\n * @property {(key:String) => Boolean} has\n * Test if the service has alreaydy a callback for the given key.\n */\n\nexport { useKey, usePointer, useDrag, useLoad, useRaf, useResize, useScroll };\n"],"file":"index.js"}
|
package/services/key.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/key.js"],"names":["Service","keyCodes","Key","handler","event","trigger","props","document","addEventListener","passive","removeEventListener","keys","Object","entries","reduce","acc","name","code","keyCode","previousEvent","type","triggered","direction","isUp","isDown","key","useKey","add","bind","remove","has"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,QAAP,MAAqB,sBAArB;;IAiCMC,G;;;;;;;;;;;;;;;;4DAEI,E;;gEAMI,C;;oEAGI,E;;;;;;;WAOhB,gBAAO;AAAA;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AAEA;AACEA,QAAAA,KAAK,EAAE,KAAKA,KADd;AAEEiB,QAAAA,SAAS,EAAE,KAAKA,SAFlB;AAGEC,QAAAA,SAAS,EAAE,KAAKlB,KAAL,CAAWgB,IAAX,KAAoB,SAApB,GAAgC,MAAhC,GAAyC,IAHtD;AAIEG,QAAAA,IAAI,EAAE,KAAKnB,KAAL,CAAWgB,IAAX,KAAoB,OAJ5B;AAKEI,QAAAA,MAAM,EAAE,KAAKpB,KAAL,CAAWgB,IAAX,KAAoB;AAL9B,SAMKT,IANL;AAQD;;;;EAtEeX,O;;AAyElB,IAAIyB,GAAG,GAAG,IAAV;AAeA,eAAe,SAASC,MAAT,GAAkB;AAC/B,MAAI,CAACD,GAAL,EAAU;AACRA,IAAAA,GAAG,GAAG,IAAIvB,GAAJ,EAAN;AACD;;AAED,MAAMyB,GAAG,GAAGF,GAAG,CAACE,GAAJ,CAAQC,IAAR,CAAaH,GAAb,CAAZ;AACA,MAAMI,MAAM,GAAGJ,GAAG,CAACI,MAAJ,CAAWD,IAAX,CAAgBH,GAAhB,CAAf;AACA,MAAMK,GAAG,GAAGL,GAAG,CAACK,GAAJ,CAAQF,IAAR,CAAaH,GAAb,CAAZ;;AACA,MAAMnB,KAAK,GAAG,SAARA,KAAQ;AAAA,WAAMmB,GAAG,CAACnB,KAAV;AAAA,GAAd;;AAEA,SAAO;AACLqB,IAAAA,GAAG,EAAHA,GADK;AAELE,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAILxB,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\nimport keyCodes from '../utils/keyCodes.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} KeyServiceProps\n * @property {KeyboardEvent} event\n * @property {Number} triggered\n * @property {Boolean} isUp\n * @property {Boolean} isDown\n * @property {Boolean} ENTER\n * @property {Boolean} SPACE\n * @property {Boolean} TAB\n * @property {Boolean} ESC\n * @property {Boolean} LEFT\n * @property {Boolean} UP\n * @property {Boolean} RIGHT\n * @property {Boolean} DOWN\n */\n\n/**\n * @typedef {Object} KeyService\n * @property {(key:String, callback:(props:KeyServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => KeyServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Key extends Service {\n /** @type {Object} The event object. */\n event = {};\n\n /**\n * Used to accumulate the number of times the `keydown` event has been triggered.\n * @type {Number}\n */\n triggered = 0;\n\n /** @type {Object} The previous event object. */\n previousEvent = {};\n\n /**\n * Bind the handler to the keyboard event.\n *\n * @return {Key}\n */\n init() {\n this.handler = (event) => {\n this.event = event;\n this.trigger(this.props);\n };\n document.addEventListener('keydown', this.handler, { passive: false });\n document.addEventListener('keyup', this.handler, { passive: false });\n return this;\n }\n\n /**\n * Unbind the handler from the keyboard event.\n *\n * @return {Key}\n */\n kill() {\n document.removeEventListener('keydown', this.handler);\n document.removeEventListener('keyup', this.handler);\n return this;\n }\n\n /**\n * Get keyboard props.\n *\n * @type {Object}\n */\n get props() {\n const keys = Object.entries(keyCodes).reduce((acc, [name, code]) => {\n acc[name] = code === this.event.keyCode;\n return acc;\n }, {});\n\n if (!this.previousEvent.type) {\n this.triggered = 0;\n }\n\n if (this.event.type === 'keydown' && this.previousEvent.type === 'keydown') {\n this.triggered += 1;\n } else {\n this.triggered = 1;\n }\n\n this.previousEvent = this.event;\n\n return {\n event: this.event,\n triggered: this.triggered,\n direction: this.event.type === 'keydown' ? 'down' : 'up',\n isUp: this.event.type === 'keyup',\n isDown: this.event.type === 'keydown',\n ...keys,\n };\n }\n}\n\nlet key = null;\n\n/**\n * Use the keyboard service.\n *\n * ```js\n * import { useKey } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useKey();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & KeyService}\n */\nexport default function useKey() {\n if (!key) {\n key = new Key();\n }\n\n const add = key.add.bind(key);\n const remove = key.remove.bind(key);\n const has = key.has.bind(key);\n const props = () => key.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"key.js"}
|
package/services/load.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/load.js"],"names":["Service","Load","handler","trigger","props","window","addEventListener","removeEventListener","instance","useRaf","add","bind","remove","has"],"mappings":";;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;;IAsBMC,I;;;;;;;;;;;;;WAMJ,gBAAO;AAAA;;AACL,WAAKC,OAAL,GAAe,YAAM;AACnB,QAAA,KAAI,CAACC,OAAL,CAAa,KAAI,CAACC,KAAlB;AACD,OAFD;;AAIAC,MAAAA,MAAM,CAACC,gBAAP,CAAwB,MAAxB,EAAgC,KAAKJ,OAArC;AACA,aAAO,IAAP;AACD;;;WAOD,gBAAO;AACLG,MAAAA,MAAM,CAACE,mBAAP,CAA2B,MAA3B,EAAmC,KAAKL,OAAxC;AACA,aAAO,IAAP;AACD;;;SAQD,eAAY;AACV,aAAO,EAAP;AACD;;;;EAjCgBF,O;;AAoCnB,IAAIQ,QAAQ,GAAG,IAAf;AAeA,eAAe,SAASC,MAAT,GAAkB;AAC/B,MAAI,CAACD,QAAL,EAAe;AACbA,IAAAA,QAAQ,GAAG,IAAIP,IAAJ,EAAX;AACD;;AAED,MAAMS,GAAG,GAAGF,QAAQ,CAACE,GAAT,CAAaC,IAAb,CAAkBH,QAAlB,CAAZ;AACA,MAAMI,MAAM,GAAGJ,QAAQ,CAACI,MAAT,CAAgBD,IAAhB,CAAqBH,QAArB,CAAf;AACA,MAAMK,GAAG,GAAGL,QAAQ,CAACK,GAAT,CAAaF,IAAb,CAAkBH,QAAlB,CAAZ;;AAGA,WAASJ,KAAT,GAAiB;AACf,WAAOI,QAAQ,CAACJ,KAAhB;AACD;;AAED,SAAO;AACLM,IAAAA,GAAG,EAAHA,GADK;AAELE,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAILT,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} LoadServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} LoadService\n * @property {(key:String, callback:(props:LoadServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => LoadServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Load service\n */\nclass Load extends Service {\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n init() {\n this.handler = () => {\n this.trigger(this.props);\n };\n\n window.addEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Load}\n */\n kill() {\n window.removeEventListener('load', this.handler);\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {};\n }\n}\n\nlet instance = null;\n\n/**\n * Use the load service.\n *\n * ```js\n * import { useLoad } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & LoadService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Load();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"load.js"}
|
package/services/pointer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/pointer.js"],"names":["Service","isTouchEvent","event","TouchEvent","Pointer","window","innerHeight","innerWidth","document","documentElement","addEventListener","once","capture","options","passive","type","handler","downHandler","upHandler","removeEventListener","updateValues","trigger","props","isDown","yLast","y","xLast","x","touches","clientY","clientX","changed","last","delta","progress","max","pointer","usePointer","add","bind","remove","has"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;;AAiCA,SAASC,YAAT,CAAsBC,KAAtB,EAA6B;AAC3B,SAAO,OAAOC,UAAP,KAAsB,WAAtB,IAAqCD,KAAK,YAAYC,UAA7D;AACD;;IAKKC,O;;;;;;;;;;;;;;;;6DAEK,K;;wDAGLC,MAAM,CAACC,WAAP,GAAqB,C;;4DAGjBD,MAAM,CAACC,WAAP,GAAqB,C;;wDAGzBD,MAAM,CAACE,UAAP,GAAoB,C;;4DAGhBF,MAAM,CAACE,UAAP,GAAoB,C;;;;6DASnB,K;;;;;;;WAQT,gBAAO;AACLC,MAAAA,QAAQ,CAACC,eAAT,CAAyBC,gBAAzB,CAA0C,YAA1C,EAAwD,IAAxD,EAA8D;AAC5DC,QAAAA,IAAI,EAAE,IADsD;AAE5DC,QAAAA,OAAO,EAAE;AAFmD,OAA9D;AAKA,UAAMC,OAAO,GAAG;AAAEC,QAAAA,OAAO,EAAE,IAAX;AAAiBF,QAAAA,OAAO,EAAE;AAA1B,OAAhB;AACAJ,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,WAA1B,EAAuC,IAAvC,EAA6CG,OAA7C;AACAL,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,WAA1B,EAAuC,IAAvC,EAA6CG,OAA7C;AACAL,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,WAA1B,EAAuC,IAAvC,EAA6CG,OAA7C;AACAL,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,YAA1B,EAAwC,IAAxC,EAA8CG,OAA9C;AACAL,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,SAA1B,EAAqC,IAArC,EAA2CG,OAA3C;AACAL,MAAAA,QAAQ,CAACE,gBAAT,CAA0B,UAA1B,EAAsC,IAAtC,EAA4CG,OAA5C;AACA,aAAO,IAAP;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AAA,CAAC,EAAEpB,MAAM,CAACC;AAFP;AArBA,OAAP;AA0BD;;;;EAlLmBN,O;;AAqLtB,IAAIoC,OAAO,GAAG,IAAd;AAeA,eAAe,SAASC,UAAT,GAAsB;AACnC,MAAI,CAACD,OAAL,EAAc;AACZA,IAAAA,OAAO,GAAG,IAAIhC,OAAJ,EAAV;AACD;;AAED,MAAMkC,GAAG,GAAGF,OAAO,CAACE,GAAR,CAAYC,IAAZ,CAAiBH,OAAjB,CAAZ;AACA,MAAMI,MAAM,GAAGJ,OAAO,CAACI,MAAR,CAAeD,IAAf,CAAoBH,OAApB,CAAf;AACA,MAAMK,GAAG,GAAGL,OAAO,CAACK,GAAR,CAAYF,IAAZ,CAAiBH,OAAjB,CAAZ;;AACA,MAAMd,KAAK,GAAG,SAARA,KAAQ;AAAA,WAAMc,OAAO,CAACd,KAAd;AAAA,GAAd;;AAEA,SAAO;AACLgB,IAAAA,GAAG,EAAHA,GADK;AAELE,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAILnB,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} PointerServiceProps\n * @property {MouseEvent | TouchEvent} event\n * @property {Boolean} isDown\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n */\n\n/**\n * @typedef {Object} PointerService\n * @property {(key:String, callback:(props:PointerServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => PointerServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Test if an event is an instance of TouchEvent.\n *\n * @param {TouchEvent|MouseEvent} event The event instance to test.\n * @return {Boolean} Is it a TouchEvent?\n */\nfunction isTouchEvent(event) {\n return typeof TouchEvent !== 'undefined' && event instanceof TouchEvent;\n}\n\n/**\n * Pointer service\n */\nclass Pointer extends Service {\n /** @type {Boolean} State of the pointer. */\n isDown = false;\n\n /** @type {Number} The y pointer position. */\n y = window.innerHeight / 2;\n\n /** @type {Number} The y previous pointer position. */\n yLast = window.innerHeight / 2;\n\n /** @type {Number} The x pointer position. */\n x = window.innerWidth / 2;\n\n /** @type {Number} The x previous pointer position. */\n xLast = window.innerWidth / 2;\n\n /** @type {MouseEvent|TouchEvent} The latest event emitted from the pointer. */\n event;\n\n /**\n * Whether or not the raf service is running.\n * @type {Boolean}\n */\n hasRaf = false;\n\n /**\n * Bind the handler to the mousemove and touchmove events.\n * Bind the up and down handler to the mousedown, mouseup, touchstart and touchend events.\n *\n * @return {Pointer}\n */\n init() {\n document.documentElement.addEventListener('mouseenter', this, {\n once: true,\n capture: true,\n });\n\n const options = { passive: true, capture: true };\n document.addEventListener('mousemove', this, options);\n document.addEventListener('touchmove', this, options);\n document.addEventListener('mousedown', this, options);\n document.addEventListener('touchstart', this, options);\n document.addEventListener('mouseup', this, options);\n document.addEventListener('touchend', this, options);\n return this;\n }\n\n /**\n * Handle events.\n * @param {MouseEvent|TouchEvent} event The event object.\n */\n handleEvent(event) {\n // eslint-disable-next-line default-case\n switch (event.type) {\n case 'mouseenter':\n case 'mousemove':\n case 'touchmove':\n this.handler(event);\n break;\n case 'mousedown':\n case 'touchstart':\n this.downHandler();\n break;\n case 'mouseup':\n case 'touchend':\n this.upHandler();\n break;\n }\n }\n\n /**\n * Unbind all handlers from their bounded event.\n *\n * @return {Pointer}\n */\n kill() {\n document.removeEventListener('mousemove', this);\n document.removeEventListener('touchmove', this);\n document.removeEventListener('mousedown', this);\n document.removeEventListener('touchstart', this);\n document.removeEventListener('mouseup', this);\n document.removeEventListener('touchend', this);\n return this;\n }\n\n /**\n * The service handler.\n * @param {MouseEvent|TouchEvent} event The mouse event object.\n */\n handler(event) {\n this.updateValues(event);\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's down action.\n *\n * @return {void}\n */\n downHandler() {\n this.isDown = true;\n this.trigger(this.props);\n }\n\n /**\n * Handler for the pointer's up action.\n *\n * @return {void}\n */\n upHandler() {\n this.isDown = false;\n this.trigger(this.props);\n }\n\n /**\n * Update the pointer positions.\n *\n * @param {MouseEvent|TouchEvent} event The event object.\n * @return {void}\n */\n updateValues(event) {\n this.event = event;\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check pointer Y\n // We either get data from a touch event `event.touches[0].clientY` or from\n // a mouse event `event.clientY`.\n const y = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientY\n : /** @type {MouseEvent} */ (event).clientY;\n if (y !== this.y) {\n this.y = y;\n }\n\n // Check pointer X\n // We either get data from a touch event `event.touches[0].clientX` or from\n // a mouse event `event.clientX`.\n const x = isTouchEvent(event)\n ? /** @type {TouchEvent} */ (event).touches[0]?.clientX\n : /** @type {MouseEvent} */ (event).clientX;\n if (x !== this.x) {\n this.x = x;\n }\n }\n\n /**\n * Get the pointer props.\n *\n * @type {Object}\n */\n get props() {\n return {\n event: this.event,\n isDown: this.isDown,\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.x / window.innerWidth,\n y: this.y / window.innerHeight,\n },\n max: {\n x: window.innerWidth,\n y: window.innerHeight,\n },\n };\n }\n}\n\nlet pointer = null;\n\n/**\n * Use the pointer.\n *\n * ```js\n * import usePointer from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = usePointer();\n * add('id', () => {});\n * remove('id');\n * props();\n * ```\n *\n * @return {ServiceInterface & PointerService}\n */\nexport default function usePointer() {\n if (!pointer) {\n pointer = new Pointer();\n }\n\n const add = pointer.add.bind(pointer);\n const remove = pointer.remove.bind(pointer);\n const has = pointer.has.bind(pointer);\n const props = () => pointer.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"pointer.js"}
|
package/services/raf.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/raf.js"],"names":["Service","getRaf","getCancelRaf","Raf","loop","bind","isTicking","trigger","props","id","raf","cancelRaf","time","window","performance","now","instance","useRaf","add","remove","has"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,uBAArC;;IAsBMC,G;;;;;AAcJ,iBAAc;AAAA;;AAAA;;AACZ;;AADY,gEAZF,KAYE;;AAAA,yDATT,CASS;;AAAA,0DAPRF,MAAM,EAOE;;AAAA,gEALFC,YAAY,EAKV;;AAEZ,UAAKE,IAAL,GAAY,MAAKA,IAAL,CAAUC,IAAV,+BAAZ;AAFY;AAGb;;;;WAOD,gBAAO;AACL,WAAKC,SAAL,GAAiB,IAAjB;AACA,WAAKF,IAAL;AACA,aAAO,IAAP;AACD;;;WAKD,gBAAO;AACL,WAAKG,OAAL,CAAa,KAAKC,KAAlB;;AAEA,UAAI,CAAC,KAAKF,SAAV,EAAqB;AACnB;AACD;;AAED,WAAKG,EAAL,GAAU,KAAKC,GAAL,CAAS,KAAKN,IAAd,CAAV;AACD;;;WAOD,gBAAO;AACL,WAAKO,SAAL,CAAe,KAAKF,EAApB;AACA,WAAKH,SAAL,GAAiB,KAAjB;AACA,aAAO,IAAP;AACD;;;SAQD,eAAY;AACV,aAAO;AACLM,QAAAA,IAAI,EAAEC,MAAM,CAACC,WAAP,CAAmBC,GAAnB;AADD,OAAP;AAGD;;;;EAhEef,O;;AAmElB,IAAIgB,QAAQ,GAAG,IAAf;AAeA,eAAe,SAASC,MAAT,GAAkB;AAC/B,MAAI,CAACD,QAAL,EAAe;AACbA,IAAAA,QAAQ,GAAG,IAAIb,GAAJ,EAAX;AACD;;AAED,MAAMe,GAAG,GAAGF,QAAQ,CAACE,GAAT,CAAab,IAAb,CAAkBW,QAAlB,CAAZ;AACA,MAAMG,MAAM,GAAGH,QAAQ,CAACG,MAAT,CAAgBd,IAAhB,CAAqBW,QAArB,CAAf;AACA,MAAMI,GAAG,GAAGJ,QAAQ,CAACI,GAAT,CAAaf,IAAb,CAAkBW,QAAlB,CAAZ;;AAGA,WAASR,KAAT,GAAiB;AACf,WAAOQ,QAAQ,CAACR,KAAhB;AACD;;AAED,SAAO;AACLU,IAAAA,GAAG,EAAHA,GADK;AAELC,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAILZ,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\nimport { getRaf, getCancelRaf } from '../utils/nextFrame.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} RafServiceProps\n * @property {DOMHighResTimeStamp} time\n */\n\n/**\n * @typedef {Object} RafService\n * @property {(key:String, callback:(props:RafServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => RafServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Tick service\n */\nclass Raf extends Service {\n /** @type {Boolean} Whether the loop is running or not. */\n isTicking = false;\n\n /** @type {number} */\n id = 0;\n\n raf = getRaf();\n\n cancelRaf = getCancelRaf();\n\n /**\n * Bind loop to the instance.\n */\n constructor() {\n super();\n this.loop = this.loop.bind(this);\n }\n\n /**\n * Start the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n init() {\n this.isTicking = true;\n this.loop();\n return this;\n }\n\n /**\n * Loop method.\n */\n loop() {\n this.trigger(this.props);\n\n if (!this.isTicking) {\n return;\n }\n\n this.id = this.raf(this.loop);\n }\n\n /**\n * Stop the requestAnimationFrame loop.\n *\n * @return {Raf}\n */\n kill() {\n this.cancelRaf(this.id);\n this.isTicking = false;\n return this;\n }\n\n /**\n * Get raf props.\n *\n * @todo Return elapsed time / index?\n * @type {Object}\n */\n get props() {\n return {\n time: window.performance.now(),\n };\n }\n}\n\nlet instance = null;\n\n/**\n * Use the RequestAnimationFrame (raf) service.\n *\n * ```js\n * import { useRaf } from '@studiometa/js/services';\n * const { add, remove, props } = useRag();\n * add(id, (props) => {});\n * remove(id);\n * props();\n * ```\n *\n * @return {ServiceInterface & RafService}\n */\nexport default function useRaf() {\n if (!instance) {\n instance = new Raf();\n }\n\n const add = instance.add.bind(instance);\n const remove = instance.remove.bind(instance);\n const has = instance.has.bind(instance);\n\n // eslint-disable-next-line require-jsdoc\n function props() {\n return instance.props;\n }\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"raf.js"}
|
package/services/resize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/resize.js"],"names":["Service","debounce","Resize","handler","trigger","props","bind","window","addEventListener","removeEventListener","width","innerWidth","height","innerHeight","ratio","orientation","breakpointElement","breakpoint","breakpoints","document","querySelector","getComputedStyle","getPropertyValue","replace","split","ResizeObserver","resize","useResize","add","remove","has"],"mappings":";;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,QAAP,MAAqB,sBAArB;;IAmCMC,M;;;;;;;;;;;;;WAMJ,gBAAO;AAAA;;AACL,WAAKC,OAAL,GAAeF,QAAQ,CAAC,YAAM;AAC5B,QAAA,KAAI,CAACG,OAAL,CAAa,KAAI,CAACC,KAAlB;AACD,OAFsB,CAAR,CAEZC,IAFY,CAEP,IAFO,CAAf;AAIAC,MAAAA,MAAM,CAACC,gBAAP,CAAwB,QAAxB,EAAkC,KAAKL,OAAvC;AAEA,aAAO,IAAP;AACD;;;WAOD,gBAAO;AACLI,MAAAA,MAAM,CAACE,mBAAP,CAA2B,QAA3B,EAAqC,KAAKN,OAA1C;AAEA,aAAO,IAAP;AACD;;;SAOD,eAAY;AAEV,UAAME,KAAK,GAAG;A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,IAAAA,MAAM,GAAG,IAAIxB,MAAJ,EAAT;AACD;;AAED,MAAM0B,GAAG,GAAGF,MAAM,CAACE,GAAP,CAAWtB,IAAX,CAAgBoB,MAAhB,CAAZ;AACA,MAAMG,MAAM,GAAGH,MAAM,CAACG,MAAP,CAAcvB,IAAd,CAAmBoB,MAAnB,CAAf;AACA,MAAMI,GAAG,GAAGJ,MAAM,CAACI,GAAP,CAAWxB,IAAX,CAAgBoB,MAAhB,CAAZ;;AACA,MAAMrB,KAAK,GAAG,SAARA,KAAQ;AAAA,WAAMqB,MAAM,CAACrB,KAAb;AAAA,GAAd;;AAEA,SAAO;AACLuB,IAAAA,GAAG,EAAHA,GADK;AAELC,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAILzB,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ResizeServiceProps\n * @property {Number} width\n * @property {Number} height\n * @property {Number} ratio\n * @property {'square'|'landscape'|'portrait'} orientation\n * @property {String} [breakpoint]\n * @property {String[]} [breakpoints]\n */\n\n/**\n * @typedef {Object} ResizeService\n * @property {(key:String, callback:(props:ResizeServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ResizeServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Resize service\n *\n * ```\n * import { useResize } from '@studiometa/js/services';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n */\nclass Resize extends Service {\n /**\n * Bind the handler to the resize event.\n *\n * @return {this}\n */\n init() {\n this.handler = debounce(() => {\n this.trigger(this.props);\n }).bind(this);\n\n window.addEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Unbind the handler from the resize event.\n *\n * @return {this}\n */\n kill() {\n window.removeEventListener('resize', this.handler);\n\n return this;\n }\n\n /**\n * Get resize props.\n *\n * @type {ResizeServiceProps}\n */\n get props() {\n /** @type {ResizeServiceProps} [description] */\n const props = {\n width: window.innerWidth,\n height: window.innerHeight,\n ratio: window.innerWidth / window.innerHeight,\n orientation: 'square',\n };\n\n if (props.ratio > 1) {\n props.orientation = 'landscape';\n }\n\n if (props.ratio < 1) {\n props.orientation = 'portrait';\n }\n\n if (this.breakpointElement) {\n props.breakpoint = this.breakpoint;\n props.breakpoints = this.breakpoints;\n }\n\n return props;\n }\n\n /**\n * The element holding the breakpoints data.\n * @return {HTMLElement}\n */\n get breakpointElement() {\n return document.querySelector('[data-breakpoint]') || null;\n }\n\n /**\n * Get the current breakpoint.\n * @return {String}\n */\n get breakpoint() {\n return window\n .getComputedStyle(this.breakpointElement, '::before')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n }\n\n /**\n * Get all breakpoints.\n * @return {Array}\n */\n get breakpoints() {\n const breakpoints = window\n .getComputedStyle(this.breakpointElement, '::after')\n .getPropertyValue('content')\n .replace(/\"/g, '');\n\n return breakpoints.split(',');\n }\n\n /**\n * Test if we can use the `ResizeObserver` API.\n * @return {Boolean}\n */\n get canUseResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n }\n}\n\nlet resize = null;\n\n/**\n * Use the resize service.\n *\n * ```js\n * import useResize from '@studiometa/js-toolkit/services/resize';\n * const { add, remove, props } = useResize();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n * @return {ServiceInterface & ResizeService}\n */\nexport default function useResize() {\n if (!resize) {\n resize = new Resize();\n }\n\n const add = resize.add.bind(resize);\n const remove = resize.remove.bind(resize);\n const has = resize.has.bind(resize);\n const props = () => resize.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"resize.js"}
|
package/services/scroll.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/js-toolkit/services/scroll.js"],"names":["Service","debounce","Scroll","window","pageYOffset","pageXOffset","document","addEventListener","passive","capture","debounced","trigger","props","Object","defineProperty","value","debouncedHandler","removeEventListener","yLast","y","xLast","x","changed","last","delta","progress","max","direction","scrollingElement","body","scrollWidth","innerWidth","scrollHeight","innerHeight","scroll","useScroll","add","bind","remove","has"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,cAApB;AACA,OAAOC,QAAP,MAAqB,sBAArB;;IA6BMC,M;;;;;;;;;;;;;;;;wDAEAC,MAAM,CAACC,W;;4DAGHD,MAAM,CAACC,W;;wDAGXD,MAAM,CAACE,W;;4DAGHF,MAAM,CAACE,W;;;;;;;WAOf,gBAAO;AACLC,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,QAA1B,EAAoC,IAApC,EAA0C;AAAEC,QAAAA,OAAO,EAAE,IAAX;AAAiBC,QAAAA,OAAO,EAAE;AAA1B,OAA1C;AACA,aAAO,IAAP;AACD;;;SAOD,eAAuB;AAAA;;AACrB,UAAMC,SAAS,GAAGT,QAAQ,CAAC,YAAM;AAC/B,QAAA,MAAI,CAACU,OAAL,CAAa,MAAI,CAACC,KAAlB;AACD,OAFyB,EAEvB,CAFuB,CAA1B;AAKAC,MAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,kBAA5B,EAAgD;AAC9CC,QAAAA,KAAK,EAAEL;AADuC,OAAhD;AAIA,aAAOA,SAAP;AACD;;;WAOD,uBAAc;AACZ,WAAKC,OAAL,CAAa,KAAKC,KAAlB;AAEA,WAAKI,gBAAL;AACD;;;WAOD,gBAAO;AACLV,MAAAA,QAAQ,CAACW,mBAAT,CAA6B,QAA7B,EAAuC,IAAvC;AACA,aAAO,IAAP;AACD;;;SAOD,eAAY;AACV,WAAKC,KAAL,GAAa,KAAKC,CAAlB;AACA,WAAKC,KAAL,GAAa,KAAKC,CAAlB;;AAGA,UAAIlB,MAAM,CAACC,WAAP,KAAuB,KAAKe,CAAhC,EAAmC;AACjC,aAAKA,CAAL,GAAShB,MAAM,CAACC,WAAh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;AAyBLQ,QAAAA,GAAG,EAAE,KAAKA;AAzBL,OAAP;AA2BD;;;SAOD,eAAU;AACR,aAAO;AACLL,QAAAA,CAAC,EAAE,CAACf,QAAQ,CAACsB,gBAAT,IAA6BtB,QAAQ,CAACuB,IAAvC,EAA6CC,WAA7C,GAA2D3B,MAAM,CAAC4B,UADhE;AAELZ,QAAAA,CAAC,EAAE,CAACb,QAAQ,CAACsB,gBAAT,IAA6BtB,QAAQ,CAACuB,IAAvC,EAA6CG,YAA7C,GAA4D7B,MAAM,CAAC8B;AAFjE,OAAP;AAID;;;;EAxHkBjC,O;;AA2HrB,IAAIkC,MAAM,GAAG,IAAb;AAeA,eAAe,SAASC,SAAT,GAAqB;AAClC,MAAI,CAACD,MAAL,EAAa;AACXA,IAAAA,MAAM,GAAG,IAAIhC,MAAJ,EAAT;AACD;;AAED,MAAMkC,GAAG,GAAGF,MAAM,CAACE,GAAP,CAAWC,IAAX,CAAgBH,MAAhB,CAAZ;AACA,MAAMI,MAAM,GAAGJ,MAAM,CAACI,MAAP,CAAcD,IAAd,CAAmBH,MAAnB,CAAf;AACA,MAAMK,GAAG,GAAGL,MAAM,CAACK,GAAP,CAAWF,IAAX,CAAgBH,MAAhB,CAAZ;;AACA,MAAMtB,KAAK,GAAG,SAARA,KAAQ;AAAA,WAAMsB,MAAM,CAACtB,KAAb;AAAA,GAAd;;AAEA,SAAO;AACLwB,IAAAA,GAAG,EAAHA,GADK;AAELE,IAAAA,MAAM,EAANA,MAFK;AAGLC,IAAAA,GAAG,EAAHA,GAHK;AAIL3B,IAAAA,KAAK,EAALA;AAJK,GAAP;AAMD","sourcesContent":["import Service from './Service.js';\nimport debounce from '../utils/debounce.js';\n\n/**\n * @typedef {import('./index').ServiceInterface} ServiceInterface\n */\n\n/**\n * @typedef {Object} ScrollServiceProps\n * @property {Number} x\n * @property {Number} y\n * @property {{ x: Boolean, y: Boolean }} changed\n * @property {{ x: Number, y: Number }} last\n * @property {{ x: Number, y: Number }} delta\n * @property {{ x: Number, y: Number }} progress\n * @property {{ x: Number, y: Number }} max\n * @property {{ x: 'LEFT'|'RIGHT'|'NONE', y: 'UP'|'DOWN'|'NONE' }} direction\n */\n\n/**\n * @typedef {Object} ScrollService\n * @property {(key:String, callback:(props:ScrollServiceProps) => void) => void} add\n * Add a function to the resize service. The key must be uniq.\n * @property {() => ScrollServiceProps} props\n * Get the current values of the resize service props.\n */\n\n/**\n * Scroll service\n */\nclass Scroll extends Service {\n /** @type {Number} The y scroll position. */\n y = window.pageYOffset;\n\n /** @type {Number} The y previous scroll position. */\n yLast = window.pageYOffset;\n\n /** @type {Number} The x scroll position. */\n x = window.pageXOffset;\n\n /** @type {Number} The x previous scroll position. */\n xLast = window.pageXOffset;\n\n /**\n * Bind the handler to the scroll event.\n *\n * @return {Scroll}\n */\n init() {\n document.addEventListener('scroll', this, { passive: true, capture: true });\n return this;\n }\n\n /**\n * Debounced handler.\n *\n * @return {() => void}\n */\n get debouncedHandler() {\n const debounced = debounce(() => {\n this.trigger(this.props);\n }, 0);\n\n // Define property to avoid multiple call to the getter\n Object.defineProperty(this, 'debouncedHandler', {\n value: debounced,\n });\n\n return debounced;\n }\n\n /**\n * Scroll event handler.\n *\n * @return {void}\n */\n handleEvent() {\n this.trigger(this.props);\n\n this.debouncedHandler();\n }\n\n /**\n * Unbind the handler from the scroll event.\n *\n * @return {Scroll}\n */\n kill() {\n document.removeEventListener('scroll', this);\n return this;\n }\n\n /**\n * Get scroll props.\n *\n * @type {Object}\n */\n get props() {\n this.yLast = this.y;\n this.xLast = this.x;\n\n // Check scroll Y\n if (window.pageYOffset !== this.y) {\n this.y = window.pageYOffset;\n }\n\n // Check scroll x\n if (window.pageXOffset !== this.x) {\n this.x = window.pageXOffset;\n }\n\n return {\n x: this.x,\n y: this.y,\n changed: {\n x: this.x !== this.xLast,\n y: this.y !== this.yLast,\n },\n last: {\n x: this.xLast,\n y: this.yLast,\n },\n delta: {\n x: this.x - this.xLast,\n y: this.y - this.yLast,\n },\n progress: {\n x: this.max.x === 0 ? 1 : this.x / this.max.x,\n y: this.max.y === 0 ? 1 : this.y / this.max.y,\n },\n direction: {\n /* eslint-disable no-nested-ternary */\n x: this.x > this.xLast ? 'RIGHT' : this.x < this.xLast ? 'LEFT' : 'NONE',\n y: this.y > this.yLast ? 'DOWN' : this.y < this.yLast ? 'UP' : 'NONE',\n /* eslint-enable no-nested-ternary */\n },\n max: this.max,\n };\n }\n\n /**\n * Get scroll max values.\n *\n * @type {Object}\n */\n get max() {\n return {\n x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,\n y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight,\n };\n }\n}\n\nlet scroll = null;\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n *\n * @return {ServiceInterface & ScrollService}\n */\nexport default function useScroll() {\n if (!scroll) {\n scroll = new Scroll();\n }\n\n const add = scroll.add.bind(scroll);\n const remove = scroll.remove.bind(scroll);\n const has = scroll.has.bind(scroll);\n const props = () => scroll.props;\n\n return {\n add,\n remove,\n has,\n props,\n };\n}\n"],"file":"scroll.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/boundingRectToCircle.js"],"names":["collidePointRect","x","y","width","height","force","Error","radius"],"mappings":"AAcA,eAAe,SAASA,gBAAT,OAAkE;AAAA,MAAtCC,CAAsC,QAAtCA,CAAsC;AAAA,MAAnCC,CAAmC,QAAnCA,CAAmC;AAAA,MAAhCC,KAAgC,QAAhCA,KAAgC;AAAA,MAAzBC,MAAyB,QAAzBA,MAAyB;AAAA,MAAfC,KAAe,uEAAP,KAAO;AAC/E,MAAIF,KAAK,KAAKC,MAAV,IAAoB,CAACC,KAAzB,EACE,MAAM,IAAIC,KAAJ,CAAU,gEAAV,CAAN;AACF,SAAO;AACLL,IAAAA,CAAC,EAAEA,CAAC,GAAGE,KAAK,GAAG,CADV;AAELD,IAAAA,CAAC,EAAEA,CAAC,GAAGE,MAAM,GAAG,CAFX;AAGLG,IAAAA,MAAM,EAAE,CAACJ,KAAK,GAAGC,MAAT,IAAmB;AAHtB,GAAP;AAKD","sourcesContent":["/**\n * @typedef {Object} Circle\n * @property {Number} x Circle's x position\n * @property {Number} y Circle's y position\n * @property {Number} radius Circle's radius\n */\n\n/**\n * Convert clientRect to a formatted circle object\n *\n * @param {Partial<DOMRect>} domRect DOMRect of a square DOMElement\n * @param {Boolean} force Force usage of non-square DOMElements\n * @return {Circle} Circle object that can be used in collides functions\n */\nexport default function collidePointRect({ x, y, width, height }, force = false) {\n if (width !== height && !force)\n throw new Error('Initial DOMElement is not a square. Please use the force mode.');\n return {\n x: x + width / 2,\n y: y + height / 2,\n radius: (width + height) / 4,\n };\n}\n"],"file":"boundingRectToCircle.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/collideCircleCircle.js"],"names":["collideCircleCircle","circle1","circle2","distX","x","distY","y","distance","Math","sqrt","radius"],"mappings":"AAeA,eAAe,SAASA,mBAAT,CAA6BC,OAA7B,EAAsCC,OAAtC,EAA+C;AAG5D,MAAMC,KAAK,GAAGF,OAAO,CAACG,CAAR,GAAYF,OAAO,CAACE,CAAlC;AACA,MAAMC,KAAK,GAAGJ,OAAO,CAACK,CAAR,GAAYJ,OAAO,CAACI,CAAlC;AACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,IAAL,CAAUN,KAAK,GAAGA,KAAR,GAAgBE,KAAK,GAAGA,KAAlC,CAAjB;;AAIA,MAAIE,QAAQ,IAAIN,OAAO,CAACS,MAAR,GAAiBR,OAAO,CAACQ,MAAzC,EAAiD;AAC/C,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD","sourcesContent":["/**\n * @typedef {Object} Circle\n * @property {Number} x Circle's x position\n * @property {Number} y Circle's y position\n * @property {Number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with another.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-circle.php\n *\n * @param {Circle} circle1 Circle 1\n * @param {Circle} circle2 Circle 2\n * @return {boolean} Are the sides of one circle touching the other ?\n */\nexport default function collideCircleCircle(circle1, circle2) {\n // get distance between the circle's centers\n // use the Pythagorean Theorem to compute the distance\n const distX = circle1.x - circle2.x;\n const distY = circle1.y - circle2.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the sum of the circle's\n // radii, the circles are touching!\n if (distance <= circle1.radius + circle2.radius) {\n return true;\n }\n return false;\n}\n"],"file":"collideCircleCircle.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/collideCircleRect.js"],"names":["collideCircleRect","circle","rect","testX","x","testY","y","width","height","distX","distY","distance","Math","sqrt","radius"],"mappings":"AAuBA,eAAe,SAASA,iBAAT,CAA2BC,MAA3B,EAAmCC,IAAnC,EAAyC;AAEtD,MAAIC,KAAK,GAAGF,MAAM,CAACG,CAAnB;AACA,MAAIC,KAAK,GAAGJ,MAAM,CAACK,CAAnB;;AAGA,MAAIL,MAAM,CAACG,CAAP,GAAWF,IAAI,CAACE,CAApB,EAAuB;AACrBD,IAAAA,KAAK,GAAGD,IAAI,CAACE,CAAb;AACD,GAFD,MAEO,IAAIH,MAAM,CAACG,CAAP,GAAWF,IAAI,CAACE,CAAL,GAASF,IAAI,CAACK,KAA7B,EAAoC;AACzCJ,IAAAA,KAAK,GAAGD,IAAI,CAACE,CAAL,GAASF,IAAI,CAACK,KAAtB;AACD;;AAED,MAAIN,MAAM,CAACK,CAAP,GAAWJ,IAAI,CAACI,CAApB,EAAuB;AACrBD,IAAAA,KAAK,GAAGH,IAAI,CAACI,CAAb;AACD,GAFD,MAEO,IAAIL,MAAM,CAACK,CAAP,GAAWJ,IAAI,CAACI,CAAL,GAASJ,IAAI,CAACM,MAA7B,EAAqC;AAC1CH,IAAAA,KAAK,GAAGH,IAAI,CAACI,CAAL,GAASJ,IAAI,CAACM,MAAtB;AACD;;AAGD,MAAMC,KAAK,GAAGR,MAAM,CAACG,CAAP,GAAWD,KAAzB;AACA,MAAMO,KAAK,GAAGT,MAAM,CAACK,CAAP,GAAWD,KAAzB;AACA,MAAMM,QAAQ,GAAGC,IAAI,CAACC,IAAL,CAAUJ,KAAK,GAAGA,KAAR,GAAgBC,KAAK,GAAGA,KAAlC,CAAjB;;AAGA,MAAIC,QAAQ,IAAIV,MAAM,CAACa,MAAvB,EAA+B;AAC7B,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD","sourcesContent":["/**\n * @typedef {Object} Rect\n * @property {Number} x Rectangle's x position\n * @property {Number} y Rectangle's y position\n * @property {Number} width Rectangle's width\n * @property {Number} height Rectangle's height\n */\n\n/**\n * @typedef {Object} Circle\n * @property {Number} x Circle's x position\n * @property {Number} y Circle's y position\n * @property {Number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-rect.php\n *\n * @param {Circle} circle Circle\n * @param {Rect} rect Rectangle\n * @return {boolean} Are the sides of the circle touching the rectangle ?\n */\nexport default function collideCircleRect(circle, rect) {\n // temporary variables to set edges for testing\n let testX = circle.x;\n let testY = circle.y;\n\n // which edge is closest?\n if (circle.x < rect.x) {\n testX = rect.x; // test left edge\n } else if (circle.x > rect.x + rect.width) {\n testX = rect.x + rect.width; // right edge\n }\n\n if (circle.y < rect.y) {\n testY = rect.y; // top edge\n } else if (circle.y > rect.y + rect.height) {\n testY = rect.y + rect.height; // bottom edge\n }\n\n // get distance from closest edges\n const distX = circle.x - testX;\n const distY = circle.y - testY;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the radius, collision!\n if (distance <= circle.radius) {\n return true;\n }\n return false;\n}\n"],"file":"collideCircleRect.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/collidePointCircle.js"],"names":["collidePointCircle","point","circle","distX","x","distY","y","distance","Math","sqrt","radius"],"mappings":"AAqBA,eAAe,SAASA,kBAAT,CAA4BC,KAA5B,EAAmCC,MAAnC,EAA2C;AAGxD,MAAMC,KAAK,GAAGF,KAAK,CAACG,CAAN,GAAUF,MAAM,CAACE,CAA/B;AACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,CAAN,GAAUJ,MAAM,CAACI,CAA/B;AACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,IAAL,CAAUN,KAAK,GAAGA,KAAR,GAAgBE,KAAK,GAAGA,KAAlC,CAAjB;AAIA,SAAOE,QAAQ,IAAIL,MAAM,CAACQ,MAA1B;AACD","sourcesContent":["/**\n * @typedef {Object} Point\n * @property {Number} x Point's x position\n * @property {Number} y Point's y position\n */\n\n/**\n * @typedef {Object} Circle\n * @property {Number} x Circle's x position\n * @property {Number} y Circle's y position\n * @property {Number} radius Circle's radius\n */\n\n/**\n * Test if a point is inside a circle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-circle.php\n *\n * @param {Point} point Point\n * @param {Circle} circle Circle\n * @return {boolean} Is the point inside the circle's bounds ?\n */\nexport default function collidePointCircle(point, circle) {\n // get distance between the point and circle's center\n // using the Pythagorean Theorem\n const distX = point.x - circle.x;\n const distY = point.y - circle.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the circle's\n // radius the point is inside!\n return distance <= circle.radius;\n}\n"],"file":"collidePointCircle.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/collidePointRect.js"],"names":["collidePointRect","point","rect","x","width","y","height"],"mappings":"AAsBA,eAAe,SAASA,gBAAT,CAA0BC,KAA1B,EAAiCC,IAAjC,EAAuC;AACpD,SACED,KAAK,CAACE,CAAN,IAAWD,IAAI,CAACC,CAAhB,IACAF,KAAK,CAACE,CAAN,IAAWD,IAAI,CAACC,CAAL,GAASD,IAAI,CAACE,KADzB,IAEAH,KAAK,CAACI,CAAN,IAAWH,IAAI,CAACG,CAFhB,IAGAJ,KAAK,CAACI,CAAN,IAAWH,IAAI,CAACG,CAAL,GAASH,IAAI,CAACI,MAJ3B;AAMD","sourcesContent":["/**\n * @typedef {Object} Point\n * @property {Number} x Point's x position\n * @property {Number} y Point's y position\n */\n\n/**\n * @typedef {Object} Rect\n * @property {Number} x Rectangle's x position\n * @property {Number} y Rectangle's y position\n * @property {Number} width Rectangle's width\n * @property {Number} height Rectangle's height\n */\n\n/**\n * Test if a point collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-rect.php\n *\n * @param {Point} point Point\n * @param {Rect} rect Rectangle\n * @return {boolean} Is the point inside the rectangle's bounds ?\n */\nexport default function collidePointRect(point, rect) {\n return (\n point.x >= rect.x && // right of the left edge AND\n point.x <= rect.x + rect.width && // left of the right edge AND\n point.y >= rect.y && // below the top AND\n point.y <= rect.y + rect.height // above the bottom\n );\n}\n"],"file":"collidePointRect.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/collideRectRect.js"],"names":["collideRectRect","rect1","rect2","x","width","y","height"],"mappings":"AAgBA,eAAe,SAASA,eAAT,CAAyBC,KAAzB,EAAgCC,KAAhC,EAAuC;AACpD,SACED,KAAK,CAACE,CAAN,GAAUF,KAAK,CAACG,KAAhB,IAAyBF,KAAK,CAACC,CAA/B,IACAF,KAAK,CAACE,CAAN,IAAWD,KAAK,CAACC,CAAN,GAAUD,KAAK,CAACE,KAD3B,IAEAH,KAAK,CAACI,CAAN,GAAUJ,KAAK,CAACK,MAAhB,IAA0BJ,KAAK,CAACG,CAFhC,IAGAJ,KAAK,CAACI,CAAN,IAAWH,KAAK,CAACG,CAAN,GAAUH,KAAK,CAACI,MAJ7B;AAMD","sourcesContent":["/**\n * @typedef {Object} Rect\n * @property {Number} x Rectangle's x position\n * @property {Number} y Rectangle's y position\n * @property {Number} width Rectangle's width\n * @property {Number} height Rectangle's height\n */\n\n/**\n * Test if a rectangle collides with another rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/rect-rect.php\n *\n * @param {Rect} rect1 Rectangle 1\n * @param {Rect} rect2 Rectangle 2\n * @return {boolean} Are the sides of one rectangle touching the other ?\n */\nexport default function collideRectRect(rect1, rect2) {\n return (\n rect1.x + rect1.width >= rect2.x && // rect1 right edge past rect2 left AND\n rect1.x <= rect2.x + rect2.width && // rect1 left edge past rect2 right AND\n rect1.y + rect1.height >= rect2.y && // rect1 top edge past rect2 bottom AND\n rect1.y <= rect2.y + rect2.height // rect1 bottom edge past rect2 top\n );\n}\n"],"file":"collideRectRect.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/collide/index.js"],"names":["collidePointRect","collideRectRect","boundingRectToCircle","collideCircleRect","collideCircleCircle","collidePointCircle"],"mappings":"AAGA,OAAOA,gBAAP,MAA6B,uBAA7B;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,SACEL,gBADF,EAEEC,eAFF,EAGEC,oBAHF,EAIEC,iBAJF,EAKEC,mBALF,EAMEC,kBANF","sourcesContent":["/**\n * Inspired by http://www.jeffreythompson.org/collision-detection/\n */\nimport collidePointRect from './collidePointRect.js';\nimport collideRectRect from './collideRectRect.js';\nimport boundingRectToCircle from './boundingRectToCircle.js';\nimport collideCircleRect from './collideCircleRect.js';\nimport collideCircleCircle from './collideCircleCircle.js';\nimport collidePointCircle from './collidePointCircle.js';\n\nexport {\n collidePointRect,\n collideRectRect,\n boundingRectToCircle,\n collideCircleRect,\n collideCircleCircle,\n collidePointCircle,\n};\n"],"file":"index.js"}
|
package/utils/css/classes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/css/classes.js"],"names":["setClasses","element","classNames","method","split","forEach","className","classList","add","remove","toggle"],"mappings":"AAOA,SAASA,UAAT,CAAoBC,OAApB,EAA6BC,UAA7B,EAAyD;AAAA,MAAhBC,MAAgB,uEAAP,KAAO;;AACvD,MAAI,CAACF,OAAD,IAAY,CAACC,UAAjB,EAA6B;AAC3B;AACD;;AAEDA,EAAAA,UAAU,CAACE,KAAX,CAAiB,GAAjB,EAAsBC,OAAtB,CAA8B,UAACC,SAAD,EAAe;AAC3CL,IAAAA,OAAO,CAACM,SAAR,CAAkBJ,MAAlB,EAA0BG,SAA1B;AACD,GAFD;AAGD;;AASD,OAAO,SAASE,GAAT,CAAaP,OAAb,EAAsBC,UAAtB,EAAkC;AACvCF,EAAAA,UAAU,CAACC,OAAD,EAAUC,UAAV,CAAV;AACD;AASD,OAAO,SAASO,MAAT,CAAgBR,OAAhB,EAAyBC,UAAzB,EAAqC;AAC1CF,EAAAA,UAAU,CAACC,OAAD,EAAUC,UAAV,EAAsB,QAAtB,CAAV;AACD;AASD,OAAO,SAASQ,MAAT,CAAgBT,OAAhB,EAAyBC,UAAzB,EAAqC;AAC1CF,EAAAA,UAAU,CAACC,OAAD,EAAUC,UAAV,EAAsB,QAAtB,CAAV;AACD","sourcesContent":["/**\n * Manage a list of classes as string on an element.\n *\n * @param {HTMLElement} element The element to update.\n * @param {String} classNames A string of class names.\n * @param {String=} [method='add'] The method to use: add, remove or toggle.\n */\nfunction setClasses(element, classNames, method = 'add') {\n if (!element || !classNames) {\n return;\n }\n\n classNames.split(' ').forEach((className) => {\n element.classList[method](className);\n });\n}\n\n/**\n * Add class names to an element.\n *\n * @param {HTMLElement} element The element to update.\n * @param {String} classNames A string of class names.\n * @return {void}\n */\nexport function add(element, classNames) {\n setClasses(element, classNames);\n}\n\n/**\n * Remove class names from an element.\n *\n * @param {HTMLElement} element The element to update.\n * @param {String} classNames A string of class names.\n * @return {void}\n */\nexport function remove(element, classNames) {\n setClasses(element, classNames, 'remove');\n}\n\n/**\n * Toggle class names from an element.\n *\n * @param {HTMLElement} element The element to update.\n * @param {String} classNames A string of class names.\n * @return {void}\n */\nexport function toggle(element, classNames) {\n setClasses(element, classNames, 'toggle');\n}\n"],"file":"classes.js"}
|
package/utils/css/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/css/index.js"],"names":["classes","styles","matrix","transition"],"mappings":"AAAA,OAAO,KAAKA,OAAZ,MAAyB,cAAzB;AACA,OAAO,KAAKC,MAAZ,MAAwB,aAAxB;AACA,OAAOC,MAAP,MAAmB,aAAnB;AACA,OAAOC,UAAP,MAAuB,iBAAvB;AAEA,SAASH,OAAT,EAAkBC,MAAlB,EAA0BC,MAA1B,EAAkCC,UAAlC","sourcesContent":["import * as classes from './classes.js';\nimport * as styles from './styles.js';\nimport matrix from './matrix.js';\nimport transition from './transition.js';\n\nexport { classes, styles, matrix, transition };\n"],"file":"index.js"}
|
package/utils/css/matrix.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/js-toolkit/utils/css/matrix.js"],"names":["matrix","transform","scaleX","skewY","skewX","scaleY","translateX","translateY"],"mappings":"AAkBA,eAAe,SAASA,MAAT,CAAgBC,SAAhB,EAA2B;AAAA;;AAExCA,EAAAA,SAAS,GAAGA,SAAS,IAAI,EAAzB;AACA,+CAAiBA,SAAS,CAACC,MAA3B,iEAAqC,CAArC,mCAA2CD,SAAS,CAACE,KAArD,+DAA8D,CAA9D,mCAAoEF,SAAS,CAACG,KAA9E,+DAAuF,CAAvF,oCACEH,SAAS,CAACI,MADZ,iEACsB,CADtB,wCAEKJ,SAAS,CAACK,UAFf,yEAE6B,CAF7B,wCAEmCL,SAAS,CAACM,UAF7C,yEAE2D,CAF3D;AAGD","sourcesContent":["/**\n * Format a CSS transform matrix with the given values.\n *\n * @param {Object} transform\n * @param {Number=} [transform.scaleX=1] The scale on the x axis.\n * @param {Number=} [transform.scaleY=1] The scale on the y axis.\n * @param {Number=} [transform.skewX=0] The skew on the x axis.\n * @param {Number=} [transform.skewY=0] The skew on the y axis.\n * @param {Number=} [transform.translateX=0] The translate on the x axis.\n * @param {Number=} [transform.translateY=0] The translate on the y axis.\n * @return {String} A formatted CSS matrix transform.\n *\n * @example\n * ```js\n * matrix({ scaleX: 0.5, scaleY: 0.5 });\n * // matrix(0.5, 0, 0, 0.5, 0, 0)\n * ```\n */\nexport default function matrix(transform) {\n // eslint-disable-next-line no-param-reassign\n transform = transform || {};\n return `matrix(${transform.scaleX ?? 1}, ${transform.skewY ?? 0}, ${transform.skewX ?? 0}, ${\n transform.scaleY ?? 1\n }, ${transform.translateX ?? 0}, ${transform.translateY ?? 0})`;\n}\n"],"file":"matrix.js"}
|