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

21
node_modules/riot/esm/api/__.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
/* Riot WIP, @license MIT */
import { template, createBinding, createExpression, bindingTypes, expressionTypes } from '@riotjs/dom-bindings';
import { DOM_COMPONENT_INSTANCE_PROPERTY, PARENT_KEY_SYMBOL } from '@riotjs/util';
import cssManager from '../core/css-manager.js';
const __ = {
cssManager,
DOMBindings: {
template,
createBinding,
createExpression,
bindingTypes,
expressionTypes
},
globals: {
DOM_COMPONENT_INSTANCE_PROPERTY,
PARENT_KEY_SYMBOL
}
};
export { __ };

26
node_modules/riot/esm/api/component.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* Riot WIP, @license MIT */
import compose from 'cumpa';
import { createComponentFromWrapper } from '../core/create-component-from-wrapper.js';
/**
* Helper method to create component without relying on the registered ones
* @param {Object} implementation - component implementation
* @returns {Function} function that will allow you to mount a riot component on a DOM node
*/
function component(implementation) {
return function (el, props, _temp) {
let {
slots,
attributes,
parentScope
} = _temp === void 0 ? {} : _temp;
return compose(c => c.mount(el, parentScope), c => c({
props,
slots,
attributes
}), createComponentFromWrapper)(implementation);
};
}
export { component };

17
node_modules/riot/esm/api/install.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/* Riot WIP, @license MIT */
import { isFunction, panic, PLUGINS_SET } from '@riotjs/util';
/**
* Define a riot plugin
* @param {Function} plugin - function that will receive all the components created
* @returns {Set} the set containing all the plugins installed
*/
function install(plugin) {
if (!isFunction(plugin)) panic('Plugins must be of type function');
if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
PLUGINS_SET.add(plugin);
return PLUGINS_SET;
}
export { install };

17
node_modules/riot/esm/api/mount.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/* Riot WIP, @license MIT */
import $ from 'bianco.query';
import { mountComponent } from '../core/mount-component.js';
/**
* Mounting function that will work only for the components that were globally registered
* @param {string|HTMLElement} selector - query for the selection or a DOM element
* @param {Object} initialProps - the initial component properties
* @param {string} name - optional component name
* @returns {Array} list of riot components
*/
function mount(selector, initialProps, name) {
return $(selector).map(element => mountComponent(element, initialProps, name));
}
export { mount };

16
node_modules/riot/esm/api/pure.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/* Riot WIP, @license MIT */
import { isFunction, panic, IS_PURE_SYMBOL } from '@riotjs/util';
/**
* Lift a riot component Interface into a pure riot object
* @param {Function} func - RiotPureComponent factory function
* @returns {Function} the lifted original function received as argument
*/
function pure(func) {
if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
func[IS_PURE_SYMBOL] = true;
return func;
}
export { pure };

28
node_modules/riot/esm/api/register.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* Riot WIP, @license MIT */
import { COMPONENTS_IMPLEMENTATION_MAP, panic } from '@riotjs/util';
import { createComponentFromWrapper } from '../core/create-component-from-wrapper.js';
/**
* Register a custom tag by name
* @param {string} name - component name
* @param {Object} implementation - tag implementation
* @returns {Map} map containing all the components implementations
*/
function register(name, _ref) {
let {
css,
template,
exports
} = _ref;
if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponentFromWrapper({
name,
css,
template,
exports
}));
return COMPONENTS_IMPLEMENTATION_MAP;
}
export { register };

16
node_modules/riot/esm/api/uninstall.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/* Riot WIP, @license MIT */
import { PLUGINS_SET, panic } from '@riotjs/util';
/**
* Uninstall a riot plugin
* @param {Function} plugin - plugin previously installed
* @returns {Set} the set containing all the plugins installed
*/
function uninstall(plugin) {
if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
PLUGINS_SET.delete(plugin);
return PLUGINS_SET;
}
export { uninstall };

22
node_modules/riot/esm/api/unmount.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/* Riot WIP, @license MIT */
import $ from 'bianco.query';
import { DOM_COMPONENT_INSTANCE_PROPERTY } from '@riotjs/util';
/**
* Sweet unmounting helper function for the DOM node mounted manually by the user
* @param {string|HTMLElement} selector - query for the selection or a DOM element
* @param {boolean|null} keepRootElement - if true keep the root element
* @returns {Array} list of nodes unmounted
*/
function unmount(selector, keepRootElement) {
return $(selector).map(element => {
if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
}
return element;
});
}
export { unmount };

18
node_modules/riot/esm/api/unregister.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/* Riot WIP, @license MIT */
import { COMPONENTS_IMPLEMENTATION_MAP, panic } from '@riotjs/util';
import cssManager from '../core/css-manager.js';
/**
* Unregister a riot web component
* @param {string} name - component name
* @returns {Map} map containing all the components implementations
*/
function unregister(name) {
if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
COMPONENTS_IMPLEMENTATION_MAP.delete(name);
cssManager.remove(name);
return COMPONENTS_IMPLEMENTATION_MAP;
}
export { unregister };

5
node_modules/riot/esm/api/version.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/* Riot WIP, @license MIT */
/** @type {string} current riot version */
const version = 'WIP';
export { version };

11
node_modules/riot/esm/api/with-types.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/* Riot WIP, @license MIT */
/**
* no-op function needed to add the proper types to your component via typescript
* @param {Function|Object} component - component default export
* @returns {Function|Object} returns exactly what it has received
*/
/* istanbul ignore next */
const withTypes = component => component;
export { withTypes };

19
node_modules/riot/esm/core/add-css-hook.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/* Riot WIP, @license MIT */
import { IS_DIRECTIVE } from '@riotjs/util';
import { getName } from '../utils/dom.js';
import { set } from 'bianco.attr';
/**
* Add eventually the "is" attribute to link this DOM node to its css
* @param {HTMLElement} element - target root node
* @param {string} name - name of the component mounted
* @returns {undefined} it's a void function
*/
function addCssHook(element, name) {
if (getName(element) !== name) {
set(element, IS_DIRECTIVE, name);
}
}
export { addCssHook };

View File

@@ -0,0 +1,13 @@
/* Riot WIP, @license MIT */
import { DOM_COMPONENT_INSTANCE_PROPERTY } from '@riotjs/util';
/**
* Bind a DOM node to its component object
* @param {HTMLElement} node - html node mounted
* @param {Object} component - Riot.js component object
* @returns {Object} the component object received as second argument
*/
const bindDOMNodeToComponentInstance = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY] = component;
export { bindDOMNodeToComponentInstance };

16
node_modules/riot/esm/core/component-dom-selectors.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/* Riot WIP, @license MIT */
import $ from 'bianco.query';
const COMPONENT_DOM_SELECTORS = Object.freeze({
// component helpers
$(selector) {
return $(selector, this.root)[0];
},
$$(selector) {
return $(selector, this.root);
}
});
export { COMPONENT_DOM_SELECTORS };

View File

@@ -0,0 +1,14 @@
/* Riot WIP, @license MIT */
import { SHOULD_UPDATE_KEY, noop, ON_BEFORE_MOUNT_KEY, ON_MOUNTED_KEY, ON_BEFORE_UPDATE_KEY, ON_UPDATED_KEY, ON_BEFORE_UNMOUNT_KEY, ON_UNMOUNTED_KEY } from '@riotjs/util';
const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
[SHOULD_UPDATE_KEY]: noop,
[ON_BEFORE_MOUNT_KEY]: noop,
[ON_MOUNTED_KEY]: noop,
[ON_BEFORE_UPDATE_KEY]: noop,
[ON_UPDATED_KEY]: noop,
[ON_BEFORE_UNMOUNT_KEY]: noop,
[ON_UNMOUNTED_KEY]: noop
});
export { COMPONENT_LIFECYCLE_METHODS };

View File

@@ -0,0 +1,24 @@
/* Riot WIP, @license MIT */
import { template, expressionTypes, bindingTypes } from '@riotjs/dom-bindings';
import { COMPONENTS_IMPLEMENTATION_MAP } from '@riotjs/util';
import { createChildrenComponentsObject } from './create-children-components-object.js';
import { memoizedCreateComponentFromWrapper } from './create-component-from-wrapper.js';
/**
* Factory function to create the component templates only once
* @param {Function} template - component template creation function
* @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
* @returns {TemplateChunk} template chunk object
*/
function componentTemplateFactory(template$1, componentWrapper) {
const components = createChildrenComponentsObject(componentWrapper.exports ? componentWrapper.exports.components : {});
return template$1(template, expressionTypes, bindingTypes, name => {
// improve support for recursive components
if (name === componentWrapper.name) return memoizedCreateComponentFromWrapper(componentWrapper); // return the registered components
return components[name] || COMPONENTS_IMPLEMENTATION_MAP.get(name);
});
}
export { componentTemplateFactory };

15
node_modules/riot/esm/core/compute-component-state.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
/* Riot WIP, @license MIT */
import { callOrAssign } from '@riotjs/util';
/**
* Compute the component current state merging it with its previous state
* @param {Object} oldState - previous state object
* @param {Object} newState - new state given to the `update` call
* @returns {Object} new object state
*/
function computeComponentState(oldState, newState) {
return Object.assign({}, oldState, callOrAssign(newState));
}
export { computeComponentState };

19
node_modules/riot/esm/core/compute-initial-props.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/* Riot WIP, @license MIT */
import { DOMattributesToObject, callOrAssign } from '@riotjs/util';
/**
* Evaluate the component properties either from its real attributes or from its initial user properties
* @param {HTMLElement} element - component root
* @param {Object} initialProps - initial props
* @returns {Object} component props key value pairs
*/
function computeInitialProps(element, initialProps) {
if (initialProps === void 0) {
initialProps = {};
}
return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
}
export { computeInitialProps };

View File

@@ -0,0 +1,27 @@
/* Riot WIP, @license MIT */
import { createCoreAPIMethods } from './create-core-api-methods.js';
import { createExpression } from '@riotjs/dom-bindings';
/**
* Create the bindings to update the component attributes
* @param {HTMLElement} node - node where we will bind the expressions
* @param {Array} attributes - list of attribute bindings
* @returns {TemplateChunk} - template bindings object
*/
function createAttributeBindings(node, attributes) {
if (attributes === void 0) {
attributes = [];
}
const expressions = attributes.map(a => createExpression(node, a));
const binding = {};
return Object.assign(binding, Object.assign({
expressions
}, createCoreAPIMethods(method => scope => {
expressions.forEach(e => e[method](scope));
return binding;
})));
}
export { createAttributeBindings };

View File

@@ -0,0 +1,23 @@
/* Riot WIP, @license MIT */
import { callOrAssign, camelToDashCase } from '@riotjs/util';
import { createComponentFromWrapper } from './create-component-from-wrapper.js';
/**
* Create the subcomponents that can be included inside a tag in runtime
* @param {Object} components - components imported in runtime
* @returns {Object} all the components transformed into Riot.Component factory functions
*/
function createChildrenComponentsObject(components) {
if (components === void 0) {
components = {};
}
return Object.entries(callOrAssign(components)).reduce((acc, _ref) => {
let [key, value] = _ref;
acc[camelToDashCase(key)] = createComponentFromWrapper(value);
return acc;
}, {});
}
export { createChildrenComponentsObject };

View File

@@ -0,0 +1,79 @@
/* Riot WIP, @license MIT */
import { IS_PURE_SYMBOL, callOrAssign, memoize } from '@riotjs/util';
import { MOCKED_TEMPLATE_INTERFACE } from './mocked-template-interface.js';
import { componentTemplateFactory } from './component-template-factory.js';
import { createPureComponent } from './create-pure-component.js';
import { instantiateComponent } from './instantiate-component.js';
/**
* Create the component interface needed for the @riotjs/dom-bindings tag bindings
* @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
* @param {string} componentWrapper.css - component css
* @param {Function} componentWrapper.template - function that will return the dom-bindings template function
* @param {Object} componentWrapper.exports - component interface
* @param {string} componentWrapper.name - component name
* @returns {Object} component like interface
*/
function createComponentFromWrapper(componentWrapper) {
const {
css,
template,
exports,
name
} = componentWrapper;
const templateFn = template ? componentTemplateFactory(template, componentWrapper) : MOCKED_TEMPLATE_INTERFACE;
return _ref => {
let {
slots,
attributes,
props
} = _ref;
// pure components rendering will be managed by the end user
if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
slots,
attributes,
props,
css,
template
});
const componentAPI = callOrAssign(exports) || {};
const component = instantiateComponent({
css,
template: templateFn,
componentAPI,
name
})({
slots,
attributes,
props
}); // notice that for the components created via tag binding
// we need to invert the mount (state/parentScope) arguments
// the template bindings will only forward the parentScope updates
// and never deal with the component state
return {
mount(element, parentScope, state) {
return component.mount(element, state, parentScope);
},
update(parentScope, state) {
return component.update(state, parentScope);
},
unmount(preserveRoot) {
return component.unmount(preserveRoot);
}
};
};
}
/**
* Performance optimization for the recursive components
* @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
* @returns {Object} component like interface
*/
const memoizedCreateComponentFromWrapper = memoize(createComponentFromWrapper);
export { createComponentFromWrapper, memoizedCreateComponentFromWrapper };

17
node_modules/riot/esm/core/create-core-api-methods.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/* Riot WIP, @license MIT */
import { MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY } from '@riotjs/util';
/**
* Wrap the Riot.js core API methods using a mapping function
* @param {Function} mapFunction - lifting function
* @returns {Object} an object having the { mount, update, unmount } functions
*/
function createCoreAPIMethods(mapFunction) {
return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
acc[method] = mapFunction(method);
return acc;
}, {});
}
export { createCoreAPIMethods };

52
node_modules/riot/esm/core/create-pure-component.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
/* Riot WIP, @license MIT */
import { panic, defineDefaults, MOUNT_METHOD_KEY, defineProperty, IS_PURE_SYMBOL } from '@riotjs/util';
import { PURE_COMPONENT_API } from './pure-component-api.js';
import { bindDOMNodeToComponentInstance } from './bind-dom-node-to-component-instance.js';
import { createCoreAPIMethods } from './create-core-api-methods.js';
/**
* Create a pure component
* @param {Function} pureFactoryFunction - pure component factory function
* @param {Array} options.slots - component slots
* @param {Array} options.attributes - component attributes
* @param {Array} options.template - template factory function
* @param {Array} options.template - template factory function
* @param {any} options.props - initial component properties
* @returns {Object} pure component object
*/
function createPureComponent(pureFactoryFunction, _ref) {
let {
slots,
attributes,
props,
css,
template
} = _ref;
if (template) panic('Pure components can not have html');
if (css) panic('Pure components do not have css');
const component = defineDefaults(pureFactoryFunction({
slots,
attributes,
props
}), PURE_COMPONENT_API);
return createCoreAPIMethods(method => function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
// intercept the mount calls to bind the DOM node to the pure object created
// see also https://github.com/riot/riot/issues/2806
if (method === MOUNT_METHOD_KEY) {
const [element] = args; // mark this node as pure element
defineProperty(element, IS_PURE_SYMBOL, true);
bindDOMNodeToComponentInstance(element, component);
}
component[method](...args);
return component;
});
}
export { createPureComponent };

73
node_modules/riot/esm/core/css-manager.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/* Riot WIP, @license MIT */
import $ from 'bianco.query';
import { set } from 'bianco.attr';
const CSS_BY_NAME = new Map();
const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
const getStyleNode = (style => {
return () => {
// lazy evaluation:
// if this function was already called before
// we return its cached result
if (style) return style; // create a new style element or use an existing one
// and cache it internally
style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
set(style, 'type', 'text/css');
/* istanbul ignore next */
if (!style.parentNode) document.head.appendChild(style);
return style;
};
})();
/**
* Object that will be used to inject and manage the css of every tag instance
*/
const cssManager = {
CSS_BY_NAME,
/**
* Save a tag style to be later injected into DOM
* @param { string } name - if it's passed we will map the css to a tagname
* @param { string } css - css string
* @returns {Object} self
*/
add(name, css) {
if (!CSS_BY_NAME.has(name)) {
CSS_BY_NAME.set(name, css);
this.inject();
}
return this;
},
/**
* Inject all previously saved tag styles into DOM
* innerHTML seems slow: http://jsperf.com/riot-insert-style
* @returns {Object} self
*/
inject() {
getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
return this;
},
/**
* Remove a tag style from the DOM
* @param {string} name a registered tagname
* @returns {Object} self
*/
remove(name) {
if (CSS_BY_NAME.has(name)) {
CSS_BY_NAME.delete(name);
this.inject();
}
return this;
}
};
export { CSS_BY_NAME, STYLE_NODE_SELECTOR, cssManager as default };

40
node_modules/riot/esm/core/instantiate-component.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/* Riot WIP, @license MIT */
import { defineProperties, defineDefaults, PROPS_KEY, STATE_KEY, SLOTS_KEY, ROOT_KEY } from '@riotjs/util';
import { COMPONENT_DOM_SELECTORS } from './component-dom-selectors.js';
import { COMPONENT_LIFECYCLE_METHODS } from './component-lifecycle-methods.js';
import cssManager from './css-manager.js';
import curry from 'curri';
import { manageComponentLifecycle } from './manage-component-lifecycle.js';
/**
* Component definition function
* @param {Object} implementation - the component implementation will be generated via compiler
* @param {Object} component - the component initial properties
* @returns {Object} a new component implementation object
*/
function instantiateComponent(_ref) {
let {
css,
template,
componentAPI,
name
} = _ref;
// add the component css into the DOM
if (css && name) cssManager.add(name, css);
return curry(manageComponentLifecycle)(defineProperties( // set the component defaults without overriding the original component API
defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
[PROPS_KEY]: {},
[STATE_KEY]: {}
})), Object.assign({
// defined during the component creation
[SLOTS_KEY]: null,
[ROOT_KEY]: null
}, COMPONENT_DOM_SELECTORS, {
name,
css,
template
})));
}
export { instantiateComponent };

View File

@@ -0,0 +1,93 @@
/* Riot WIP, @license MIT */
import { autobindMethods, defineProperties, isObject, defineProperty, IS_PURE_SYMBOL, PARENT_KEY_SYMBOL, ATTRIBUTES_KEY_SYMBOL, PROPS_KEY, evaluateAttributeExpressions, STATE_KEY, TEMPLATE_KEY_SYMBOL, ROOT_KEY, SLOTS_KEY, ON_BEFORE_MOUNT_KEY, ON_MOUNTED_KEY, SHOULD_UPDATE_KEY, ON_BEFORE_UPDATE_KEY, IS_COMPONENT_UPDATING, ON_UPDATED_KEY, ON_BEFORE_UNMOUNT_KEY, ON_UNMOUNTED_KEY, isFunction } from '@riotjs/util';
import { addCssHook } from './add-css-hook.js';
import { bindDOMNodeToComponentInstance } from './bind-dom-node-to-component-instance.js';
import { computeComponentState } from './compute-component-state.js';
import { computeInitialProps } from './compute-initial-props.js';
import { createAttributeBindings } from './create-attribute-bindings.js';
import { runPlugins } from './run-plugins.js';
/**
* Component creation factory function that will enhance the user provided API
* @param {Object} component - a component implementation previously defined
* @param {Array} options.slots - component slots generated via riot compiler
* @param {Array} options.attributes - attribute expressions generated via riot compiler
* @returns {Riot.Component} a riot component instance
*/
function manageComponentLifecycle(component, _ref) {
let {
slots,
attributes,
props
} = _ref;
return autobindMethods(runPlugins(defineProperties(isObject(component) ? Object.create(component) : component, {
mount(element, state, parentScope) {
if (state === void 0) {
state = {};
}
// any element mounted passing through this function can't be a pure component
defineProperty(element, IS_PURE_SYMBOL, false);
this[PARENT_KEY_SYMBOL] = parentScope;
this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, computeInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
this[STATE_KEY] = computeComponentState(this[STATE_KEY], state);
this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
bindDOMNodeToComponentInstance(element, this); // add eventually the 'is' attribute
component.name && addCssHook(element, component.name); // define the root element
defineProperty(this, ROOT_KEY, element); // define the slots array
defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]); // mount the template
this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
return this;
},
update(state, parentScope) {
if (state === void 0) {
state = {};
}
if (parentScope) {
this[PARENT_KEY_SYMBOL] = parentScope;
this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
}
const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
this[STATE_KEY] = computeComponentState(this[STATE_KEY], state);
this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
// see also https://github.com/riot/riot/issues/2895
if (!this[IS_COMPONENT_UPDATING]) {
this[IS_COMPONENT_UPDATING] = true;
this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
}
this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
this[IS_COMPONENT_UPDATING] = false;
return this;
},
unmount(preserveRoot) {
this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
// in that case the DOM cleanup will happen differently from a parent node
this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
return this;
}
})), Object.keys(component).filter(prop => isFunction(component[prop])));
}
export { manageComponentLifecycle };

View File

@@ -0,0 +1,10 @@
/* Riot WIP, @license MIT */
import { PURE_COMPONENT_API } from './pure-component-api.js';
import { noop } from '@riotjs/util';
const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
clone: noop,
createDOM: noop
});
export { MOCKED_TEMPLATE_INTERFACE };

24
node_modules/riot/esm/core/mount-component.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/* Riot WIP, @license MIT */
import { COMPONENTS_IMPLEMENTATION_MAP, panic } from '@riotjs/util';
import { getName } from '../utils/dom.js';
/**
* Component initialization function starting from a DOM node
* @param {HTMLElement} element - element to upgrade
* @param {Object} initialProps - initial component properties
* @param {string} componentName - component id
* @param {Array} slots - component slots
* @returns {Object} a new component instance bound to a DOM node
*/
function mountComponent(element, initialProps, componentName, slots) {
const name = componentName || getName(element);
if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component named "${name}" was never registered`);
const component = COMPONENTS_IMPLEMENTATION_MAP.get(name)({
props: initialProps,
slots
});
return component.mount(element);
}
export { mountComponent };

10
node_modules/riot/esm/core/pure-component-api.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
/* Riot WIP, @license MIT */
import { MOUNT_METHOD_KEY, noop, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY } from '@riotjs/util';
const PURE_COMPONENT_API = Object.freeze({
[MOUNT_METHOD_KEY]: noop,
[UPDATE_METHOD_KEY]: noop,
[UNMOUNT_METHOD_KEY]: noop
});
export { PURE_COMPONENT_API };

14
node_modules/riot/esm/core/run-plugins.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
/* Riot WIP, @license MIT */
import { PLUGINS_SET } from '@riotjs/util';
/**
* Run the component instance through all the plugins set by the user
* @param {Object} component - component instance
* @returns {Object} the component enhanced by the plugins
*/
function runPlugins(component) {
return [...PLUGINS_SET].reduce((c, fn) => fn(c) || c, component);
}
export { runPlugins };

12
node_modules/riot/esm/riot.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/* Riot WIP, @license MIT */
export { register } from './api/register.js';
export { unregister } from './api/unregister.js';
export { mount } from './api/mount.js';
export { unmount } from './api/unmount.js';
export { install } from './api/install.js';
export { uninstall } from './api/uninstall.js';
export { component } from './api/component.js';
export { pure } from './api/pure.js';
export { withTypes } from './api/with-types.js';
export { version } from './api/version.js';
export { __ } from './api/__.js';

15
node_modules/riot/esm/utils/dom.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
/* Riot WIP, @license MIT */
import { IS_DIRECTIVE } from '@riotjs/util';
import { get } from 'bianco.attr';
/**
* Get the tag name of any DOM node
* @param {HTMLElement} element - DOM node we want to inspect
* @returns {string} name to identify this dom node in riot
*/
function getName(element) {
return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
}
export { getName };