gnim 1.2.2 → 1.2.4
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/jsx/scope.d.ts +3 -3
- package/dist/jsx/scope.js +10 -9
- package/dist/jsx/state.js +2 -2
- package/package.json +1 -1
- package/dist/gnim.gresource +0 -0
package/dist/jsx/scope.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare class Scope {
|
|
2
|
-
static current
|
|
2
|
+
static current?: Scope | null;
|
|
3
3
|
parent?: Scope | null;
|
|
4
|
-
|
|
4
|
+
contexts: Map<Context<any>, unknown>;
|
|
5
5
|
private cleanups;
|
|
6
6
|
private mounts;
|
|
7
7
|
private mounted;
|
|
8
|
-
constructor(parent
|
|
8
|
+
constructor(parent?: Scope | null);
|
|
9
9
|
onCleanup(callback: () => void): void;
|
|
10
10
|
onMount(callback: () => void): void;
|
|
11
11
|
run<T>(fn: () => T): T;
|
package/dist/jsx/scope.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class Scope {
|
|
2
2
|
constructor(parent) {
|
|
3
|
+
this.contexts = new Map();
|
|
3
4
|
this.cleanups = new Set();
|
|
4
5
|
this.mounts = new Set();
|
|
5
6
|
this.mounted = false;
|
|
@@ -32,8 +33,8 @@ export class Scope {
|
|
|
32
33
|
dispose() {
|
|
33
34
|
this.cleanups.forEach((cb) => cb());
|
|
34
35
|
this.cleanups.clear();
|
|
36
|
+
this.contexts.clear();
|
|
35
37
|
delete this.parent;
|
|
36
|
-
delete this.context;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
@@ -59,29 +60,29 @@ export class Scope {
|
|
|
59
60
|
* ```
|
|
60
61
|
*/
|
|
61
62
|
export function createContext(defaultValue) {
|
|
63
|
+
let ctx;
|
|
62
64
|
function provide(value, fn) {
|
|
63
|
-
const scope =
|
|
64
|
-
|
|
65
|
-
scope.context = value;
|
|
65
|
+
const scope = getScope();
|
|
66
|
+
scope.contexts.set(ctx, value);
|
|
66
67
|
return scope.run(fn);
|
|
67
68
|
}
|
|
68
69
|
function use() {
|
|
69
70
|
let scope = Scope.current;
|
|
70
71
|
while (scope) {
|
|
71
|
-
const value = scope.
|
|
72
|
-
if (value)
|
|
72
|
+
const value = scope.contexts.get(ctx);
|
|
73
|
+
if (value !== undefined)
|
|
73
74
|
return value;
|
|
74
|
-
scope = scope.parent
|
|
75
|
+
scope = scope.parent;
|
|
75
76
|
}
|
|
76
77
|
return defaultValue;
|
|
77
78
|
}
|
|
78
79
|
function context({ value, children }) {
|
|
79
80
|
return provide(value, children);
|
|
80
81
|
}
|
|
81
|
-
return Object.assign(context, {
|
|
82
|
+
return (ctx = Object.assign(context, {
|
|
82
83
|
provide,
|
|
83
84
|
use,
|
|
84
|
-
});
|
|
85
|
+
}));
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* Gets the scope that owns the currently running code.
|
package/dist/jsx/state.js
CHANGED
|
@@ -175,14 +175,14 @@ export function createConnection(init, h1, h2, h3, h4, h5, h6, h7, h8, h9) {
|
|
|
175
175
|
const subscribe = (callback) => {
|
|
176
176
|
if (subscribers.size === 0) {
|
|
177
177
|
dispose = signals.map(([object, signal, callback]) => {
|
|
178
|
-
const id =
|
|
178
|
+
const id = GObject.Object.prototype.connect.call(object, signal, (_, ...args) => {
|
|
179
179
|
const newValue = callback(...args);
|
|
180
180
|
if (value !== newValue) {
|
|
181
181
|
value = newValue;
|
|
182
182
|
subscribers.forEach((cb) => cb());
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
|
-
return () =>
|
|
185
|
+
return () => GObject.Object.prototype.disconnect.call(object, id);
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
subscribers.add(callback);
|
package/package.json
CHANGED
package/dist/gnim.gresource
DELETED
|
Binary file
|