@gjsify/dom-elements 0.3.16 → 0.3.17
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/lib/esm/_virtual/_rolldown/runtime.js +1 -18
- package/lib/esm/attr.js +1 -38
- package/lib/esm/character-data.js +1 -63
- package/lib/esm/comment.js +1 -28
- package/lib/esm/document-fragment.js +1 -119
- package/lib/esm/document.js +1 -82
- package/lib/esm/dom-matrix.js +1 -159
- package/lib/esm/dom-token-list.js +1 -115
- package/lib/esm/element.js +1 -247
- package/lib/esm/font-face.js +1 -95
- package/lib/esm/gst-time.js +1 -22
- package/lib/esm/html-canvas-element.js +1 -84
- package/lib/esm/html-element.js +1 -426
- package/lib/esm/html-image-element.js +1 -231
- package/lib/esm/html-media-element.js +1 -128
- package/lib/esm/html-video-element.js +1 -120
- package/lib/esm/image.js +1 -29
- package/lib/esm/index.js +1 -29
- package/lib/esm/intersection-observer.js +1 -23
- package/lib/esm/location-stub.js +1 -27
- package/lib/esm/match-media.js +1 -21
- package/lib/esm/mutation-observer.js +1 -19
- package/lib/esm/named-node-map.js +1 -124
- package/lib/esm/namespace-uri.js +1 -11
- package/lib/esm/node-list.js +1 -40
- package/lib/esm/node-type.js +1 -15
- package/lib/esm/node.js +1 -244
- package/lib/esm/property-symbol.js +1 -36
- package/lib/esm/register/canvas.js +1 -20
- package/lib/esm/register/document.js +1 -41
- package/lib/esm/register/font-face.js +1 -18
- package/lib/esm/register/helpers.js +1 -18
- package/lib/esm/register/image.js +1 -9
- package/lib/esm/register/location.js +1 -7
- package/lib/esm/register/match-media.js +1 -7
- package/lib/esm/register/navigator.js +1 -6
- package/lib/esm/register/observers.js +1 -11
- package/lib/esm/register.js +1 -8
- package/lib/esm/resize-observer.js +1 -16
- package/lib/esm/text.js +1 -58
- package/lib/esm/types/index.js +1 -3
- package/package.json +12 -12
- package/tsconfig.tsbuildinfo +1 -1
package/lib/esm/element.js
CHANGED
|
@@ -1,247 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NodeType } from "./node-type.js";
|
|
3
|
-
import { Node } from "./node.js";
|
|
4
|
-
import { NamespaceURI } from "./namespace-uri.js";
|
|
5
|
-
import { NamedNodeMap } from "./named-node-map.js";
|
|
6
|
-
|
|
7
|
-
//#region src/element.ts
|
|
8
|
-
let _PS$tagName, _PS$localName, _PS$namespaceURI, _PS$prefix, _PS$attributes, _PS$propertyEventList;
|
|
9
|
-
/**
|
|
10
|
-
* DOM Element class.
|
|
11
|
-
*
|
|
12
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
13
|
-
*/
|
|
14
|
-
var Element = class extends Node {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
this[_PS$tagName] = "";
|
|
18
|
-
this[_PS$localName] = "";
|
|
19
|
-
this[_PS$namespaceURI] = NamespaceURI.html;
|
|
20
|
-
this[_PS$prefix] = null;
|
|
21
|
-
this[_PS$attributes] = new NamedNodeMap(this);
|
|
22
|
-
this[_PS$propertyEventList] = new Map();
|
|
23
|
-
this._pointerCaptures = new Set();
|
|
24
|
-
this[nodeType] = NodeType.ELEMENT_NODE;
|
|
25
|
-
}
|
|
26
|
-
get tagName() {
|
|
27
|
-
return this[tagName];
|
|
28
|
-
}
|
|
29
|
-
get localName() {
|
|
30
|
-
return this[localName];
|
|
31
|
-
}
|
|
32
|
-
get namespaceURI() {
|
|
33
|
-
return this[namespaceURI];
|
|
34
|
-
}
|
|
35
|
-
get prefix() {
|
|
36
|
-
return this[prefix];
|
|
37
|
-
}
|
|
38
|
-
get nodeName() {
|
|
39
|
-
return this[tagName];
|
|
40
|
-
}
|
|
41
|
-
get attributes() {
|
|
42
|
-
return this[attributes];
|
|
43
|
-
}
|
|
44
|
-
get id() {
|
|
45
|
-
return this.getAttribute("id") ?? "";
|
|
46
|
-
}
|
|
47
|
-
set id(value) {
|
|
48
|
-
this.setAttribute("id", value);
|
|
49
|
-
}
|
|
50
|
-
get className() {
|
|
51
|
-
return this.getAttribute("class") ?? "";
|
|
52
|
-
}
|
|
53
|
-
set className(value) {
|
|
54
|
-
this.setAttribute("class", value);
|
|
55
|
-
}
|
|
56
|
-
get children() {
|
|
57
|
-
return this[elementChildren];
|
|
58
|
-
}
|
|
59
|
-
get childElementCount() {
|
|
60
|
-
return this[elementChildren].length;
|
|
61
|
-
}
|
|
62
|
-
get firstElementChild() {
|
|
63
|
-
return this[elementChildren][0] ?? null;
|
|
64
|
-
}
|
|
65
|
-
get lastElementChild() {
|
|
66
|
-
const children = this[elementChildren];
|
|
67
|
-
return children[children.length - 1] ?? null;
|
|
68
|
-
}
|
|
69
|
-
get previousElementSibling() {
|
|
70
|
-
const parent = this[parentNode];
|
|
71
|
-
if (!parent) return null;
|
|
72
|
-
const siblings = parent[elementChildren];
|
|
73
|
-
const idx = siblings.indexOf(this);
|
|
74
|
-
return idx > 0 ? siblings[idx - 1] : null;
|
|
75
|
-
}
|
|
76
|
-
get nextElementSibling() {
|
|
77
|
-
const parent = this[parentNode];
|
|
78
|
-
if (!parent) return null;
|
|
79
|
-
const siblings = parent[elementChildren];
|
|
80
|
-
const idx = siblings.indexOf(this);
|
|
81
|
-
return idx !== -1 && idx < siblings.length - 1 ? siblings[idx + 1] : null;
|
|
82
|
-
}
|
|
83
|
-
get textContent() {
|
|
84
|
-
let text = "";
|
|
85
|
-
for (const child of this[childNodesList]) {
|
|
86
|
-
if (child.textContent !== null) {
|
|
87
|
-
text += child.textContent;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return text;
|
|
91
|
-
}
|
|
92
|
-
set textContent(_value) {
|
|
93
|
-
const children = this[childNodesList];
|
|
94
|
-
while (children.length > 0) {
|
|
95
|
-
this.removeChild(children[0]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
getAttribute(qualifiedName) {
|
|
99
|
-
const attr = this[attributes].getNamedItem(qualifiedName);
|
|
100
|
-
return attr ? attr.value : null;
|
|
101
|
-
}
|
|
102
|
-
getAttributeNS(namespace, localName) {
|
|
103
|
-
const attr = this[attributes].getNamedItemNS(namespace, localName);
|
|
104
|
-
return attr ? attr.value : null;
|
|
105
|
-
}
|
|
106
|
-
setAttribute(qualifiedName, value) {
|
|
107
|
-
this[attributes]._setNamedItem(qualifiedName, String(value));
|
|
108
|
-
}
|
|
109
|
-
setAttributeNS(namespace, qualifiedName, value) {
|
|
110
|
-
const ns = namespace === "" ? null : namespace;
|
|
111
|
-
const parts = qualifiedName.split(":");
|
|
112
|
-
const prefix = parts.length > 1 ? parts[0] : null;
|
|
113
|
-
this[attributes]._setNamedItem(qualifiedName, String(value), ns, prefix);
|
|
114
|
-
}
|
|
115
|
-
removeAttribute(qualifiedName) {
|
|
116
|
-
this[attributes]._removeNamedItem(qualifiedName);
|
|
117
|
-
}
|
|
118
|
-
removeAttributeNS(namespace, localName) {
|
|
119
|
-
const ns = namespace === "" ? null : namespace;
|
|
120
|
-
this[attributes]._removeNamedItemNS(ns, localName);
|
|
121
|
-
}
|
|
122
|
-
hasAttribute(qualifiedName) {
|
|
123
|
-
return this[attributes].getNamedItem(qualifiedName) !== null;
|
|
124
|
-
}
|
|
125
|
-
hasAttributeNS(namespace, localName) {
|
|
126
|
-
return this[attributes].getNamedItemNS(namespace, localName) !== null;
|
|
127
|
-
}
|
|
128
|
-
getAttributeNode(qualifiedName) {
|
|
129
|
-
return this[attributes].getNamedItem(qualifiedName);
|
|
130
|
-
}
|
|
131
|
-
setAttributeNode(attr) {
|
|
132
|
-
return this[attributes].setNamedItem(attr);
|
|
133
|
-
}
|
|
134
|
-
removeAttributeNode(attr) {
|
|
135
|
-
const existing = this[attributes].getNamedItem(attr.name);
|
|
136
|
-
if (!existing) {
|
|
137
|
-
throw new DOMException("Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.", "NotFoundError");
|
|
138
|
-
}
|
|
139
|
-
this[attributes].removeNamedItem(existing.name);
|
|
140
|
-
return existing;
|
|
141
|
-
}
|
|
142
|
-
toggleAttribute(qualifiedName, force) {
|
|
143
|
-
if (force !== undefined) {
|
|
144
|
-
if (force) {
|
|
145
|
-
this.setAttribute(qualifiedName, "");
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
this.removeAttribute(qualifiedName);
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
if (this.hasAttribute(qualifiedName)) {
|
|
152
|
-
this.removeAttribute(qualifiedName);
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
this.setAttribute(qualifiedName, "");
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
hasAttributes() {
|
|
159
|
-
return this[attributes].length > 0;
|
|
160
|
-
}
|
|
161
|
-
dispatchEvent(event) {
|
|
162
|
-
const result = super.dispatchEvent(event);
|
|
163
|
-
const handler = this[propertyEventListeners].get("on" + event.type);
|
|
164
|
-
if (typeof handler === "function") {
|
|
165
|
-
handler.call(this, event);
|
|
166
|
-
}
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
querySelector(_selectors) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
querySelectorAll(_selectors) {
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
matches(_selectors) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
closest(_selectors) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
getElementsByTagName(tagName$1) {
|
|
182
|
-
const results = [];
|
|
183
|
-
const upperTag = tagName$1.toUpperCase();
|
|
184
|
-
const walk = (node) => {
|
|
185
|
-
for (const child of node[childNodesList]) {
|
|
186
|
-
if (child[nodeType] === NodeType.ELEMENT_NODE) {
|
|
187
|
-
const el = child;
|
|
188
|
-
if (tagName$1 === "*" || el[tagName] === upperTag) {
|
|
189
|
-
results.push(el);
|
|
190
|
-
}
|
|
191
|
-
walk(el);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
walk(this);
|
|
196
|
-
return results;
|
|
197
|
-
}
|
|
198
|
-
getElementsByClassName(className) {
|
|
199
|
-
const results = [];
|
|
200
|
-
const targetClasses = className.split(/\s+/).filter(Boolean);
|
|
201
|
-
const walk = (node) => {
|
|
202
|
-
for (const child of node[childNodesList]) {
|
|
203
|
-
if (child[nodeType] === NodeType.ELEMENT_NODE) {
|
|
204
|
-
const el = child;
|
|
205
|
-
const elClasses = el.className.split(/\s+/);
|
|
206
|
-
if (targetClasses.every((c) => elClasses.includes(c))) {
|
|
207
|
-
results.push(el);
|
|
208
|
-
}
|
|
209
|
-
walk(el);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
walk(this);
|
|
214
|
-
return results;
|
|
215
|
-
}
|
|
216
|
-
cloneNode(deep = false) {
|
|
217
|
-
const clone = super.cloneNode(false);
|
|
218
|
-
clone[tagName] = this[tagName];
|
|
219
|
-
clone[localName] = this[localName];
|
|
220
|
-
clone[namespaceURI] = this[namespaceURI];
|
|
221
|
-
clone[prefix] = this[prefix];
|
|
222
|
-
for (const attr of this[attributes]) {
|
|
223
|
-
clone.setAttributeNS(attr.namespaceURI, attr.name, attr.value);
|
|
224
|
-
}
|
|
225
|
-
if (deep) {
|
|
226
|
-
for (const child of this[childNodesList]) {
|
|
227
|
-
clone.appendChild(child.cloneNode(true));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return clone;
|
|
231
|
-
}
|
|
232
|
-
setPointerCapture(pointerId) {
|
|
233
|
-
this._pointerCaptures.add(pointerId);
|
|
234
|
-
}
|
|
235
|
-
releasePointerCapture(pointerId) {
|
|
236
|
-
this._pointerCaptures.delete(pointerId);
|
|
237
|
-
}
|
|
238
|
-
hasPointerCapture(pointerId) {
|
|
239
|
-
return this._pointerCaptures.has(pointerId);
|
|
240
|
-
}
|
|
241
|
-
get [(_PS$tagName = tagName, _PS$localName = localName, _PS$namespaceURI = namespaceURI, _PS$prefix = prefix, _PS$attributes = attributes, _PS$propertyEventList = propertyEventListeners, Symbol.toStringTag)]() {
|
|
242
|
-
return "Element";
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
//#endregion
|
|
247
|
-
export { Element };
|
|
1
|
+
import{attributes as e,childNodesList as t,elementChildren as n,localName as r,namespaceURI as i,nodeType as a,parentNode as o,prefix as s,propertyEventListeners as c,tagName as l}from"./property-symbol.js";import{NodeType as u}from"./node-type.js";import{Node as d}from"./node.js";import{NamespaceURI as f}from"./namespace-uri.js";import{NamedNodeMap as p}from"./named-node-map.js";let m,h,g,_,v,y;var b=class extends d{constructor(){super(),this[m]=``,this[h]=``,this[g]=f.html,this[_]=null,this[v]=new p(this),this[y]=new Map,this._pointerCaptures=new Set,this[a]=u.ELEMENT_NODE}get tagName(){return this[l]}get localName(){return this[r]}get namespaceURI(){return this[i]}get prefix(){return this[s]}get nodeName(){return this[l]}get attributes(){return this[e]}get id(){return this.getAttribute(`id`)??``}set id(e){this.setAttribute(`id`,e)}get className(){return this.getAttribute(`class`)??``}set className(e){this.setAttribute(`class`,e)}get children(){return this[n]}get childElementCount(){return this[n].length}get firstElementChild(){return this[n][0]??null}get lastElementChild(){let e=this[n];return e[e.length-1]??null}get previousElementSibling(){let e=this[o];if(!e)return null;let t=e[n],r=t.indexOf(this);return r>0?t[r-1]:null}get nextElementSibling(){let e=this[o];if(!e)return null;let t=e[n],r=t.indexOf(this);return r!==-1&&r<t.length-1?t[r+1]:null}get textContent(){let e=``;for(let n of this[t])n.textContent!==null&&(e+=n.textContent);return e}set textContent(e){let n=this[t];for(;n.length>0;)this.removeChild(n[0])}getAttribute(t){let n=this[e].getNamedItem(t);return n?n.value:null}getAttributeNS(t,n){let r=this[e].getNamedItemNS(t,n);return r?r.value:null}setAttribute(t,n){this[e]._setNamedItem(t,String(n))}setAttributeNS(t,n,r){let i=t===``?null:t,a=n.split(`:`),o=a.length>1?a[0]:null;this[e]._setNamedItem(n,String(r),i,o)}removeAttribute(t){this[e]._removeNamedItem(t)}removeAttributeNS(t,n){let r=t===``?null:t;this[e]._removeNamedItemNS(r,n)}hasAttribute(t){return this[e].getNamedItem(t)!==null}hasAttributeNS(t,n){return this[e].getNamedItemNS(t,n)!==null}getAttributeNode(t){return this[e].getNamedItem(t)}setAttributeNode(t){return this[e].setNamedItem(t)}removeAttributeNode(t){let n=this[e].getNamedItem(t.name);if(!n)throw new DOMException(`Failed to execute 'removeAttributeNode' on 'Element': The attribute is not owned by this element.`,`NotFoundError`);return this[e].removeNamedItem(n.name),n}toggleAttribute(e,t){return t===void 0?this.hasAttribute(e)?(this.removeAttribute(e),!1):(this.setAttribute(e,``),!0):t?(this.setAttribute(e,``),!0):(this.removeAttribute(e),!1)}hasAttributes(){return this[e].length>0}dispatchEvent(e){let t=super.dispatchEvent(e),n=this[c].get(`on`+e.type);return typeof n==`function`&&n.call(this,e),t}querySelector(e){return null}querySelectorAll(e){return[]}matches(e){return!1}closest(e){return null}getElementsByTagName(e){let n=[],r=e.toUpperCase(),i=o=>{for(let s of o[t])if(s[a]===u.ELEMENT_NODE){let t=s;(e===`*`||t[l]===r)&&n.push(t),i(t)}};return i(this),n}getElementsByClassName(e){let n=[],r=e.split(/\s+/).filter(Boolean),i=e=>{for(let o of e[t])if(o[a]===u.ELEMENT_NODE){let e=o,t=e.className.split(/\s+/);r.every(e=>t.includes(e))&&n.push(e),i(e)}};return i(this),n}cloneNode(n=!1){let a=super.cloneNode(!1);a[l]=this[l],a[r]=this[r],a[i]=this[i],a[s]=this[s];for(let t of this[e])a.setAttributeNS(t.namespaceURI,t.name,t.value);if(n)for(let e of this[t])a.appendChild(e.cloneNode(!0));return a}setPointerCapture(e){this._pointerCaptures.add(e)}releasePointerCapture(e){this._pointerCaptures.delete(e)}hasPointerCapture(e){return this._pointerCaptures.has(e)}get[(m=l,h=r,g=i,_=s,v=e,y=c,Symbol.toStringTag)](){return`Element`}};export{b as Element};
|
package/lib/esm/font-face.js
CHANGED
|
@@ -1,95 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var FontFace = class {
|
|
3
|
-
constructor(family, source, _descriptors) {
|
|
4
|
-
this.status = "unloaded";
|
|
5
|
-
this.display = "auto";
|
|
6
|
-
this.style = "normal";
|
|
7
|
-
this.weight = "normal";
|
|
8
|
-
this.stretch = "normal";
|
|
9
|
-
this.unicodeRange = "U+0-10FFFF";
|
|
10
|
-
this.variant = "normal";
|
|
11
|
-
this.featureSettings = "normal";
|
|
12
|
-
this.family = family;
|
|
13
|
-
this.source = typeof source === "string" ? source : "[binary]";
|
|
14
|
-
this.loaded = Promise.resolve(this);
|
|
15
|
-
}
|
|
16
|
-
_extractFilePath() {
|
|
17
|
-
const m = this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);
|
|
18
|
-
if (!m) return null;
|
|
19
|
-
return m[1].replace(/^file:\/\//, "");
|
|
20
|
-
}
|
|
21
|
-
async load() {
|
|
22
|
-
this.status = "loading";
|
|
23
|
-
const filePath = this._extractFilePath();
|
|
24
|
-
if (filePath) {
|
|
25
|
-
try {
|
|
26
|
-
const { default: PangoCairo } = await import("gi://PangoCairo?version=1.0");
|
|
27
|
-
PangoCairo.font_map_get_default().add_font_file(filePath);
|
|
28
|
-
} catch {}
|
|
29
|
-
}
|
|
30
|
-
this.status = "loaded";
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* FontFaceSet — tracks loaded FontFace objects and exposes them to consumers.
|
|
36
|
-
*
|
|
37
|
-
* Intentionally does NOT extend EventTarget. The dom-elements /register module
|
|
38
|
-
* runs before dom-events/register in the inject order, so EventTarget may not
|
|
39
|
-
* yet exist when this class is defined at module load time. All event methods
|
|
40
|
-
* are provided as no-ops; consumers that call addEventListener('loadingdone')
|
|
41
|
-
* etc. will silently receive nothing.
|
|
42
|
-
*/
|
|
43
|
-
var FontFaceSet = class {
|
|
44
|
-
constructor() {
|
|
45
|
-
this.status = "loaded";
|
|
46
|
-
this.ready = Promise.resolve(this);
|
|
47
|
-
this._faces = new Set();
|
|
48
|
-
}
|
|
49
|
-
addEventListener(_type, _listener) {}
|
|
50
|
-
removeEventListener(_type, _listener) {}
|
|
51
|
-
dispatchEvent(_event) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
add(face) {
|
|
55
|
-
this._faces.add(face);
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
delete(face) {
|
|
59
|
-
return this._faces.delete(face);
|
|
60
|
-
}
|
|
61
|
-
clear() {
|
|
62
|
-
this._faces.clear();
|
|
63
|
-
}
|
|
64
|
-
has(face) {
|
|
65
|
-
return this._faces.has(face);
|
|
66
|
-
}
|
|
67
|
-
check(_font, _text) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
load(_font, _text) {
|
|
71
|
-
return Promise.resolve([]);
|
|
72
|
-
}
|
|
73
|
-
forEach(callback) {
|
|
74
|
-
this._faces.forEach((f) => callback(f, f, this));
|
|
75
|
-
}
|
|
76
|
-
values() {
|
|
77
|
-
return this._faces.values();
|
|
78
|
-
}
|
|
79
|
-
keys() {
|
|
80
|
-
return this._faces.values();
|
|
81
|
-
}
|
|
82
|
-
entries() {
|
|
83
|
-
const faces = Array.from(this._faces);
|
|
84
|
-
return faces.map((f) => [f, f])[Symbol.iterator]();
|
|
85
|
-
}
|
|
86
|
-
[Symbol.iterator]() {
|
|
87
|
-
return this._faces[Symbol.iterator]();
|
|
88
|
-
}
|
|
89
|
-
get size() {
|
|
90
|
-
return this._faces.size;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
//#endregion
|
|
95
|
-
export { FontFace, FontFaceSet };
|
|
1
|
+
var e=class{constructor(e,t,n){this.status=`unloaded`,this.display=`auto`,this.style=`normal`,this.weight=`normal`,this.stretch=`normal`,this.unicodeRange=`U+0-10FFFF`,this.variant=`normal`,this.featureSettings=`normal`,this.family=e,this.source=typeof t==`string`?t:`[binary]`,this.loaded=Promise.resolve(this)}_extractFilePath(){let e=this.source.match(/url\s*\(\s*["']?(file:\/\/\/[^"')]+)["']?\s*\)/i);return e?e[1].replace(/^file:\/\//,``):null}async load(){this.status=`loading`;let e=this._extractFilePath();if(e)try{let{default:t}=await import(`gi://PangoCairo?version=1.0`);t.font_map_get_default().add_font_file(e)}catch{}return this.status=`loaded`,this}},t=class{constructor(){this.status=`loaded`,this.ready=Promise.resolve(this),this._faces=new Set}addEventListener(e,t){}removeEventListener(e,t){}dispatchEvent(e){return!0}add(e){return this._faces.add(e),this}delete(e){return this._faces.delete(e)}clear(){this._faces.clear()}has(e){return this._faces.has(e)}check(e,t){return!1}load(e,t){return Promise.resolve([])}forEach(e){this._faces.forEach(t=>e(t,t,this))}values(){return this._faces.values()}keys(){return this._faces.values()}entries(){return Array.from(this._faces).map(e=>[e,e])[Symbol.iterator]()}[Symbol.iterator](){return this._faces[Symbol.iterator]()}get size(){return this._faces.size}};export{e as FontFace,t as FontFaceSet};
|
package/lib/esm/gst-time.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const NS_PER_SECOND = 1e9;
|
|
3
|
-
/**
|
|
4
|
-
* Convert seconds (number) to GStreamer nanoseconds (bigint).
|
|
5
|
-
* Rounds to the nearest nanosecond to avoid floating-point drift over
|
|
6
|
-
* repeated back-and-forth conversions.
|
|
7
|
-
*/
|
|
8
|
-
function secondsToGstTime(seconds) {
|
|
9
|
-
return BigInt(Math.round(seconds * NS_PER_SECOND));
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Convert GStreamer nanoseconds to seconds (number).
|
|
13
|
-
* Accepts both `bigint` (the runtime type from GStreamer queries) and `number`
|
|
14
|
-
* (what the `@girs/gst-1.0` typings currently declare — a known GIR bug for
|
|
15
|
-
* `gint64` return values in `query_position` / `query_duration`).
|
|
16
|
-
*/
|
|
17
|
-
function gstTimeToSeconds(nanoseconds) {
|
|
18
|
-
return Number(nanoseconds) / NS_PER_SECOND;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { gstTimeToSeconds, secondsToGstTime };
|
|
1
|
+
const e=1e9;function t(t){return BigInt(Math.round(t*e))}function n(t){return Number(t)/e}export{n as gstTimeToSeconds,t as secondsToGstTime};
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/html-canvas-element.ts
|
|
4
|
-
/**
|
|
5
|
-
* HTMLCanvasElement base class.
|
|
6
|
-
*
|
|
7
|
-
* This is a DOM-spec-compliant stub. The GTK-backed implementation lives in
|
|
8
|
-
* `@gjsify/webgl` and extends this class, overriding `getContext()`.
|
|
9
|
-
*
|
|
10
|
-
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement
|
|
11
|
-
*/
|
|
12
|
-
var HTMLCanvasElement = class HTMLCanvasElement extends HTMLElement {
|
|
13
|
-
constructor(..._args) {
|
|
14
|
-
super(..._args);
|
|
15
|
-
this.oncontextlost = null;
|
|
16
|
-
this.oncontextrestored = null;
|
|
17
|
-
this.onwebglcontextcreationerror = null;
|
|
18
|
-
this.onwebglcontextlost = null;
|
|
19
|
-
this.onwebglcontextrestored = null;
|
|
20
|
-
}
|
|
21
|
-
static {
|
|
22
|
-
this._contextFactories = new Map();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Register a rendering context factory for a given context type.
|
|
26
|
-
* Called by packages like @gjsify/canvas2d and @gjsify/webgl to plug in their implementations.
|
|
27
|
-
*/
|
|
28
|
-
static registerContextFactory(contextId, factory) {
|
|
29
|
-
HTMLCanvasElement._contextFactories.set(contextId, factory);
|
|
30
|
-
}
|
|
31
|
-
/** Returns the width of the canvas element. Default: 300. */
|
|
32
|
-
get width() {
|
|
33
|
-
const w = this.getAttribute("width");
|
|
34
|
-
return w !== null ? Number(w) : 300;
|
|
35
|
-
}
|
|
36
|
-
set width(value) {
|
|
37
|
-
this.setAttribute("width", String(value));
|
|
38
|
-
}
|
|
39
|
-
/** Returns the height of the canvas element. Default: 150. */
|
|
40
|
-
get height() {
|
|
41
|
-
const h = this.getAttribute("height");
|
|
42
|
-
return h !== null ? Number(h) : 150;
|
|
43
|
-
}
|
|
44
|
-
set height(value) {
|
|
45
|
-
this.setAttribute("height", String(value));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns a rendering context.
|
|
49
|
-
* Checks the static context factory registry for a matching factory.
|
|
50
|
-
* Subclasses (e.g. @gjsify/webgl) may override and fall through via super.getContext().
|
|
51
|
-
*/
|
|
52
|
-
getContext(contextId, options) {
|
|
53
|
-
const factory = HTMLCanvasElement._contextFactories.get(contextId);
|
|
54
|
-
if (factory) return factory(this, options);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
/** Returns a data URL representing the canvas image. Delegates to the active 2D context if available. */
|
|
58
|
-
toDataURL(type, quality) {
|
|
59
|
-
const ctx = this.getContext("2d");
|
|
60
|
-
if (ctx && typeof ctx._toDataURL === "function") return ctx._toDataURL(type, quality);
|
|
61
|
-
return "";
|
|
62
|
-
}
|
|
63
|
-
/** Converts the canvas to a Blob and passes it to the callback. Delegates to the active 2D context if available. */
|
|
64
|
-
toBlob(callback, type, quality) {
|
|
65
|
-
const dataUrl = this.toDataURL(type, quality);
|
|
66
|
-
if (!dataUrl) {
|
|
67
|
-
callback(null);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const [header, b64] = dataUrl.split(",");
|
|
71
|
-
const mime = header.split(":")[1].split(";")[0];
|
|
72
|
-
const bytes = atob(b64);
|
|
73
|
-
const arr = new Uint8Array(bytes.length);
|
|
74
|
-
for (let i = 0; i < bytes.length; i++) arr[i] = bytes.charCodeAt(i);
|
|
75
|
-
callback(new Blob([arr], { type: mime }));
|
|
76
|
-
}
|
|
77
|
-
/** Returns a MediaStream capturing the canvas. Stub — returns empty object. */
|
|
78
|
-
captureStream(_frameRequestRate) {
|
|
79
|
-
return {};
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { HTMLCanvasElement };
|
|
1
|
+
import{HTMLElement as e}from"./html-element.js";var t=class t extends e{constructor(...e){super(...e),this.oncontextlost=null,this.oncontextrestored=null,this.onwebglcontextcreationerror=null,this.onwebglcontextlost=null,this.onwebglcontextrestored=null}static{this._contextFactories=new Map}static registerContextFactory(e,n){t._contextFactories.set(e,n)}get width(){let e=this.getAttribute(`width`);return e===null?300:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get height(){let e=this.getAttribute(`height`);return e===null?150:Number(e)}set height(e){this.setAttribute(`height`,String(e))}getContext(e,n){let r=t._contextFactories.get(e);return r?r(this,n):null}toDataURL(e,t){let n=this.getContext(`2d`);return n&&typeof n._toDataURL==`function`?n._toDataURL(e,t):``}toBlob(e,t,n){let r=this.toDataURL(t,n);if(!r){e(null);return}let[i,a]=r.split(`,`),o=i.split(`:`)[1].split(`;`)[0],s=atob(a),c=new Uint8Array(s.length);for(let e=0;e<s.length;e++)c[e]=s.charCodeAt(e);e(new Blob([c],{type:o}))}captureStream(e){return{}}};export{t as HTMLCanvasElement};
|