@cntrl-site/sdk-nextjs 1.9.13-2 → 1.9.13-3
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.
|
@@ -105,44 +105,47 @@ class InteractionsRegistry {
|
|
|
105
105
|
return available;
|
|
106
106
|
}
|
|
107
107
|
notifyLoad() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
108
|
+
var _a, _b;
|
|
109
|
+
const timestamp = Date.now();
|
|
110
|
+
for (const interaction of this.interactions) {
|
|
111
|
+
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
112
|
+
const matchingTrigger = interaction.triggers.find(trigger => 'position' in trigger && trigger.position === 0 && trigger.from === currentStateId);
|
|
113
|
+
if (!matchingTrigger)
|
|
114
|
+
continue;
|
|
115
|
+
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
116
|
+
const isNewStateActive = matchingTrigger.to === activeStateId;
|
|
117
|
+
this.setCurrentStateForInteraction(interaction.id, matchingTrigger.to);
|
|
118
|
+
const transitioningItems = (_a = this.stateItemsIdsMap[activeStateId]) !== null && _a !== void 0 ? _a : [];
|
|
119
|
+
const state = interaction.states.find((state) => state.id === matchingTrigger.to);
|
|
120
|
+
const actions = (_b = state === null || state === void 0 ? void 0 : state.actions) !== null && _b !== void 0 ? _b : [];
|
|
121
|
+
for (const action of actions) {
|
|
122
|
+
const ctrl = this.ctrls.get(action.itemId);
|
|
123
|
+
if (!ctrl)
|
|
124
|
+
continue;
|
|
125
|
+
ctrl.receiveAction(action.type);
|
|
126
|
+
}
|
|
127
|
+
this.itemsStages = this.itemsStages.map((stage) => {
|
|
128
|
+
if (stage.interactionId !== interaction.id)
|
|
129
|
+
return stage;
|
|
130
|
+
return {
|
|
131
|
+
itemId: stage.itemId,
|
|
132
|
+
interactionId: stage.interactionId,
|
|
133
|
+
type: 'transitioning',
|
|
134
|
+
from: stage.type === 'transitioning' ? stage.to : stage.stateId,
|
|
135
|
+
to: matchingTrigger.to,
|
|
136
|
+
direction: isNewStateActive ? 'in' : 'out',
|
|
137
|
+
updated: timestamp
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
const itemsToNotify = new Set(transitioningItems);
|
|
141
|
+
for (const trigger of interaction.triggers) {
|
|
142
|
+
if (!('itemId' in trigger))
|
|
143
|
+
continue;
|
|
144
|
+
itemsToNotify.add(trigger.itemId);
|
|
145
|
+
}
|
|
146
|
+
this.notifyItemCtrlsChange(Array.from(itemsToNotify));
|
|
147
|
+
this.notifyTransitionStartForItems(transitioningItems, activeStateId);
|
|
148
|
+
}
|
|
146
149
|
}
|
|
147
150
|
notifyScroll(position) {
|
|
148
151
|
// const timestamp = Date.now();
|
package/package.json
CHANGED
|
@@ -113,46 +113,46 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
notifyLoad() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
const timestamp = Date.now();
|
|
117
|
+
for (const interaction of this.interactions) {
|
|
118
|
+
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
119
|
+
const matchingTrigger = interaction.triggers.find(trigger =>
|
|
120
|
+
'position' in trigger && trigger.position === 0 && trigger.from === currentStateId
|
|
121
|
+
);
|
|
122
|
+
if (!matchingTrigger) continue;
|
|
123
|
+
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
124
|
+
const isNewStateActive = matchingTrigger.to === activeStateId;
|
|
125
|
+
this.setCurrentStateForInteraction(interaction.id, matchingTrigger.to);
|
|
126
|
+
const transitioningItems = this.stateItemsIdsMap[activeStateId] ?? [];
|
|
127
|
+
const state = interaction.states.find((state) => state.id === matchingTrigger.to);
|
|
128
|
+
const actions = state?.actions ?? [];
|
|
129
|
+
for (const action of actions) {
|
|
130
|
+
const ctrl = this.ctrls.get(action.itemId);
|
|
131
|
+
if (!ctrl) continue;
|
|
132
|
+
ctrl.receiveAction(action.type);
|
|
133
|
+
}
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
this.itemsStages = this.itemsStages.map((stage) => {
|
|
136
|
+
if (stage.interactionId !== interaction.id) return stage;
|
|
137
|
+
return {
|
|
138
|
+
itemId: stage.itemId,
|
|
139
|
+
interactionId: stage.interactionId,
|
|
140
|
+
type: 'transitioning',
|
|
141
|
+
from: stage.type === 'transitioning' ? stage.to : stage.stateId!,
|
|
142
|
+
to: matchingTrigger.to,
|
|
143
|
+
direction: isNewStateActive ? 'in' : 'out',
|
|
144
|
+
updated: timestamp
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
const itemsToNotify = new Set<ItemId>(transitioningItems);
|
|
149
|
+
for (const trigger of interaction.triggers) {
|
|
150
|
+
if (!('itemId' in trigger)) continue;
|
|
151
|
+
itemsToNotify.add(trigger.itemId);
|
|
152
|
+
}
|
|
153
|
+
this.notifyItemCtrlsChange(Array.from(itemsToNotify));
|
|
154
|
+
this.notifyTransitionStartForItems(transitioningItems, activeStateId);
|
|
155
|
+
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
notifyScroll(position: number) {
|