@gjsify/dom-elements 0.45.0 → 0.46.0

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 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
+ 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"gi://GLib?version=2.0";import s from"gi://Gio?version=2.0";import c from"gi://GdkPixbuf?version=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,4 +1,4 @@
1
- import GdkPixbuf from '@girs/gdkpixbuf-2.0';
1
+ import GdkPixbuf from 'gi://GdkPixbuf?version=2.0';
2
2
  import { HTMLElement } from './html-element.js';
3
3
  import type { ImageData } from './types/index.js';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/dom-elements",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "DOM element hierarchy (Node, Element, HTMLElement, HTMLImageElement) for GJS",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -68,19 +68,19 @@
68
68
  "node"
69
69
  ],
70
70
  "dependencies": {
71
- "@girs/gdkpixbuf-2.0": "^4.1.0",
72
- "@girs/gjs": "^4.1.0",
73
- "@girs/glib-2.0": "^4.1.0",
74
- "@gjsify/abort-controller": "^0.45.0",
75
- "@gjsify/canvas2d-core": "^0.45.0",
76
- "@gjsify/dom-events": "^0.45.0",
77
- "@gjsify/domparser": "^0.45.0",
78
- "@gjsify/fetch": "^0.45.0"
71
+ "@girs/gdkpixbuf-2.0": "4.6.0",
72
+ "@girs/gjs": "4.6.0",
73
+ "@girs/glib-2.0": "4.6.0",
74
+ "@gjsify/abort-controller": "^0.46.0",
75
+ "@gjsify/canvas2d-core": "^0.46.0",
76
+ "@gjsify/dom-events": "^0.46.0",
77
+ "@gjsify/domparser": "^0.46.0",
78
+ "@gjsify/fetch": "^0.46.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@girs/gst-1.0": "^4.1.0",
82
- "@gjsify/cli": "^0.45.0",
83
- "@gjsify/unit": "^0.45.0",
81
+ "@girs/gst-1.0": "4.6.0",
82
+ "@gjsify/cli": "^0.46.0",
83
+ "@gjsify/unit": "^0.46.0",
84
84
  "@types/node": "^25.9.2",
85
85
  "typescript": "^6.0.3"
86
86
  },