@zcomponent/core 1.27.0 → 1.27.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.
|
@@ -32,6 +32,7 @@ export declare class AudioContextContext extends Context {
|
|
|
32
32
|
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the disposal was successful.
|
|
33
33
|
*/
|
|
34
34
|
dispose(): never;
|
|
35
|
+
private _resumeAudioContext;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Returns the audio context.
|
|
@@ -16,8 +16,14 @@ export class AudioContextContext extends Context {
|
|
|
16
16
|
this.audioContext = new AudioContext();
|
|
17
17
|
this._layers = new Map();
|
|
18
18
|
this.layers = this._layers;
|
|
19
|
+
this._resumeAudioContext = () => {
|
|
20
|
+
if (this.audioContext.state === 'suspended' && document.visibilityState === 'visible') {
|
|
21
|
+
this.audioContext.resume();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
19
24
|
nextUserEvent(contextManager).then(() => {
|
|
20
25
|
this.audioContext.resume();
|
|
26
|
+
document.addEventListener('visibilitychange', this._resumeAudioContext);
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
29
|
_getLayer(name) {
|
|
@@ -51,6 +57,7 @@ export class AudioContextContext extends Context {
|
|
|
51
57
|
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the disposal was successful.
|
|
52
58
|
*/
|
|
53
59
|
dispose() {
|
|
60
|
+
document.removeEventListener('visibilitychange', this._resumeAudioContext);
|
|
54
61
|
this.audioContext.close();
|
|
55
62
|
return super.dispose();
|
|
56
63
|
}
|
package/lib/data/change.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ import { Prop } from '../types';
|
|
|
7
7
|
* @returns The computed hierarchy of nodes.
|
|
8
8
|
*/
|
|
9
9
|
export declare function computeNodeHierarchy(nodes: NodeByID): ComputedHierarchy;
|
|
10
|
+
export interface HierarchyDiffItem {
|
|
11
|
+
id: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
type?: 'added' | 'deleted' | 'moved';
|
|
14
|
+
order?: string;
|
|
15
|
+
}
|
|
16
|
+
export type HierarchyDiff = {
|
|
17
|
+
[id: string]: HierarchyDiffItem[];
|
|
18
|
+
};
|
|
19
|
+
export declare function computeHierarchyDiff(before: NodeByID | undefined, after: NodeByID): HierarchyDiff;
|
|
10
20
|
/**
|
|
11
21
|
* Computes and memoizes the hierarchy of behaviors.
|
|
12
22
|
*
|
package/lib/data/change.js
CHANGED
|
@@ -5,6 +5,7 @@ import { EntityPropOverrideType } from './core';
|
|
|
5
5
|
* Represents a map of node IDs to their child node IDs.
|
|
6
6
|
*/
|
|
7
7
|
const computedHierarchies = new Map();
|
|
8
|
+
const computedHierarchyDiff = new Map();
|
|
8
9
|
/**
|
|
9
10
|
* Represents a map of behavior IDs to their child behavior IDs.
|
|
10
11
|
*/
|
|
@@ -41,6 +42,54 @@ export function computeNodeHierarchy(nodes) {
|
|
|
41
42
|
}
|
|
42
43
|
return existing;
|
|
43
44
|
}
|
|
45
|
+
export function computeHierarchyDiff(before, after) {
|
|
46
|
+
let existing = computedHierarchyDiff.get(after);
|
|
47
|
+
if (!existing) {
|
|
48
|
+
existing = {};
|
|
49
|
+
for (const [id, node] of Object.entries(after)) {
|
|
50
|
+
if (!node || !node.parent)
|
|
51
|
+
continue;
|
|
52
|
+
const parent = existing[node.parent.id] || [];
|
|
53
|
+
existing[node.parent.id] = parent;
|
|
54
|
+
const item = { id, label: node.label, order: node.parent.order };
|
|
55
|
+
if (before) {
|
|
56
|
+
if (before[id]?.parent?.id !== node.parent.id)
|
|
57
|
+
item.type = 'added';
|
|
58
|
+
else if (before[id]?.parent?.order !== node.parent.order) {
|
|
59
|
+
item.type = 'added';
|
|
60
|
+
parent.push({ id: 'tombstone-' + id, label: node.label, order: before[id]?.parent?.order, type: 'deleted' });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
parent.push(item);
|
|
64
|
+
}
|
|
65
|
+
if (before) {
|
|
66
|
+
for (const [id, node] of Object.entries(before)) {
|
|
67
|
+
if (!node || !node.parent)
|
|
68
|
+
continue;
|
|
69
|
+
const parent = existing[node.parent.id] || [];
|
|
70
|
+
existing[node.parent.id] = parent;
|
|
71
|
+
if (after[id]?.parent?.id !== node.parent.id) {
|
|
72
|
+
const item = { id: 'tombstone-' + id, label: node.label, order: node.parent.order };
|
|
73
|
+
item.type = 'deleted';
|
|
74
|
+
parent.push(item);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const children of Object.values(existing)) {
|
|
79
|
+
children.sort((nodeAID, nodeBID) => {
|
|
80
|
+
let a = nodeAID.order ?? 'A0';
|
|
81
|
+
let b = nodeBID.order ?? 'A0';
|
|
82
|
+
if (a === b) {
|
|
83
|
+
a = nodeAID.id;
|
|
84
|
+
b = nodeBID.id;
|
|
85
|
+
}
|
|
86
|
+
return a < b ? -1 : 1;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
computedHierarchyDiff.set(after, existing);
|
|
90
|
+
}
|
|
91
|
+
return existing;
|
|
92
|
+
}
|
|
44
93
|
/**
|
|
45
94
|
* Computes and memoizes the hierarchy of behaviors.
|
|
46
95
|
*
|