fix CE defines 2

This commit is contained in:
“chrisshank” 2024-12-03 14:34:48 -08:00
parent 9d1d202dee
commit 53a87fa344
22 changed files with 45 additions and 61 deletions

View File

@ -12,6 +12,7 @@ class FolkThought extends HTMLElement {
static tagName = 'fc-thought'; static tagName = 'fc-thought';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }

View File

@ -4,6 +4,7 @@ export class GeoWiki extends HTMLElement {
static tagName = 'geo-wiki'; static tagName = 'geo-wiki';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -62,3 +63,5 @@ export class GeoWiki extends HTMLElement {
this.appendChild(list); this.appendChild(list);
} }
} }
GeoWiki.define();

View File

@ -219,6 +219,7 @@ export class RecordPlayer extends HTMLElement {
static tagName = 'record-player'; static tagName = 'record-player';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -384,3 +385,5 @@ function diffStyles(stylesA: Map<string, string>, stylesB: Map<string, string>):
return changedProperties; return changedProperties;
} }
RecordPlayer.define();

View File

@ -35,10 +35,10 @@
</head> </head>
<body> <body>
<folk-shape x="10" y="100" width="250" height="400"> <folk-shape x="10" y="100" width="250" height="400">
<iframe id="frame1" src="./arrows.html"></iframe> <iframe id="frame1" src="./sticky-html-arrow.html"></iframe>
</folk-shape> </folk-shape>
<folk-shape x="300" y="100" width="250" height="400"> <folk-shape x="300" y="100" width="250" height="400">
<iframe id="frame2" src="./arrows.html"></iframe> <iframe id="frame2" src="./sticky-html-arrow.html"></iframe>
</folk-shape> </folk-shape>
<folk-rope source="#frame1 >>> #box1" target="#frame2 >>> #box1"></folk-rope> <folk-rope source="#frame1 >>> #box1" target="#frame2 >>> #box1"></folk-rope>

View File

@ -30,6 +30,7 @@ export class DistanceField extends HTMLElement {
private isPingTexture: boolean = true; private isPingTexture: boolean = true;
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -569,6 +570,4 @@ void main() {
outColor = vec4(seedCoord, v_shapeID, 0.0); // Seed coords (x, y), shape ID (z), initial distance (a) outColor = vec4(seedCoord, v_shapeID, 0.0); // Seed coords (x, y), shape ID (z), initial distance (a)
}`; }`;
if (!customElements.get('distance-field')) { DistanceField.define();
DistanceField.define();
}

View File

@ -86,6 +86,4 @@ export class FolkConnection extends AbstractArrow {
} }
} }
if (!customElements.get('folk-connection')) { FolkConnection.define();
FolkConnection.define();
}

View File

@ -245,6 +245,4 @@ function parseAst(functionBody: string) {
console.log('Properties accessed on from:', Array.from(fromProps)); console.log('Properties accessed on from:', Array.from(fromProps));
} }
if (!customElements.get('folk-event-propagator')) { FolkEventPropagator.define();
FolkEventPropagator.define();
}

View File

@ -111,6 +111,4 @@ export function makeHull(rects: DOMRectReadOnly[]): Point[] {
return upperHull.concat(lowerHull); return upperHull.concat(lowerHull);
} }
if (!customElements.get('folk-hull')) { FolkHull.define();
FolkHull.define();
}

View File

@ -212,6 +212,4 @@ export class FolkInk extends HTMLElement {
} }
} }
if (!customElements.get('folk-ink')) { FolkInk.define();
FolkInk.define();
}

View File

@ -15,6 +15,7 @@ export class FolkLLM extends HTMLElement {
static tagName = 'folk-llm'; static tagName = 'folk-llm';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -103,6 +104,4 @@ declare global {
} }
} }
if (!customElements.get('folk-llm')) { FolkLLM.define();
FolkLLM.define();
}

View File

@ -25,6 +25,7 @@ export class FolkMap extends HTMLElement {
static tagName = 'folk-map'; static tagName = 'folk-map';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -95,6 +96,4 @@ export class FolkMap extends HTMLElement {
}; };
} }
if (!customElements.get('folk-map')) { FolkMap.define();
FolkMap.define();
}

View File

@ -8,6 +8,7 @@ export class FolkMetronome extends HTMLElement {
static tagName = 'folk-metronome'; static tagName = 'folk-metronome';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -70,6 +71,4 @@ export class FolkMetronome extends HTMLElement {
}; };
} }
if (!customElements.get('folk-metronome')) { FolkMetronome.define();
FolkMetronome.define();
}

View File

@ -132,6 +132,7 @@ export class FolkProximity extends HTMLElement {
static tagName = 'folk-proximity'; static tagName = 'folk-proximity';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -193,6 +194,5 @@ export class FolkProximity extends HTMLElement {
} }
} }
if (!customElements.get('folk-proximity')) { FolkCluster.define();
FolkProximity.define(); FolkProximity.define();
}

View File

@ -258,6 +258,4 @@ function applyConstraint(p1: RopePoint, p2: RopePoint) {
} }
} }
if (!customElements.get('folk-rope')) { FolkRope.define();
FolkRope.define();
}

View File

@ -14,6 +14,7 @@ export class FolkSet extends HTMLElement {
static tagName = 'folk-set'; static tagName = 'folk-set';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -79,6 +80,4 @@ export class FolkSet extends HTMLElement {
update() {} update() {}
} }
if (!customElements.get('folk-set')) { FolkSet.define();
FolkSet.define();
}

View File

@ -91,7 +91,7 @@ styles.replaceSync(css`
div { div {
height: 100%; height: 100%;
width: 100%; width: 100%;
overflow: hidden; overflow: scroll;
pointer-events: none; pointer-events: none;
} }
@ -221,6 +221,7 @@ export class FolkShape extends HTMLElement {
static tagName = 'folk-shape'; static tagName = 'folk-shape';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -326,7 +327,6 @@ export class FolkShape extends HTMLElement {
super(); super();
this.addEventListener('pointerdown', this); this.addEventListener('pointerdown', this);
this.setAttribute('tabindex', '0');
this.#shadow.adoptedStyleSheets = [styles, this.#dynamicStyles]; this.#shadow.adoptedStyleSheets = [styles, this.#dynamicStyles];
// Ideally we would creating these lazily on first focus, but the resize handlers need to be around for delegate focus to work. // Ideally we would creating these lazily on first focus, but the resize handlers need to be around for delegate focus to work.
@ -348,6 +348,7 @@ export class FolkShape extends HTMLElement {
#isConnected = false; #isConnected = false;
connectedCallback() { connectedCallback() {
this.setAttribute('tabindex', '0');
this.#isConnected = true; this.#isConnected = true;
this.#update(new Set(['type', 'x', 'y', 'height', 'width', 'rotation'])); this.#update(new Set(['type', 'x', 'y', 'height', 'width', 'rotation']));
} }
@ -684,6 +685,4 @@ export class FolkShape extends HTMLElement {
} }
} }
if (!customElements.get('folk-shape')) { FolkShape.define();
FolkShape.define();
}

View File

@ -10,6 +10,7 @@ export class FolkSpace extends HTMLElement {
static tagName = 'folk-space'; static tagName = 'folk-space';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -71,6 +72,4 @@ export class FolkSpace extends HTMLElement {
} }
} }
if (!customElements.get('folk-space')) { FolkSpace.define();
FolkSpace.define();
}

View File

@ -153,6 +153,7 @@ export class FolkSpreadsheet extends HTMLElement {
static tagName = 'folk-spreadsheet'; static tagName = 'folk-spreadsheet';
static define() { static define() {
if (customElements.get(this.tagName)) return;
FolkSpreadSheetCell.define(); FolkSpreadSheetCell.define();
FolkSpreadsheetHeader.define(); FolkSpreadsheetHeader.define();
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
@ -349,6 +350,7 @@ export class FolkSpreadsheetHeader extends HTMLElement {
static tagName = 's-header'; static tagName = 's-header';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -379,6 +381,7 @@ export class FolkSpreadSheetCell extends HTMLElement {
static tagName = 'folk-cell'; static tagName = 'folk-cell';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -514,6 +517,4 @@ export class FolkSpreadSheetCell extends HTMLElement {
} }
} }
if (!customElements.get('folk-cell')) { FolkSpreadsheet.define();
FolkSpreadSheetCell.define();
}

View File

@ -8,6 +8,7 @@ export class FolkTimer extends HTMLElement {
static tagName = 'folk-timer'; static tagName = 'folk-timer';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -40,6 +41,4 @@ export class FolkTimer extends HTMLElement {
}; };
} }
if (!customElements.get('folk-timer')) { FolkTimer.define();
FolkTimer.define();
}

View File

@ -33,6 +33,7 @@ export class FolkToolbar extends HTMLElement {
static tagName = 'folk-toolbar'; static tagName = 'folk-toolbar';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -113,9 +114,6 @@ export class FolkToolbar extends HTMLElement {
'text/html' 'text/html'
).body.firstElementChild; ).body.firstElementChild;
if (!customElements.get('folk-event-propagator')) {
FolkEventPropagator.define();
}
if (propagator) { if (propagator) {
document.body.appendChild(propagator); document.body.appendChild(propagator);
} }
@ -129,6 +127,5 @@ export class FolkToolbar extends HTMLElement {
} }
} }
if (!customElements.get('folk-toolbar')) { FolkEventPropagator.define();
FolkToolbar.define(); FolkToolbar.define();
}

View File

@ -14,6 +14,7 @@ export class FolkWeather extends HTMLElement {
static tagName = 'folk-weather'; static tagName = 'folk-weather';
static define() { static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this); customElements.define(this.tagName, this);
} }
@ -69,6 +70,4 @@ export class FolkWeather extends HTMLElement {
} }
} }
if (!customElements.get('folk-weather')) { FolkWeather.define();
FolkWeather.define();
}

View File

@ -101,6 +101,4 @@ function computeInlineVertices(rects: DOMRect[]): Point[] {
return vertices; return vertices;
} }
if (!customElements.get('folk-xanadu')) { FolkXanadu.define();
FolkXanadu.define();
}