@gjsify/dom-elements 0.4.21 → 0.4.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{localName as e,namespaceURI as t,tagName as n}from"./property-symbol.js";import{NamespaceURI as r}from"./namespace-uri.js";import{HTMLElement as i}from"./html-element.js";import{Event as a}from"@gjsify/dom-events";import o from"@girs/glib-2.0";import s from"@girs/gio-2.0";import c from"@girs/gdkpixbuf-2.0";import l from"system";var HTMLImageElement=class extends i{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[n]=`IMG`,this[e]=`img`,this[t]=r.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let t=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let n=e.indexOf(`,`);if(n===-1){this._complete=!0,this.dispatchEvent(new a(`error`));return}let r=e.slice(5,n),i=e.slice(n+1),l=r.includes(`;base64`);try{let e;e=l?o.base64_decode(i):new TextEncoder().encode(decodeURIComponent(i));let n=o.Bytes.new(e),r=s.MemoryInputStream.new_from_bytes(n);this._pixbuf=c.Pixbuf.new_from_stream(r,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&console.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new a(`load`))}catch(e){t&&console.warn(`[img] error data:: ${e
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{localName as e,namespaceURI as t,tagName as n}from"./property-symbol.js";import{NamespaceURI as r}from"./namespace-uri.js";import{HTMLElement as i}from"./html-element.js";import{Event as a}from"@gjsify/dom-events";import o from"@girs/glib-2.0";import s from"@girs/gio-2.0";import c from"@girs/gdkpixbuf-2.0";import l from"system";var HTMLImageElement=class extends i{constructor(){super(),this._complete=!1,this._naturalHeight=0,this._naturalWidth=0,this[n]=`IMG`,this[e]=`img`,this[t]=r.html}get complete(){return this._complete}get naturalHeight(){return this._naturalHeight}get naturalWidth(){return this._naturalWidth}get currentSrc(){return this.src}get x(){return 0}get y(){return 0}get alt(){return this.getAttribute(`alt`)??``}set alt(e){this.setAttribute(`alt`,e)}get crossOrigin(){return this.getAttribute(`crossorigin`)}set crossOrigin(e){e===null?this.removeAttribute(`crossorigin`):this.setAttribute(`crossorigin`,e)}get decoding(){return this.getAttribute(`decoding`)??`auto`}set decoding(e){this.setAttribute(`decoding`,e)}get loading(){let e=this.getAttribute(`loading`);return e===`lazy`||e===`eager`?e:`auto`}set loading(e){this.setAttribute(`loading`,e)}get referrerPolicy(){return this.getAttribute(`referrerpolicy`)??``}set referrerPolicy(e){this.setAttribute(`referrerpolicy`,e)}get sizes(){return this.getAttribute(`sizes`)??``}set sizes(e){this.setAttribute(`sizes`,e)}get src(){return this.getAttribute(`src`)??``}set src(e){this.setAttribute(`src`,e);let t=globalThis.__GJSIFY_DEBUG_IMG===!0;if(e.startsWith(`data:`)){let n=e.indexOf(`,`);if(n===-1){this._complete=!0,this.dispatchEvent(new a(`error`));return}let r=e.slice(5,n),i=e.slice(n+1),l=r.includes(`;base64`);try{let e;e=l?o.base64_decode(i):new TextEncoder().encode(decodeURIComponent(i));let n=o.Bytes.new(e),r=s.MemoryInputStream.new_from_bytes(n);this._pixbuf=c.Pixbuf.new_from_stream(r,null),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&console.log(`[img] ok data: (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new a(`load`))}catch(e){t&&console.warn(`[img] error data:: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new a(`error`))}return}let n;if(e.startsWith(`file://`))n=o.filename_from_uri(e)[0];else if(e.startsWith(`http://`)||e.startsWith(`https://`)){this._complete=!0,this.dispatchEvent(new a(`error`));return}else{let t=o.path_get_dirname(l.programInvocationName);n=o.build_filenamev([t,e])}try{t&&console.log(`[img] load ${n}`),this._pixbuf=c.Pixbuf.new_from_file(n),this._naturalWidth=this._pixbuf.get_width(),this._naturalHeight=this._pixbuf.get_height(),this._complete=!0,t&&console.log(`[img] ok ${n} (${this._naturalWidth}x${this._naturalHeight})`),this.dispatchEvent(new a(`load`))}catch(e){t&&console.warn(`[img] error ${n}: ${e instanceof Error?e.message:String(e)}`),this._complete=!0,this.dispatchEvent(new a(`error`))}}get srcset(){return this.getAttribute(`srcset`)??``}set srcset(e){this.setAttribute(`srcset`,e)}get useMap(){return this.getAttribute(`usemap`)??``}set useMap(e){this.setAttribute(`usemap`,e)}get height(){if(this._pixbuf)return this._pixbuf.get_height();let e=this.getAttribute(`height`);return e===null?0:Number(e)}set height(e){this.setAttribute(`height`,String(e))}get width(){if(this._pixbuf)return this._pixbuf.get_width();let e=this.getAttribute(`width`);return e===null?0:Number(e)}set width(e){this.setAttribute(`width`,String(e))}get isMap(){return this.hasAttribute(`ismap`)}set isMap(e){e?this.setAttribute(`ismap`,``):this.removeAttribute(`ismap`)}decode(){return Promise.resolve()}cloneNode(e=!1){return super.cloneNode(e)}getImageData(){if(!this._pixbuf)return null;let e=this._pixbuf.get_has_alpha()?this._pixbuf:this._pixbuf.add_alpha(!1,0,0,0)??this._pixbuf;return{colorSpace:`srgb`,data:new Uint8ClampedArray(e.get_pixels()),height:e.get_height(),width:e.get_width()}}isPixbuf(){return!!this._pixbuf}get[Symbol.toStringTag](){return`HTMLImageElement`}};export{HTMLImageElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{localName as e,namespaceURI as t,tagName as n}from"./property-symbol.js";import{NamespaceURI as r}from"./namespace-uri.js";import{HTMLMediaElement as i}from"./html-media-element.js";import{gstTimeToSeconds as a,secondsToGstTime as o}from"./gst-time.js";import{Event as s}from"@gjsify/dom-events";var HTMLVideoElement=class extends i{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[n]=`VIDEO`,this[e]=`video`,this[t]=r.html;let i=this;Object.defineProperty(this
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{localName as e,namespaceURI as t,tagName as n}from"./property-symbol.js";import{NamespaceURI as r}from"./namespace-uri.js";import{HTMLMediaElement as i}from"./html-media-element.js";import{gstTimeToSeconds as a,secondsToGstTime as o}from"./gst-time.js";import{Event as s}from"@gjsify/dom-events";var HTMLVideoElement=class extends i{constructor(){super(),this._pipeline=null,this._videoWidth=0,this._videoHeight=0,this.poster=``,this[n]=`VIDEO`,this[e]=`video`,this[t]=r.html;let i=this;Object.defineProperty(this,"paused",{get(){if(!i._pipeline)return!0;let[,e]=i._pipeline.get_state(0n);return e!==4},configurable:!0,enumerable:!0}),Object.defineProperty(this,"currentTime",{get(){if(!i._pipeline)return 0;let[e,t]=i._pipeline.query_position(3);return e?a(t):0},set(e){i._pipeline?.seek(1,3,5,1,o(e),0,-1n)},configurable:!0,enumerable:!0}),Object.defineProperty(this,"duration",{get(){if(!i._pipeline)return NaN;let[e,t]=i._pipeline.query_duration(3);return e&&Number(t)>0?a(t):NaN},configurable:!0,enumerable:!0}),Object.defineProperty(this,"volume",{get(){return i._playbin()?.volume??1},set(e){let t=i._playbin();t&&(t.volume=Math.max(0,Math.min(1,e)))},configurable:!0,enumerable:!0}),Object.defineProperty(this,"muted",{get(){return i._playbin()?.mute??!1},set(e){let t=i._playbin();t&&(t.mute=e)},configurable:!0,enumerable:!0})}async play(){this._pipeline?.set_state(4),this.dispatchEvent(new s(`play`)),this.dispatchEvent(new s(`playing`))}pause(){this._pipeline?.set_state(3),this.dispatchEvent(new s(`pause`))}get videoWidth(){return this._videoWidth}set videoWidth(e){this._videoWidth=e}get videoHeight(){return this._videoHeight}set videoHeight(e){this._videoHeight=e}get[Symbol.toStringTag](){return`HTMLVideoElement`}_playbin(){return this._pipeline?.get_by_name(`playbin`)??null}};export{HTMLVideoElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as e}from"../html-canvas-element.js";import{DOMMatrix as t,DOMMatrixReadOnly as n}from"../dom-matrix.js";import{defineGlobal as r}from"./helpers.js";import{CanvasRenderingContext2D as i}from"@gjsify/canvas2d-core";r(`HTMLCanvasElement`,e),r(`CanvasRenderingContext2D`,i),r(`DOMMatrix`,t),r(`DOMMatrixReadOnly`,n);const a=Symbol.for(`gjsify_canvas2d_context`);e.registerContextFactory(`2d`,(e,t)=>{let n=e[a];if(
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as e}from"../html-canvas-element.js";import{DOMMatrix as t,DOMMatrixReadOnly as n}from"../dom-matrix.js";import{defineGlobal as r}from"./helpers.js";import{CanvasRenderingContext2D as i}from"@gjsify/canvas2d-core";r(`HTMLCanvasElement`,e),r(`CanvasRenderingContext2D`,i),r(`DOMMatrix`,t),r(`DOMMatrixReadOnly`,n);const a=Symbol.for(`gjsify_canvas2d_context`);e.registerContextFactory(`2d`,(e,t)=>{let n=e,r=n[a];if(r)return r;let o=new i(e,t);return n[a]=o,o});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{Comment as e}from"../comment.js";import{Text as t}from"../text.js";import{DocumentFragment as n}from"../document-fragment.js";import{document as r}from"../document.js";import{DOMTokenList as i}from"../dom-token-list.js";import{defineGlobal as a,defineGlobalIfMissing as o}from"./helpers.js";import{EventTarget as s}from"@gjsify/dom-events";a(`Text`,t),a(`Comment`,e),a(`DocumentFragment`,n),a(`DOMTokenList`,i),a(`document`,r),o(`self`,globalThis);var Window=class{};
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Comment as e}from"../comment.js";import{Text as t}from"../text.js";import{DocumentFragment as n}from"../document-fragment.js";import{document as r}from"../document.js";import{DOMTokenList as i}from"../dom-token-list.js";import{defineGlobal as a,defineGlobalIfMissing as o}from"./helpers.js";import{EventTarget as s}from"@gjsify/dom-events";a(`Text`,t),a(`Comment`,e),a(`DocumentFragment`,n),a(`DOMTokenList`,i),a(`document`,r),o(`self`,globalThis);var Window=class{};o(`Window`,Window),o(`window`,globalThis),o(`focus`,()=>{}),o(`blur`,()=>{});{let e=globalThis;if(typeof e.addEventListener!=`function`){let t=new s;e.__gjsify_globalEventTarget=t,e.addEventListener=(e,n,r)=>t.addEventListener(e,n,r),e.removeEventListener=(e,n,r)=>t.removeEventListener(e,n,r),e.dispatchEvent=e=>t.dispatchEvent(e)}}o(`devicePixelRatio`,1),o(`scrollX`,0),o(`scrollY`,0),o(`pageXOffset`,0),o(`pageYOffset`,0),o(`alert`,(...e)=>console.error(`alert:`,...e)),globalThis.top===void 0&&Object.defineProperty(globalThis,"top",{get:()=>globalThis,configurable:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FontFace as e,FontFaceSet as t}from"../font-face.js";import{defineGlobalIfMissing as n}from"./helpers.js";n(`FontFace`,e),
|
|
1
|
+
import{FontFace as e,FontFaceSet as t}from"../font-face.js";import{defineGlobalIfMissing as n}from"./helpers.js";const r=globalThis;n(`FontFace`,e),r.FontFace===void 0&&(r.FontFace=e);const i=r.document;i&&i.fonts===void 0&&Object.defineProperty(i,"fonts",{value:new t,configurable:!0,writable:!0});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/dom-elements",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22",
|
|
4
4
|
"description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -65,19 +65,19 @@
|
|
|
65
65
|
"node"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@girs/gdkpixbuf-2.0": "2.0.0-4.0.
|
|
69
|
-
"@girs/gjs": "4.0.
|
|
70
|
-
"@girs/glib-2.0": "2.88.0-4.0.
|
|
71
|
-
"@gjsify/abort-controller": "^0.4.
|
|
72
|
-
"@gjsify/canvas2d-core": "^0.4.
|
|
73
|
-
"@gjsify/dom-events": "^0.4.
|
|
74
|
-
"@gjsify/fetch": "^0.4.
|
|
68
|
+
"@girs/gdkpixbuf-2.0": "2.0.0-4.0.1",
|
|
69
|
+
"@girs/gjs": "4.0.1",
|
|
70
|
+
"@girs/glib-2.0": "2.88.0-4.0.1",
|
|
71
|
+
"@gjsify/abort-controller": "^0.4.22",
|
|
72
|
+
"@gjsify/canvas2d-core": "^0.4.22",
|
|
73
|
+
"@gjsify/dom-events": "^0.4.22",
|
|
74
|
+
"@gjsify/fetch": "^0.4.22"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@girs/gst-1.0": "1.28.1-4.0.
|
|
78
|
-
"@gjsify/cli": "^0.4.
|
|
79
|
-
"@gjsify/unit": "^0.4.
|
|
80
|
-
"@types/node": "^25.
|
|
77
|
+
"@girs/gst-1.0": "1.28.1-4.0.1",
|
|
78
|
+
"@gjsify/cli": "^0.4.22",
|
|
79
|
+
"@gjsify/unit": "^0.4.22",
|
|
80
|
+
"@types/node": "^25.9.1",
|
|
81
81
|
"typescript": "^6.0.3"
|
|
82
82
|
}
|
|
83
83
|
}
|