gnim 1.4.0 → 1.5.1
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/dist/gnim.gresource +0 -0
- package/dist/gnome/jsx-runtime.ts +18 -2
- package/dist/gtk3/jsx-runtime.ts +17 -8
- package/dist/gtk4/jsx-runtime.ts +22 -8
- package/dist/index.ts +9 -1
- package/dist/jsx/jsx.ts +30 -0
- package/dist/resource.xml +1 -15
- package/package.json +2 -4
- package/dist/gtk3/style.ts +0 -35
- package/dist/gtk4/style.ts +0 -35
package/dist/gnim.gresource
CHANGED
|
Binary file
|
|
@@ -2,9 +2,20 @@ import Clutter from "gi://Clutter"
|
|
|
2
2
|
import St from "gi://St"
|
|
3
3
|
import GObject from "gi://GObject"
|
|
4
4
|
import { configue } from "../jsx/env.js"
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
onCleanup,
|
|
7
|
+
getType,
|
|
8
|
+
addChild as _add,
|
|
9
|
+
removeChild as _remove,
|
|
10
|
+
Accessor,
|
|
11
|
+
Fragment,
|
|
12
|
+
} from "../index.js"
|
|
13
|
+
|
|
14
|
+
function add(parent: GObject.Object, child: GObject.Object, index: number) {
|
|
15
|
+
if (_add in parent && typeof parent[_add] === "function") {
|
|
16
|
+
parent[_add](child, getType(child), index)
|
|
17
|
+
}
|
|
6
18
|
|
|
7
|
-
function add(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
8
19
|
if (parent instanceof Clutter.Actor) {
|
|
9
20
|
if (child instanceof Clutter.Action) {
|
|
10
21
|
return parent.add_action(child)
|
|
@@ -24,6 +35,11 @@ function add(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
function remove(parent: GObject.Object, child: GObject.Object) {
|
|
38
|
+
if (_remove in parent && typeof parent[_remove] === "function") {
|
|
39
|
+
parent[_remove](child)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
if (child instanceof Clutter.Actor && parent instanceof Clutter.Actor) {
|
|
28
44
|
return parent.remove_child(child)
|
|
29
45
|
}
|
package/dist/gtk3/jsx-runtime.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import Gtk from "gi://Gtk?version=3.0"
|
|
2
2
|
import GObject from "gi://GObject"
|
|
3
3
|
import { configue } from "../jsx/env.js"
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getType,
|
|
6
|
+
onCleanup,
|
|
7
|
+
addChild as _add,
|
|
8
|
+
removeChild as _remove,
|
|
9
|
+
Accessor,
|
|
10
|
+
Fragment,
|
|
11
|
+
} from "../index.js"
|
|
5
12
|
|
|
6
13
|
const dummyBuilder = new Gtk.Builder()
|
|
7
14
|
|
|
@@ -11,13 +18,12 @@ function add(parent: Gtk.Buildable, child: GObject.Object, _: number) {
|
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
function specialAdd(parent: GObject.Object, child: GObject.Object, index: number) {
|
|
22
|
+
if (_add in parent && typeof parent[_add] === "function") {
|
|
23
|
+
parent[_add](child, getType(child), index)
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
18
26
|
|
|
19
|
-
function specialAdd(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
20
|
-
// TODO: add any other special case
|
|
21
27
|
if (
|
|
22
28
|
child instanceof Gtk.Adjustment &&
|
|
23
29
|
"set_adjustment" in parent &&
|
|
@@ -52,7 +58,10 @@ function specialAdd(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
function remove(parent: GObject.Object, child: GObject.Object) {
|
|
55
|
-
if (
|
|
61
|
+
if (_remove in parent && typeof parent[_remove] === "function") {
|
|
62
|
+
parent[_remove](child)
|
|
63
|
+
return
|
|
64
|
+
}
|
|
56
65
|
|
|
57
66
|
if (parent instanceof Gtk.Container && child instanceof Gtk.Widget) {
|
|
58
67
|
return parent.remove(child)
|
package/dist/gtk4/jsx-runtime.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import Gtk from "gi://Gtk?version=4.0"
|
|
2
2
|
import Gio from "gi://Gio?version=2.0"
|
|
3
3
|
import GObject from "gi://GObject"
|
|
4
|
-
import { getType, onCleanup, Accessor, Fragment } from "../index.js"
|
|
5
4
|
import { configue } from "../jsx/env.js"
|
|
5
|
+
import {
|
|
6
|
+
getType,
|
|
7
|
+
onCleanup,
|
|
8
|
+
addChild as _add,
|
|
9
|
+
removeChild as _remove,
|
|
10
|
+
Accessor,
|
|
11
|
+
Fragment,
|
|
12
|
+
} from "../index.js"
|
|
6
13
|
|
|
7
14
|
const dummyBuilder = new Gtk.Builder()
|
|
8
15
|
|
|
@@ -12,13 +19,12 @@ function add(parent: Gtk.Buildable, child: GObject.Object, _: number) {
|
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
function specialAdd(parent: GObject.Object, child: GObject.Object, index: number) {
|
|
23
|
+
if (_add in parent && typeof parent[_add] === "function") {
|
|
24
|
+
parent[_add](child, getType(child), index)
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
19
27
|
|
|
20
|
-
function specialAdd(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
21
|
-
// TODO: add any other special case
|
|
22
28
|
if (
|
|
23
29
|
child instanceof Gtk.Adjustment &&
|
|
24
30
|
"set_adjustment" in parent &&
|
|
@@ -69,8 +75,16 @@ function specialAdd(parent: GObject.Object, child: GObject.Object, _: number) {
|
|
|
69
75
|
return false
|
|
70
76
|
}
|
|
71
77
|
|
|
78
|
+
// `set_child` and especially `remove` might be way too generic and there might
|
|
79
|
+
// be cases where it does not actually do what we want it to do
|
|
80
|
+
//
|
|
81
|
+
// if there is a usecase for either of these two that does something else than
|
|
82
|
+
// we expect it to do here in a JSX context we have to check for known instances
|
|
72
83
|
function remove(parent: GObject.Object, child: GObject.Object) {
|
|
73
|
-
if (
|
|
84
|
+
if (_remove in parent && typeof parent[_remove] === "function") {
|
|
85
|
+
parent[_remove](child)
|
|
86
|
+
return
|
|
87
|
+
}
|
|
74
88
|
|
|
75
89
|
if (parent instanceof Gtk.Widget && child instanceof Gtk.EventController) {
|
|
76
90
|
return parent.remove_controller(child)
|
package/dist/index.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
type Node,
|
|
3
|
+
type CCProps,
|
|
4
|
+
type FCProps,
|
|
5
|
+
getType,
|
|
6
|
+
jsx,
|
|
7
|
+
addChild,
|
|
8
|
+
removeChild,
|
|
9
|
+
} from "./jsx/jsx.js"
|
|
2
10
|
export { Fragment } from "./jsx/Fragment.js"
|
|
3
11
|
export { For } from "./jsx/For.js"
|
|
4
12
|
export { With } from "./jsx/With.js"
|
package/dist/jsx/jsx.ts
CHANGED
|
@@ -19,6 +19,36 @@ export type Node =
|
|
|
19
19
|
|
|
20
20
|
export const gtkType = Symbol("gtk builder type")
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Special symbol which lets you implement how widgets are appended in JSX.
|
|
24
|
+
*
|
|
25
|
+
* Example:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* class MyComponent extends GObject.Object {
|
|
29
|
+
* [addChild](child: GObject.Object, type: string | null, index: number) {
|
|
30
|
+
* // implement
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const addChild = Symbol("JSX add child method")
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Special symbol which lets you implement how widgets are removed in JSX.
|
|
39
|
+
*
|
|
40
|
+
* Example:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* class MyComponent extends GObject.Object {
|
|
44
|
+
* [removeChild](child: GObject.Object) {
|
|
45
|
+
* // implement
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const removeChild = Symbol("JSX add remove method")
|
|
51
|
+
|
|
22
52
|
/**
|
|
23
53
|
* Get the type of the object specified through the `$type` property
|
|
24
54
|
*/
|
package/dist/resource.xml
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
--alias:gnim/dbus=resource:///gnim/dbus.js
|
|
7
7
|
--alias:gnim/gobject=resource:///gnim/gobject.js
|
|
8
8
|
--alias:gnim/gtk4/jsx-runtime=resource:///gnim/gtk4/jsx-runtime.js
|
|
9
|
-
--alias:gnim/gtk4/style=resource:///gnim/gtk4/style.js
|
|
10
9
|
--alias:gnim/gtk3/jsx-runtime=resource:///gnim/gtk3/jsx-runtime.js
|
|
11
|
-
--alias:gnim/gtk3/style=resource:///gnim/gtk3/style.js
|
|
12
10
|
--alias:gnim/gnome/jsx-runtime=resource:///gnim/gnome/jsx-runtime.js
|
|
13
11
|
-->
|
|
14
12
|
|
|
@@ -40,14 +38,6 @@
|
|
|
40
38
|
declare module "resource:///gnim/gtk3/jsx-runtime.js" {
|
|
41
39
|
export * from "gnim/gtk3/jsx-runtime"
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
declare module "resource:///gnim/gtk4/style.js" {
|
|
45
|
-
export * from "gnim/gtk4/style"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
declare module "resource:///gnim/gtk3/style.js" {
|
|
49
|
-
export * from "gnim/gtk3/style"
|
|
50
|
-
}
|
|
51
41
|
-->
|
|
52
42
|
<gresource prefix="/gnim">
|
|
53
43
|
<file>dbus.js</file>
|
|
@@ -56,14 +46,10 @@
|
|
|
56
46
|
<file>util.js</file>
|
|
57
47
|
<file>index.js</file>
|
|
58
48
|
|
|
59
|
-
<file>gnome/jsx-runtime.js</file>
|
|
60
49
|
<file>gnome/signalTracker.js</file>
|
|
61
|
-
|
|
50
|
+
<file>gnome/jsx-runtime.js</file>
|
|
62
51
|
<file>gtk3/jsx-runtime.js</file>
|
|
63
|
-
<file>gtk3/style.js</file>
|
|
64
|
-
|
|
65
52
|
<file>gtk4/jsx-runtime.js</file>
|
|
66
|
-
<file>gtk4/style.js</file>
|
|
67
53
|
|
|
68
54
|
<file>jsx/env.js</file>
|
|
69
55
|
<file>jsx/For.js</file>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gnim",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Aylur",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,9 +40,7 @@
|
|
|
40
40
|
"./resource": "./dist/resource/resource.ts",
|
|
41
41
|
"./gnome/jsx-runtime": "./dist/gnome/jsx-runtime.ts",
|
|
42
42
|
"./gtk3/jsx-runtime": "./dist/gtk3/jsx-runtime.ts",
|
|
43
|
-
"./
|
|
44
|
-
"./gtk4/jsx-runtime": "./dist/gtk4/jsx-runtime.ts",
|
|
45
|
-
"./gtk4/style": "./dist/gtk4/style.ts"
|
|
43
|
+
"./gtk4/jsx-runtime": "./dist/gtk4/jsx-runtime.ts"
|
|
46
44
|
},
|
|
47
45
|
"files": [
|
|
48
46
|
"dist"
|
package/dist/gtk3/style.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import Gtk from "gi://Gtk?version=3.0"
|
|
2
|
-
import Gdk from "gi://Gdk?version=3.0"
|
|
3
|
-
|
|
4
|
-
const stylesheets: string[] = []
|
|
5
|
-
|
|
6
|
-
/** @experimental */
|
|
7
|
-
export function apply() {
|
|
8
|
-
const provider = new Gtk.CssProvider()
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
provider.load_from_data(stylesheets.join(" "))
|
|
12
|
-
} catch (err) {
|
|
13
|
-
logError(err)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const screen = Gdk.Screen.get_default()
|
|
17
|
-
if (!screen) {
|
|
18
|
-
throw Error("Could not get default Gdk.Screen")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Gtk.StyleContext.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
Gtk.StyleContext.remove_provider_for_screen(screen, provider)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function css(css: TemplateStringsArray, ...values: any[]): void
|
|
29
|
-
export function css(css: string): void
|
|
30
|
-
export function css(css: TemplateStringsArray | string, ...values: any[]) {
|
|
31
|
-
const style =
|
|
32
|
-
typeof css === "string" ? css : css.flatMap((str, i) => str + `${values[i] ?? ""}`).join("")
|
|
33
|
-
|
|
34
|
-
stylesheets.push(style)
|
|
35
|
-
}
|
package/dist/gtk4/style.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import Gtk from "gi://Gtk?version=4.0"
|
|
2
|
-
import Gdk from "gi://Gdk?version=4.0"
|
|
3
|
-
|
|
4
|
-
const stylesheets: string[] = []
|
|
5
|
-
|
|
6
|
-
/** @experimental */
|
|
7
|
-
export function apply() {
|
|
8
|
-
const provider = new Gtk.CssProvider()
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
provider.load_from_string(stylesheets.join(" "))
|
|
12
|
-
} catch (err) {
|
|
13
|
-
logError(err)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const display = Gdk.Display.get_default()
|
|
17
|
-
if (!display) {
|
|
18
|
-
throw Error("Could not get default Gdk.Display")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Gtk.StyleContext.add_provider_for_display(display, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
Gtk.StyleContext.remove_provider_for_display(display, provider)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function css(css: TemplateStringsArray, ...values: any[]): void
|
|
29
|
-
export function css(css: string): void
|
|
30
|
-
export function css(css: TemplateStringsArray | string, ...values: any[]) {
|
|
31
|
-
const style =
|
|
32
|
-
typeof css === "string" ? css : css.flatMap((str, i) => str + `${values[i] ?? ""}`).join("")
|
|
33
|
-
|
|
34
|
-
stylesheets.push(style)
|
|
35
|
-
}
|