@player-ui/player 0.7.0 → 0.7.1-next.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.
- package/dist/index.cjs.js +249 -268
- package/dist/index.esm.js +249 -268
- package/dist/player.dev.js +249 -268
- package/dist/player.prod.js +1 -1
- package/package.json +3 -3
- package/src/controllers/validation/controller.ts +11 -14
- package/src/controllers/view/controller.ts +27 -11
- package/src/player.ts +2 -2
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-ui/player",
|
|
3
|
-
"version": "0.7.0",
|
|
3
|
+
"version": "0.7.1-next.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@player-ui/partial-match-registry": "0.7.0",
|
|
11
|
-
"@player-ui/types": "0.7.0",
|
|
10
|
+
"@player-ui/partial-match-registry": "0.7.1-next.0",
|
|
11
|
+
"@player-ui/types": "0.7.1-next.0",
|
|
12
12
|
"dequal": "^2.0.2",
|
|
13
13
|
"p-defer": "^3.0.0",
|
|
14
14
|
"queue-microtask": "^1.2.3",
|
|
@@ -184,13 +184,10 @@ class ValidatedBinding {
|
|
|
184
184
|
public getAll(): Array<ValidationResponse> {
|
|
185
185
|
return this.applicableValidations.reduce((all, statefulObj) => {
|
|
186
186
|
if (statefulObj.state === 'active' && statefulObj.response) {
|
|
187
|
-
|
|
188
|
-
...
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
blocking: this.checkIfBlocking(statefulObj),
|
|
192
|
-
},
|
|
193
|
-
];
|
|
187
|
+
all.push({
|
|
188
|
+
...statefulObj.response,
|
|
189
|
+
blocking: this.checkIfBlocking(statefulObj),
|
|
190
|
+
});
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
return all;
|
|
@@ -604,18 +601,18 @@ export class ValidationController implements BindingTracker {
|
|
|
604
601
|
// Get all of the validations from each provider
|
|
605
602
|
const possibleValidations = this.getValidationProviders().reduce<
|
|
606
603
|
Array<ValidationObjectWithSource>
|
|
607
|
-
>(
|
|
608
|
-
(
|
|
609
|
-
...vals,
|
|
604
|
+
>((vals, provider) => {
|
|
605
|
+
vals.push(
|
|
610
606
|
...(provider.provider
|
|
611
607
|
.getValidationsForBinding?.(binding)
|
|
612
608
|
?.map((valObj) => ({
|
|
613
609
|
...valObj,
|
|
614
610
|
[VALIDATION_PROVIDER_NAME_SYMBOL]: provider.source,
|
|
615
|
-
})) ?? [])
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
611
|
+
})) ?? [])
|
|
612
|
+
);
|
|
613
|
+
|
|
614
|
+
return vals;
|
|
615
|
+
}, []);
|
|
619
616
|
|
|
620
617
|
if (possibleValidations.length === 0) {
|
|
621
618
|
return;
|
|
@@ -41,6 +41,8 @@ export class ViewController {
|
|
|
41
41
|
private pendingUpdate?: {
|
|
42
42
|
/** pending data binding changes */
|
|
43
43
|
changedBindings?: Set<BindingInstance>;
|
|
44
|
+
/** Whether we have a microtask queued to handle this pending update */
|
|
45
|
+
scheduled?: boolean;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
public currentView?: ViewInstance;
|
|
@@ -53,10 +55,11 @@ export class ViewController {
|
|
|
53
55
|
) {
|
|
54
56
|
this.viewOptions = options;
|
|
55
57
|
this.viewMap = initialViews.reduce<Record<string, View>>(
|
|
56
|
-
(viewMap, view) =>
|
|
57
|
-
|
|
58
|
-
[view.id]
|
|
59
|
-
|
|
58
|
+
(viewMap, view) => {
|
|
59
|
+
// eslint-disable-next-line no-param-reassign
|
|
60
|
+
viewMap[view.id] = view;
|
|
61
|
+
return viewMap;
|
|
62
|
+
},
|
|
60
63
|
{}
|
|
61
64
|
);
|
|
62
65
|
|
|
@@ -76,19 +79,25 @@ export class ViewController {
|
|
|
76
79
|
);
|
|
77
80
|
|
|
78
81
|
/** Trigger a view update */
|
|
79
|
-
const update = (updates: Set<BindingInstance
|
|
82
|
+
const update = (updates: Set<BindingInstance>, silent = false) => {
|
|
80
83
|
if (this.currentView) {
|
|
81
84
|
if (this.optimizeUpdates) {
|
|
82
|
-
this.queueUpdate(updates);
|
|
85
|
+
this.queueUpdate(updates, silent);
|
|
83
86
|
} else {
|
|
84
87
|
this.currentView.update();
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
|
|
89
|
-
options.model.hooks.onUpdate.tap(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
options.model.hooks.onUpdate.tap(
|
|
93
|
+
'viewController',
|
|
94
|
+
(updates, updateOptions) => {
|
|
95
|
+
update(
|
|
96
|
+
new Set(updates.map((t) => t.binding)),
|
|
97
|
+
updateOptions?.silent ?? false
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
92
101
|
|
|
93
102
|
options.model.hooks.onDelete.tap('viewController', (binding) => {
|
|
94
103
|
const parentBinding = binding.parent();
|
|
@@ -103,14 +112,21 @@ export class ViewController {
|
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
114
|
|
|
106
|
-
private queueUpdate(bindings: Set<BindingInstance
|
|
115
|
+
private queueUpdate(bindings: Set<BindingInstance>, silent = false) {
|
|
107
116
|
if (this.pendingUpdate?.changedBindings) {
|
|
117
|
+
// If there's already a pending update, just add to it don't worry about silent updates here yet
|
|
108
118
|
this.pendingUpdate.changedBindings = new Set([
|
|
109
119
|
...this.pendingUpdate.changedBindings,
|
|
110
120
|
...bindings,
|
|
111
121
|
]);
|
|
112
122
|
} else {
|
|
113
|
-
this.pendingUpdate = { changedBindings: bindings };
|
|
123
|
+
this.pendingUpdate = { changedBindings: bindings, scheduled: false };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// If there's no pending update, schedule one only if this one isn't silent
|
|
127
|
+
// otherwise if this is silent, we'll just wait for the next non-silent update and make sure our bindings are included
|
|
128
|
+
if (!this.pendingUpdate.scheduled && !silent) {
|
|
129
|
+
this.pendingUpdate.scheduled = true;
|
|
114
130
|
queueMicrotask(() => {
|
|
115
131
|
const updates = this.pendingUpdate?.changedBindings;
|
|
116
132
|
this.pendingUpdate = undefined;
|
package/src/player.ts
CHANGED
|
@@ -30,8 +30,8 @@ import type {
|
|
|
30
30
|
import { NOT_STARTED_STATE } from './types';
|
|
31
31
|
|
|
32
32
|
// Variables injected at build time
|
|
33
|
-
const PLAYER_VERSION = '0.7.0';
|
|
34
|
-
const COMMIT = '
|
|
33
|
+
const PLAYER_VERSION = '0.7.1-next.0';
|
|
34
|
+
const COMMIT = 'b0282a1b53e7a91069e97814edec091b3de9ec5f';
|
|
35
35
|
|
|
36
36
|
export interface PlayerPlugin {
|
|
37
37
|
/**
|