@fluid-topics/ft-wc-utils 2.0.27 → 2.0.28
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/build/CancelablePromise.d.ts +3 -3
- package/build/ScopedRegistryLitElement.d.ts +7 -0
- package/build/ScopedRegistryLitElement.js +25 -2
- package/build/decorators.js +3 -4
- package/build/globals.min.js +25 -127
- package/build/helpers.d.ts +2 -0
- package/build/helpers.js +7 -0
- package/build/redux/FtReduxStore.d.ts +2 -2
- package/build/redux/decorators.d.ts +1 -1
- package/build/silent-define.js +8 -1
- package/build/silent-define.min.js +1 -1
- package/package.json +2 -2
package/build/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Constructor, Optional, Provider } from "./generic-types";
|
|
2
|
+
import type { ElementDefinitionsMap } from "./ScopedRegistryLitElement";
|
|
2
3
|
export declare const delay: (ms: number) => Promise<unknown>;
|
|
3
4
|
export declare function waitUntil(condition: Provider<boolean | Promise<boolean>>, interval?: number, timeout?: Optional<number>): Promise<void>;
|
|
4
5
|
export declare function waitFor<T>(provider: Provider<Optional<T> | Promise<Optional<T>>>, interval?: number, timeout?: Optional<number>): Promise<T>;
|
|
@@ -19,3 +20,4 @@ export declare function deepCopy<T = any>(value: T): T;
|
|
|
19
20
|
export declare function randomId(size: number, prefix?: string): string;
|
|
20
21
|
export declare function applyMixinOnce<IN extends Constructor<unknown>, OUT>(mixinIdentifier: symbol, mixin: (c: IN) => OUT): (c: IN) => OUT;
|
|
21
22
|
export declare function ignoreComposingEvents(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
23
|
+
export declare function customElements(definitions: ElementDefinitionsMap): void;
|
package/build/helpers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { customElement } from "./decorators";
|
|
1
2
|
export const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2
3
|
export async function waitUntil(condition, interval = 10, timeout = 20000) {
|
|
3
4
|
await waitFor(async () => await condition() || undefined, interval, timeout);
|
|
@@ -220,3 +221,9 @@ export function ignoreComposingEvents() {
|
|
|
220
221
|
};
|
|
221
222
|
};
|
|
222
223
|
}
|
|
224
|
+
export function customElements(definitions) {
|
|
225
|
+
for (const [tagName, klass] of Object.entries(definitions)) {
|
|
226
|
+
// eslint-disable-next-line ft/custom-elements
|
|
227
|
+
customElement(tagName)(klass);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -27,8 +27,8 @@ export declare class FtReduxStore<State = any, CR extends SliceCaseReducers<Stat
|
|
|
27
27
|
get name(): string;
|
|
28
28
|
get reducer(): Reducer<State>;
|
|
29
29
|
get caseReducers(): { [Type in keyof CR]: CR[Type] extends {
|
|
30
|
-
reducer: infer
|
|
31
|
-
} ?
|
|
30
|
+
reducer: infer Reducer;
|
|
31
|
+
} ? Reducer : CR[Type]; };
|
|
32
32
|
getInitialState(): State;
|
|
33
33
|
}
|
|
34
34
|
export declare function clearAllStores(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FtLitElementRedux } from "./FtLitElementRedux";
|
|
2
2
|
import { ReduxEventListenerInit, ReduxPropertyInit } from "./models";
|
|
3
3
|
export declare const reduxReactive: () => (proto: Object, name: string) => void;
|
|
4
|
-
export declare const redux: <State,
|
|
4
|
+
export declare const redux: <State, Element extends FtLitElementRedux>(propertyInit?: ReduxPropertyInit<State, Element>) => (proto: Object, name: string) => void;
|
|
5
5
|
export declare const reduxEventListener: (init: ReduxEventListenerInit) => (proto: Object, name: string) => void;
|
package/build/silent-define.js
CHANGED
|
@@ -7,6 +7,7 @@ try {
|
|
|
7
7
|
catch (e) {
|
|
8
8
|
const initialDefine = window.customElements.define;
|
|
9
9
|
window.customElements.define = (name, constructor, options) => {
|
|
10
|
+
var _a;
|
|
10
11
|
if (constructor === null) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
@@ -14,7 +15,13 @@ catch (e) {
|
|
|
14
15
|
initialDefine.bind(window.customElements)(name, constructor, options);
|
|
15
16
|
}
|
|
16
17
|
catch (e) {
|
|
17
|
-
|
|
18
|
+
if ((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("this constructor has already been used")) {
|
|
19
|
+
window.customElements.define(name, class extends constructor {
|
|
20
|
+
}, options);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.info(name, constructor, options, e);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
};
|
|
20
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{if(!ShadowRoot.prototype.createElement){let m=window.HTMLElement,
|
|
1
|
+
"use strict";(()=>{if(!ShadowRoot.prototype.createElement){let m=window.HTMLElement,y=window.customElements.define,w=window.customElements.get,f=window.customElements,l=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap;window.CustomElementRegistry=class{constructor(){this._definitionsByTag=new Map,this._definitionsByClass=new Map,this._whenDefinedPromises=new Map,this._awaitingUpgrade=new Map}define(e,t){if(e=e.toLowerCase(),this._getDefinition(e)!==void 0)throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${e}" has already been used with this registry`);if(this._definitionsByClass.get(t)!==void 0)throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");let o=t.prototype.attributeChangedCallback,i=new Set(t.observedAttributes||[]);O(t,i,o);let r={elementClass:t,connectedCallback:t.prototype.connectedCallback,disconnectedCallback:t.prototype.disconnectedCallback,adoptedCallback:t.prototype.adoptedCallback,attributeChangedCallback:o,formAssociated:t.formAssociated,formAssociatedCallback:t.prototype.formAssociatedCallback,formDisabledCallback:t.prototype.formDisabledCallback,formResetCallback:t.prototype.formResetCallback,formStateRestoreCallback:t.prototype.formStateRestoreCallback,observedAttributes:i};this._definitionsByTag.set(e,r),this._definitionsByClass.set(t,r);let d=w.call(f,e);d||(d=L(e),y.call(f,e,d)),this===window.customElements&&(g.set(t,r),r.standInClass=d);let c=this._awaitingUpgrade.get(e);if(c){this._awaitingUpgrade.delete(e);for(let s of c)p.delete(s),R(s,r,!0)}let n=this._whenDefinedPromises.get(e);return n!==void 0&&(n.resolve(t),this._whenDefinedPromises.delete(e)),t}upgrade(){u.push(this),f.upgrade.apply(f,arguments),u.pop()}get(e){return this._definitionsByTag.get(e)?.elementClass}_getDefinition(e){return this._definitionsByTag.get(e)}whenDefined(e){let t=this._getDefinition(e);if(t!==void 0)return Promise.resolve(t.elementClass);let o=this._whenDefinedPromises.get(e);return o===void 0&&(o={},o.promise=new Promise(i=>o.resolve=i),this._whenDefinedPromises.set(e,o)),o.promise}_upgradeWhenDefined(e,t,o){let i=this._awaitingUpgrade.get(t);i||this._awaitingUpgrade.set(t,i=new Set),o?i.add(e):i.delete(e)}};let b;window.HTMLElement=function(){let t=b;if(t)return b=void 0,t;let o=g.get(this.constructor);if(!o)throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)");return t=Reflect.construct(m,[],o.standInClass),Object.setPrototypeOf(t,this.constructor.prototype),l.set(t,o),t},window.HTMLElement.prototype=m.prototype;let A=e=>e===document||e instanceof ShadowRoot,T=e=>{let t=e.getRootNode();if(!A(t)){let o=u[u.length-1];if(o instanceof CustomElementRegistry)return o;t=o.getRootNode(),A(t)||(t=k.get(t)?.getRootNode()||document)}return t.customElements},L=e=>class{static get formAssociated(){return!0}constructor(){let o=Reflect.construct(m,[],this.constructor);Object.setPrototypeOf(o,HTMLElement.prototype);let i=T(o)||window.customElements,r=i._getDefinition(e);return r?R(o,r):p.set(o,i),o}connectedCallback(){let o=l.get(this);o?o.connectedCallback&&o.connectedCallback.apply(this,arguments):p.get(this)._upgradeWhenDefined(this,e,!0)}disconnectedCallback(){let o=l.get(this);o?o.disconnectedCallback&&o.disconnectedCallback.apply(this,arguments):p.get(this)._upgradeWhenDefined(this,e,!1)}adoptedCallback(){l.get(this)?.adoptedCallback?.apply(this,arguments)}formAssociatedCallback(){let o=l.get(this);o&&o.formAssociated&&o?.formAssociatedCallback?.apply(this,arguments)}formDisabledCallback(){let o=l.get(this);o?.formAssociated&&o?.formDisabledCallback?.apply(this,arguments)}formResetCallback(){let o=l.get(this);o?.formAssociated&&o?.formResetCallback?.apply(this,arguments)}formStateRestoreCallback(){let o=l.get(this);o?.formAssociated&&o?.formStateRestoreCallback?.apply(this,arguments)}},O=(e,t,o)=>{if(t.size===0||o===void 0)return;let i=e.prototype.setAttribute;i&&(e.prototype.setAttribute=function(c,n){let s=c.toLowerCase();if(t.has(s)){let a=this.getAttribute(s);i.call(this,s,n),o.call(this,s,a,n)}else i.call(this,s,n)});let r=e.prototype.removeAttribute;r&&(e.prototype.removeAttribute=function(c){let n=c.toLowerCase();if(t.has(n)){let s=this.getAttribute(n);r.call(this,n),o.call(this,n,s,null)}else r.call(this,n)});let d=e.prototype.toggleAttribute;d&&(e.prototype.toggleAttribute=function(c,n){let s=c.toLowerCase();if(t.has(s)){let a=this.getAttribute(s);d.call(this,s,n);let h=this.getAttribute(s);o.call(this,s,a,h)}else d.call(this,s,n)})},M=e=>{let t=Object.getPrototypeOf(e);if(t!==window.HTMLElement)return t===m?Object.setPrototypeOf(e,window.HTMLElement):M(t)},R=(e,t,o=!1)=>{Object.setPrototypeOf(e,t.elementClass.prototype),l.set(e,t),b=e;try{new t.elementClass}catch{M(t.elementClass),new t.elementClass}t.attributeChangedCallback&&t.observedAttributes.forEach(i=>{e.hasAttribute(i)&&t.attributeChangedCallback.call(e,i,null,e.getAttribute(i))}),o&&t.connectedCallback&&e.isConnected&&t.connectedCallback.call(e)},S=Element.prototype.attachShadow;Element.prototype.attachShadow=function(e){let t=S.apply(this,arguments);return e.customElements&&(t.customElements=e.customElements),t};let u=[document],E=(e,t,o=void 0)=>{let i=(o?Object.getPrototypeOf(o):e.prototype)[t];e.prototype[t]=function(){u.push(this);let r=i.apply(o||this,arguments);return r!==void 0&&k.set(r,this),u.pop(),r}};E(ShadowRoot,"createElement",document),E(ShadowRoot,"importNode",document),E(Element,"insertAdjacentHTML");let _=(e,t)=>{let o=Object.getOwnPropertyDescriptor(e.prototype,t);Object.defineProperty(e.prototype,t,{...o,set(i){u.push(this),o.set.call(this,i),u.pop()}})};if(_(Element,"innerHTML"),_(ShadowRoot,"innerHTML"),Object.defineProperty(window,"customElements",{value:new CustomElementRegistry,configurable:!0,writable:!0}),window.ElementInternals&&window.ElementInternals.prototype.setFormValue){let e=new WeakMap,t=HTMLElement.prototype.attachInternals,o=["setFormValue","setValidity","checkValidity","reportValidity"];HTMLElement.prototype.attachInternals=function(...c){let n=t.call(this,...c);return e.set(n,this),n},o.forEach(c=>{let n=window.ElementInternals.prototype,s=n[c];n[c]=function(...a){let h=e.get(this);if(l.get(h).formAssociated===!0)return s?.call(this,...a);throw new DOMException(`Failed to execute ${s} on 'ElementInternals': The target element is not a form-associated custom element.`)}});class i extends Array{constructor(n){super(...n),this._elements=n}get value(){return this._elements.find(n=>n.checked===!0)?.value||""}}class r{constructor(n){let s=new Map;n.forEach((a,h)=>{let C=a.getAttribute("name"),D=s.get(C)||[];this[+h]=a,D.push(a),s.set(C,D)}),this.length=n.length,s.forEach((a,h)=>{a&&(a.length===1?this[h]=a[0]:this[h]=new i(a))})}namedItem(n){return this[n]}}let d=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"elements");Object.defineProperty(HTMLFormElement.prototype,"elements",{get:function(){let c=d.get.call(this,[]),n=[];for(let s of c){let a=l.get(s);(!a||a.formAssociated===!0)&&n.push(s)}return new r(n)}})}}try{window.customElements.define("custom-element",null)}catch{let y=window.customElements.define;window.customElements.define=(w,f,l)=>{var p;if(f!==null)try{y.bind(window.customElements)(w,f,l)}catch(g){!((p=g.message)===null||p===void 0)&&p.includes("this constructor has already been used")?window.customElements.define(w,class extends f{},l):console.info(w,f,l,g)}}}})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@webcomponents/scoped-custom-element-registry/src/scoped-custom-element-registry.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-wc-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.28",
|
|
4
4
|
"description": "Internal web components tools",
|
|
5
5
|
"author": "Fluid Topics <devtopics@antidot.net>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/mark.js": "8.11.12"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "c81a78f103c19425eb2eac2675a6dd8396e2aa4e"
|
|
30
30
|
}
|