chore: update license info (#21)

This commit is contained in:
Ayo Ayco 2023-12-12 22:06:12 +01:00 committed by GitHub
parent ce1733c7ca
commit 5720901d25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "web-component-base", "name": "web-component-base",
"version": "2.0.0", "version": "2.0.1",
"description": "A zero-dependency & tiny JS base class for creating reactive custom elements easily", "description": "A zero-dependency & tiny JS base class for creating reactive custom elements easily",
"type": "module", "type": "module",
"exports": { "exports": {
@ -32,7 +32,7 @@
"site": "npm start -w site", "site": "npm start -w site",
"build": "npm run clean && tsc && npm run copy:meta && npm run copy:source", "build": "npm run clean && tsc && npm run copy:meta && npm run copy:source",
"clean": "rm -rf dist", "clean": "rm -rf dist",
"copy:meta": "node prepare.js && cp README.md ./dist && cp LICENSE ./dist", "copy:meta": "node prepare.js && cp README.md ./dist && cp LICENSE ./dist && cp -r ./src/vendors ./dist",
"copy:source": "esbuild --minify --bundle ./src/*.js ./src/utils/* --outdir=\"./dist\" --format=\"esm\"", "copy:source": "esbuild --minify --bundle ./src/*.js ./src/utils/* --outdir=\"./dist\" --format=\"esm\"",
"pub": "npm run clean && npm run build && cd ./dist && npm publish", "pub": "npm run clean && npm run build && cd ./dist && npm publish",
"pub:beta": "npm run clean && npm run build && cd ./dist && npm publish --tag beta", "pub:beta": "npm run clean && npm run build && cd ./dist && npm publish --tag beta",

View file

@ -1,3 +1,8 @@
/**
* @license MIT <https://opensource.org/licenses/MIT>
* @author Ayo Ayco <https://ayo.ayco.io>
*/
import { import {
createElement, createElement,
getKebabCase, getKebabCase,
@ -8,9 +13,7 @@ import {
/** /**
* A minimal base class to reduce the complexity of creating reactive custom elements * A minimal base class to reduce the complexity of creating reactive custom elements
* @license MIT <https://opensource.org/licenses/MIT> * @see https://WebComponent.io
* @author Ayo Ayco <https://ayo.ayco.io>
* @see https://www.npmjs.com/package/web-component-base#readme
*/ */
export class WebComponent extends HTMLElement { export class WebComponent extends HTMLElement {
/** /**
@ -21,6 +24,8 @@ export class WebComponent extends HTMLElement {
/** /**
* Blueprint for the Proxy props * Blueprint for the Proxy props
* @typedef {{[name: string]: any}} PropStringMap
* @type {PropStringMap}
*/ */
static props; static props;
@ -35,7 +40,6 @@ export class WebComponent extends HTMLElement {
/** /**
* Read-only property containing camelCase counterparts of observed attributes. * Read-only property containing camelCase counterparts of observed attributes.
* @typedef {{[name: string]: any}} PropStringMap
* @see https://www.npmjs.com/package/web-component-base#prop-access * @see https://www.npmjs.com/package/web-component-base#prop-access
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
* @type {PropStringMap} * @type {PropStringMap}
@ -141,7 +145,7 @@ export class WebComponent extends HTMLElement {
throw TypeError( throw TypeError(
`Cannot assign ${typeof value} to ${ `Cannot assign ${typeof value} to ${
typeMap[prop] typeMap[prop]
} property (setting '${prop}' of ${meta.constructor.name})`, } property (setting '${prop}' of ${meta.constructor.name})`
); );
} else if (oldValue !== value) { } else if (oldValue !== value) {
obj[prop] = value; obj[prop] = value;
@ -176,7 +180,7 @@ export class WebComponent extends HTMLElement {
if (!this.#props) { if (!this.#props) {
this.#props = new Proxy( this.#props = new Proxy(
initialProps, initialProps,
this.#handler((key, value) => this.setAttribute(key, value), this), this.#handler((key, value) => this.setAttribute(key, value), this)
); );
} }
} }
@ -185,13 +189,11 @@ export class WebComponent extends HTMLElement {
render() { render() {
if (typeof this.template === "string") { if (typeof this.template === "string") {
this.innerHTML = this.template; this.innerHTML = this.template;
return;
} else if (typeof this.template === "object") { } else if (typeof this.template === "object") {
const tree = this.template; const tree = this.template;
// TODO: smart diffing // TODO: smart diffing
if (JSON.stringify(this.#prevDOM) !== JSON.stringify(tree)) { if (JSON.stringify(this.#prevDOM) !== JSON.stringify(tree)) {
// render
const el = createElement(tree); const el = createElement(tree);
if (el) { if (el) {
if (Array.isArray(el)) this.replaceChildren(...el); if (Array.isArray(el)) this.replaceChildren(...el);

View file

@ -1,7 +1,3 @@
/**
* htm -- https://github.com/developit/htm
* For license information please see ./vendors/htm/LICENSE.txt
*/
const htm = const htm =
(new Map(), (new Map(),
function (n) { function (n) {
@ -77,4 +73,9 @@ function h(type, props, ...children) {
return { type, props, children }; return { type, props, children };
} }
/**
* For htm license information please see ./vendors/htm/LICENSE.txt
* @license Apache <https://www.apache.org/licenses/LICENSE-2.0>
* @author Jason Miller <jason@developit.ca>
*/
export const html = htm.bind(h); export const html = htm.bind(h);

View file

@ -1,3 +1,5 @@
This license applies to parts of the `html` function originating from https://github.com/developit/htm project:
Apache License Apache License
Version 2.0, January 2004 Version 2.0, January 2004