@repobit/dex-store-elements 1.1.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/CHANGELOG.md +110 -0
- package/README.md +211 -0
- package/dist/src/actions/action.button.d.ts +1 -0
- package/dist/src/actions/action.button.js +14 -0
- package/dist/src/actions/action.button.js.map +1 -0
- package/dist/src/actions/action.input.d.ts +1 -0
- package/dist/src/actions/action.input.js +37 -0
- package/dist/src/actions/action.input.js.map +1 -0
- package/dist/src/actions/action.select.d.ts +1 -0
- package/dist/src/actions/action.select.js +12 -0
- package/dist/src/actions/action.select.js.map +1 -0
- package/dist/src/actions/index.d.ts +2 -0
- package/dist/src/actions/index.js +30 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/utilty.d.ts +9 -0
- package/dist/src/actions/utilty.js +88 -0
- package/dist/src/actions/utilty.js.map +1 -0
- package/dist/src/contexts/context.datalayer.d.ts +9 -0
- package/dist/src/contexts/context.datalayer.js +3 -0
- package/dist/src/contexts/context.datalayer.js.map +1 -0
- package/dist/src/contexts/context.derived.d.ts +12 -0
- package/dist/src/contexts/context.derived.js +3 -0
- package/dist/src/contexts/context.derived.js.map +1 -0
- package/dist/src/contexts/context.event.d.ts +5 -0
- package/dist/src/contexts/context.event.js +3 -0
- package/dist/src/contexts/context.event.js.map +1 -0
- package/dist/src/contexts/context.option.d.ts +5 -0
- package/dist/src/contexts/context.option.js +3 -0
- package/dist/src/contexts/context.option.js.map +1 -0
- package/dist/src/contexts/context.product.d.ts +5 -0
- package/dist/src/contexts/context.product.js +3 -0
- package/dist/src/contexts/context.product.js.map +1 -0
- package/dist/src/contexts/context.state.d.ts +28 -0
- package/dist/src/contexts/context.state.js +3 -0
- package/dist/src/contexts/context.state.js.map +1 -0
- package/dist/src/contexts/context.store.d.ts +5 -0
- package/dist/src/contexts/context.store.js +3 -0
- package/dist/src/contexts/context.store.js.map +1 -0
- package/dist/src/dsl/compilers/array/compiler.d.ts +1 -0
- package/dist/src/dsl/compilers/array/compiler.js +30 -0
- package/dist/src/dsl/compilers/array/compiler.js.map +1 -0
- package/dist/src/dsl/compilers/boolean/compiler.d.ts +7 -0
- package/dist/src/dsl/compilers/boolean/compiler.js +53 -0
- package/dist/src/dsl/compilers/boolean/compiler.js.map +1 -0
- package/dist/src/dsl/compilers/enum/compiler.d.ts +7 -0
- package/dist/src/dsl/compilers/enum/compiler.js +16 -0
- package/dist/src/dsl/compilers/enum/compiler.js.map +1 -0
- package/dist/src/dsl/compilers/index.d.ts +12 -0
- package/dist/src/dsl/compilers/index.js +9 -0
- package/dist/src/dsl/compilers/index.js.map +1 -0
- package/dist/src/dsl/utilty.d.ts +6 -0
- package/dist/src/dsl/utilty.js +32 -0
- package/dist/src/dsl/utilty.js.map +1 -0
- package/dist/src/events/events.d.ts +60 -0
- package/dist/src/events/events.js +56 -0
- package/dist/src/events/events.js.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/nodes/node.context.d.ts +3 -0
- package/dist/src/nodes/node.context.js +15 -0
- package/dist/src/nodes/node.context.js.map +1 -0
- package/dist/src/nodes/node.option.d.ts +32 -0
- package/dist/src/nodes/node.option.js +247 -0
- package/dist/src/nodes/node.option.js.map +1 -0
- package/dist/src/nodes/node.product.d.ts +14 -0
- package/dist/src/nodes/node.product.js +99 -0
- package/dist/src/nodes/node.product.js.map +1 -0
- package/dist/src/nodes/node.root.d.ts +16 -0
- package/dist/src/nodes/node.root.js +53 -0
- package/dist/src/nodes/node.root.js.map +1 -0
- package/dist/src/nodes/node.state.d.ts +112 -0
- package/dist/src/nodes/node.state.js +742 -0
- package/dist/src/nodes/node.state.js.map +1 -0
- package/dist/src/renders/attributes/buyLink.d.ts +2 -0
- package/dist/src/renders/attributes/buyLink.js +18 -0
- package/dist/src/renders/attributes/buyLink.js.map +1 -0
- package/dist/src/renders/attributes/devices.d.ts +2 -0
- package/dist/src/renders/attributes/devices.js +32 -0
- package/dist/src/renders/attributes/devices.js.map +1 -0
- package/dist/src/renders/attributes/discount.d.ts +2 -0
- package/dist/src/renders/attributes/discount.js +96 -0
- package/dist/src/renders/attributes/discount.js.map +1 -0
- package/dist/src/renders/attributes/hide.d.ts +2 -0
- package/dist/src/renders/attributes/hide.js +33 -0
- package/dist/src/renders/attributes/hide.js.map +1 -0
- package/dist/src/renders/attributes/index.d.ts +3 -0
- package/dist/src/renders/attributes/index.js +24 -0
- package/dist/src/renders/attributes/index.js.map +1 -0
- package/dist/src/renders/attributes/price.d.ts +2 -0
- package/dist/src/renders/attributes/price.js +96 -0
- package/dist/src/renders/attributes/price.js.map +1 -0
- package/dist/src/renders/attributes/subscription.d.ts +2 -0
- package/dist/src/renders/attributes/subscription.js +34 -0
- package/dist/src/renders/attributes/subscription.js.map +1 -0
- package/dist/src/renders/attributes/trialLink.d.ts +2 -0
- package/dist/src/renders/attributes/trialLink.js +13 -0
- package/dist/src/renders/attributes/trialLink.js.map +1 -0
- package/dist/src/renders/context.d.ts +11 -0
- package/dist/src/renders/context.js +88 -0
- package/dist/src/renders/context.js.map +1 -0
- package/dist/src/renders/format.d.ts +2 -0
- package/dist/src/renders/format.js +21 -0
- package/dist/src/renders/format.js.map +1 -0
- package/dist/src/renders/index.d.ts +2 -0
- package/dist/src/renders/index.js +30 -0
- package/dist/src/renders/index.js.map +1 -0
- package/dist/src/renders/observe.d.ts +4 -0
- package/dist/src/renders/observe.js +30 -0
- package/dist/src/renders/observe.js.map +1 -0
- package/dist/src/renders/utility.d.ts +28 -0
- package/dist/src/renders/utility.js +132 -0
- package/dist/src/renders/utility.js.map +1 -0
- package/dist/src/templating/eta.d.ts +3 -0
- package/dist/src/templating/eta.js +9 -0
- package/dist/src/templating/eta.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { dataLayerContext } from "../contexts/context.datalayer.js";
|
|
8
|
+
import { optionContext } from "../contexts/context.option.js";
|
|
9
|
+
import { productContext } from "../contexts/context.product.js";
|
|
10
|
+
import { toDSLContext } from "../renders/context.js";
|
|
11
|
+
import { consume, provide } from "@lit/context";
|
|
12
|
+
import { Task } from "@lit/task";
|
|
13
|
+
import { customElement, property } from "lit/decorators.js";
|
|
14
|
+
import { StateNode } from "./node.state.js";
|
|
15
|
+
let OptionNode = class OptionNode extends StateNode {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.bundle = [];
|
|
19
|
+
// ensure datalayer is fired only once (first load)
|
|
20
|
+
this._sentDataLayer = false;
|
|
21
|
+
this._changeOptionEvent = new Task(this, {
|
|
22
|
+
task: async ([evt, store]) => {
|
|
23
|
+
if (!evt || !store) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
// Ignore events matching this node's ignoreEvents list (works for DOM or context)
|
|
27
|
+
if (this._isIgnoredSource(evt)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
this._optionContext = this._changeOptionEvent.taskComplete;
|
|
31
|
+
if (!this.noCollect) {
|
|
32
|
+
this.collectOption({
|
|
33
|
+
name: this.storeName,
|
|
34
|
+
options: this._changeOptionEvent.taskComplete.then(option => option ? [option] : [])
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
let option = null;
|
|
38
|
+
if (this.isActionEvent(evt)) {
|
|
39
|
+
// Record event-driven attribute values (if any) so attribute task can skip
|
|
40
|
+
this._pendingDevicesFromEvent = evt.detail?.devices;
|
|
41
|
+
this._pendingSubscriptionFromEvent = evt.detail?.subscription;
|
|
42
|
+
option = await this.__applyAction(evt.detail || {});
|
|
43
|
+
}
|
|
44
|
+
if (this.isBundleToogle(evt)) {
|
|
45
|
+
option = await this.__applyBundle(evt.detail || {});
|
|
46
|
+
}
|
|
47
|
+
if (this.isDeltaUpdate(evt)) {
|
|
48
|
+
option = await this._applyDeltaUpdate(evt.detail || {});
|
|
49
|
+
}
|
|
50
|
+
this._option = option;
|
|
51
|
+
return option;
|
|
52
|
+
},
|
|
53
|
+
args: () => [this._event, this.store]
|
|
54
|
+
});
|
|
55
|
+
// Ensure datalayer is emitted if the callback becomes available slightly
|
|
56
|
+
// after the first option was computed.
|
|
57
|
+
this._fireDataLayerTask = new Task(this, {
|
|
58
|
+
task: async ([opt, dl, evt]) => {
|
|
59
|
+
if (this._sentDataLayer)
|
|
60
|
+
return;
|
|
61
|
+
if (opt && dl && evt) {
|
|
62
|
+
dl({ option: opt, event: evt });
|
|
63
|
+
this._sentDataLayer = true;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
args: () => [this._option, this._dataLayer, this.dataLayerEvent]
|
|
67
|
+
});
|
|
68
|
+
this._loadOptionByAttributes = new Task(this, {
|
|
69
|
+
task: async ([devices, subscription]) => {
|
|
70
|
+
// Skip only when current attribute values were just set by an event
|
|
71
|
+
if ((this._pendingDevicesFromEvent !== undefined && devices === this._pendingDevicesFromEvent) ||
|
|
72
|
+
(this._pendingSubscriptionFromEvent !== undefined && subscription === this._pendingSubscriptionFromEvent)) {
|
|
73
|
+
this._pendingDevicesFromEvent = undefined;
|
|
74
|
+
this._pendingSubscriptionFromEvent = undefined;
|
|
75
|
+
return this._option;
|
|
76
|
+
}
|
|
77
|
+
if (!this._option) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (!devices || !subscription) {
|
|
81
|
+
this._option = null;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
this._optionContext = this._loadOptionByAttributes.taskComplete;
|
|
85
|
+
if (!this.noCollect) {
|
|
86
|
+
this.collectOption({
|
|
87
|
+
name: this.storeName,
|
|
88
|
+
options: this._loadOptionByAttributes.taskComplete.then(option => option ? [option] : [])
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const option = await this.option?.getOption({ devices, subscription });
|
|
92
|
+
this._option = option;
|
|
93
|
+
return option;
|
|
94
|
+
},
|
|
95
|
+
args: () => [this.devices, this.subscription]
|
|
96
|
+
});
|
|
97
|
+
// Render text templates for option-specific context in direct children
|
|
98
|
+
this._etaOptionRenderTask = new Task(this, {
|
|
99
|
+
task: async ([opt, state, product, derived]) => {
|
|
100
|
+
const option = opt ?? this._option;
|
|
101
|
+
if (!option)
|
|
102
|
+
return;
|
|
103
|
+
const it = await toDSLContext({ option, product, state, derived });
|
|
104
|
+
await this._renderEtaTemplates(it);
|
|
105
|
+
},
|
|
106
|
+
args: () => [this._option, this.state, this.product, this._derived]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
get option() {
|
|
110
|
+
return this._option;
|
|
111
|
+
}
|
|
112
|
+
// Disable base state-level Eta render to avoid double rendering.
|
|
113
|
+
shouldRunEtaStateRender() { return false; }
|
|
114
|
+
connectedCallback() {
|
|
115
|
+
super.connectedCallback();
|
|
116
|
+
if (!this.noCollect) {
|
|
117
|
+
this.collectOption({
|
|
118
|
+
name: this.storeName,
|
|
119
|
+
options: Promise.resolve(this._option ? [this._option] : [])
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
disconnectedCallback() {
|
|
124
|
+
this.collectOption({
|
|
125
|
+
name: this.storeName,
|
|
126
|
+
options: null
|
|
127
|
+
});
|
|
128
|
+
super.disconnectedCallback();
|
|
129
|
+
}
|
|
130
|
+
async getUpdateComplete() {
|
|
131
|
+
const result = await super.getUpdateComplete();
|
|
132
|
+
await this._changeOptionEvent.taskComplete;
|
|
133
|
+
await this._loadOptionByAttributes.taskComplete;
|
|
134
|
+
await this._etaOptionRenderTask.taskComplete;
|
|
135
|
+
await this._fireDataLayerTask.taskComplete;
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
_eventChange(e) {
|
|
139
|
+
// Respect option-level ignore list
|
|
140
|
+
if (this._isIgnoredSource(e)) {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// Always capture locally
|
|
145
|
+
this._eventDom = e;
|
|
146
|
+
// Allow only product-change events to bubble up to <bd-product>
|
|
147
|
+
if (this.isProductChange(e)) {
|
|
148
|
+
return; // no stopPropagation → let it bubble
|
|
149
|
+
}
|
|
150
|
+
// Keep all other events scoped to this option
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
}
|
|
153
|
+
async _applyDeltaUpdate({ type, delta, useAsValue, min = Number.MAX_SAFE_INTEGER, max = Number.MIN_SAFE_INTEGER }) {
|
|
154
|
+
const devices = useAsValue && type === "devices" ? Number(delta) : this.devices;
|
|
155
|
+
const subscription = useAsValue && type === "subscription" ? Number(delta) : this.subscription;
|
|
156
|
+
let option;
|
|
157
|
+
if (useAsValue) {
|
|
158
|
+
if (!devices || !subscription) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
option = await this.option?.getOption({ devices, subscription });
|
|
162
|
+
}
|
|
163
|
+
option = await this.option?.nextOption(type === "devices" ?
|
|
164
|
+
{ devices: delta } :
|
|
165
|
+
{ subscription: delta });
|
|
166
|
+
if (!option) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (type === "devices" && (option.getDevices() < min || option.getDevices() > max)) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
if (type === "subscription" && (option.getSubscription() < min || option.getSubscription() > max)) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
// Mark as event-driven attribute update to avoid double work
|
|
176
|
+
this._pendingDevicesFromEvent = devices;
|
|
177
|
+
this._pendingSubscriptionFromEvent = subscription;
|
|
178
|
+
this.devices = devices;
|
|
179
|
+
this.subscription = subscription;
|
|
180
|
+
return option;
|
|
181
|
+
}
|
|
182
|
+
async __applyAction({ id, campaign, devices, subscription }) {
|
|
183
|
+
this.devices = devices || this.devices;
|
|
184
|
+
this.subscription = subscription || this.subscription;
|
|
185
|
+
if (!this.devices || !this.subscription) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (id) {
|
|
189
|
+
const product = await this.store?.getProduct({ id, campaign });
|
|
190
|
+
return product?.getOption({
|
|
191
|
+
devices: this.devices,
|
|
192
|
+
subscription: this.subscription,
|
|
193
|
+
bundle: this.option?.getBundle() || []
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return this.option?.getOption({ devices: this.devices, subscription: this.subscription });
|
|
197
|
+
}
|
|
198
|
+
async __applyBundle(option) {
|
|
199
|
+
const devices = option.devices || this.devices;
|
|
200
|
+
const subscription = option.subscription || this.subscription;
|
|
201
|
+
if (!devices || !subscription || !option.id) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
const productToBeBundled = await this.store?.getProduct({ id: option.id, campaign: option.campaign });
|
|
205
|
+
const optionToBeBundled = await productToBeBundled?.getOption({ devices, subscription });
|
|
206
|
+
if (!optionToBeBundled) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
if (this.devices && this.subscription) {
|
|
210
|
+
return this.option?.toogleBundle({
|
|
211
|
+
devicesFixed: Boolean(option.devices),
|
|
212
|
+
subscriptionFixed: Boolean(option.subscription),
|
|
213
|
+
option: optionToBeBundled
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
__decorate([
|
|
220
|
+
provide({ context: optionContext }),
|
|
221
|
+
property({ attribute: false })
|
|
222
|
+
], OptionNode.prototype, "_optionContext", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
consume({ context: dataLayerContext, subscribe: true }),
|
|
225
|
+
property({ attribute: false })
|
|
226
|
+
], OptionNode.prototype, "_dataLayer", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
consume({ context: productContext, subscribe: true }),
|
|
229
|
+
property({ attribute: false })
|
|
230
|
+
], OptionNode.prototype, "product", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ attribute: false })
|
|
233
|
+
], OptionNode.prototype, "bundle", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Number })
|
|
236
|
+
], OptionNode.prototype, "devices", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: Number })
|
|
239
|
+
], OptionNode.prototype, "subscription", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property()
|
|
242
|
+
], OptionNode.prototype, "dataLayerEvent", void 0);
|
|
243
|
+
OptionNode = __decorate([
|
|
244
|
+
customElement('bd-option')
|
|
245
|
+
], OptionNode);
|
|
246
|
+
export { OptionNode };
|
|
247
|
+
//# sourceMappingURL=node.option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.option.js","sourceRoot":"","sources":["../../../src/nodes/node.option.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,aAAa,EAAqB,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IA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B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;gBAC/B,YAAY,EAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC1C,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;gBAC/C,MAAM,EAAa,iBAAiB;aACrC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF,CAAA;AArRC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDACI;AAInC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8CACG;AAIlC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACrD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACF;AAG7B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;0CACM;AAGrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACL;AAItB;IADC,QAAQ,EAAE;kDACgC;AAxBhC,UAAU;IADtB,aAAa,CAAC,WAAW,CAAC;GACd,UAAU,CAwRtB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Product } from "@repobit/dex-store";
|
|
2
|
+
import { StateNode } from "./node.state.js";
|
|
3
|
+
export declare class ProductNode extends StateNode {
|
|
4
|
+
autoForward: boolean;
|
|
5
|
+
productId?: string;
|
|
6
|
+
campaign?: string;
|
|
7
|
+
product?: Product;
|
|
8
|
+
private _productChangeEvent;
|
|
9
|
+
private _forwardEventTask;
|
|
10
|
+
private __loadProductTask;
|
|
11
|
+
private _etaProductRenderTask;
|
|
12
|
+
protected shouldRunEtaStateRender(): boolean;
|
|
13
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { productContext } from "../contexts/context.product.js";
|
|
8
|
+
import { ActionEvent } from "../events/events.js";
|
|
9
|
+
import { toDSLContext } from "../renders/context.js";
|
|
10
|
+
import { provide } from "@lit/context";
|
|
11
|
+
import { Task } from "@lit/task";
|
|
12
|
+
import { customElement, property } from "lit/decorators.js";
|
|
13
|
+
import { StateNode } from "./node.state.js";
|
|
14
|
+
let ProductNode = class ProductNode extends StateNode {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
// Use custom forward tasks; disable default passthrough.
|
|
18
|
+
this.autoForward = false;
|
|
19
|
+
// Reflect incoming product-change events and forward original event.
|
|
20
|
+
this._productChangeEvent = new Task(this, {
|
|
21
|
+
task: ([evt]) => {
|
|
22
|
+
if (!evt)
|
|
23
|
+
return null;
|
|
24
|
+
if (this.isProductChange(evt)) {
|
|
25
|
+
this.productId = evt.detail.id;
|
|
26
|
+
this.campaign = evt.detail.campaign;
|
|
27
|
+
}
|
|
28
|
+
this._forwardEvent(this._event);
|
|
29
|
+
this._notifyParent();
|
|
30
|
+
},
|
|
31
|
+
args: () => [this._event]
|
|
32
|
+
});
|
|
33
|
+
// Synthesize product-change events when attributes change locally.
|
|
34
|
+
this._forwardEventTask = new Task(this, {
|
|
35
|
+
task: ([id, campaign]) => {
|
|
36
|
+
const evt = this._event;
|
|
37
|
+
if (evt && this.isProductChange(evt)) {
|
|
38
|
+
const { id: evtId, campaign: evtCampaign } = evt.detail;
|
|
39
|
+
if (evtId === id && evtCampaign === campaign) {
|
|
40
|
+
return; // skip resynthesizing if mirroring incoming event
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (id) {
|
|
44
|
+
this._forwardEvent(new ActionEvent({ id, campaign }));
|
|
45
|
+
this._notifyParent();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
args: () => [this.productId, this.campaign]
|
|
49
|
+
});
|
|
50
|
+
this.__loadProductTask = new Task(this, {
|
|
51
|
+
task: async ([store, id, campaign]) => {
|
|
52
|
+
if (!store || !id) {
|
|
53
|
+
this.product = undefined;
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const product = await store.getProduct({ id, campaign });
|
|
57
|
+
this.product = product;
|
|
58
|
+
return product;
|
|
59
|
+
},
|
|
60
|
+
args: () => [this.store, this.productId, this.campaign]
|
|
61
|
+
});
|
|
62
|
+
// Render text templates for product-specific context in direct children
|
|
63
|
+
this._etaProductRenderTask = new Task(this, {
|
|
64
|
+
task: async ([product, state, derived]) => {
|
|
65
|
+
if (!product)
|
|
66
|
+
return;
|
|
67
|
+
const it = await toDSLContext({ product, state, derived });
|
|
68
|
+
await this._renderEtaTemplates(it);
|
|
69
|
+
},
|
|
70
|
+
args: () => [this.product, this.state, this._derived]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Avoid double-rendering via StateNode's base Eta render;
|
|
74
|
+
// product task includes state in its context.
|
|
75
|
+
shouldRunEtaStateRender() { return false; }
|
|
76
|
+
async getUpdateComplete() {
|
|
77
|
+
const result = await super.getUpdateComplete();
|
|
78
|
+
await this._productChangeEvent.taskComplete;
|
|
79
|
+
await this._forwardEventTask.taskComplete;
|
|
80
|
+
await this.__loadProductTask.taskComplete;
|
|
81
|
+
await this._etaProductRenderTask.taskComplete;
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__decorate([
|
|
86
|
+
property()
|
|
87
|
+
], ProductNode.prototype, "productId", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
property()
|
|
90
|
+
], ProductNode.prototype, "campaign", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
provide({ context: productContext }),
|
|
93
|
+
property({ attribute: false })
|
|
94
|
+
], ProductNode.prototype, "product", void 0);
|
|
95
|
+
ProductNode = __decorate([
|
|
96
|
+
customElement('bd-product')
|
|
97
|
+
], ProductNode);
|
|
98
|
+
export { ProductNode };
|
|
99
|
+
//# sourceMappingURL=node.product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.product.js","sourceRoot":"","sources":["../../../src/nodes/node.product.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,SAAS;IAAnC;;QACL,yDAAyD;QACzD,gBAAW,GAAG,KAAK,CAAC;QAWp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8C;IAC3B,uBAAuB,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAE7D,KAAK,CAAC,iBAAiB;QAC/B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC/C,MAAM,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;QAC5C,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAC1C,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAC1C,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA7EC;IADC,QAAQ,EAAE;8CACQ;AAGnB;IADC,QAAQ,EAAE;6CACO;AAIlB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CACb;AAXP,WAAW;IADvB,aAAa,CAAC,YAAY,CAAC;GACf,WAAW,CAiFvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { dataLayerContextType } from "../contexts/context.datalayer.js";
|
|
2
|
+
import { derivedContextType } from "../contexts/context.derived.js";
|
|
3
|
+
import { optionContextType } from "../contexts/context.option.js";
|
|
4
|
+
import { productContextType } from "../contexts/context.product.js";
|
|
5
|
+
import { storeContextType } from "../contexts/context.store.js";
|
|
6
|
+
import { StateNode } from "./node.state.js";
|
|
7
|
+
export declare class RootNode extends StateNode {
|
|
8
|
+
/**
|
|
9
|
+
* Consumes store provided by root node
|
|
10
|
+
*/
|
|
11
|
+
store?: storeContextType;
|
|
12
|
+
dataLayer?: dataLayerContextType;
|
|
13
|
+
_optionContextDefault?: optionContextType;
|
|
14
|
+
_productContextDefault?: productContextType;
|
|
15
|
+
derived?: derivedContextType | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { dataLayerContext } from "../contexts/context.datalayer.js";
|
|
8
|
+
import { derivedContext } from "../contexts/context.derived.js";
|
|
9
|
+
import { optionContext } from "../contexts/context.option.js";
|
|
10
|
+
import { productContext } from "../contexts/context.product.js";
|
|
11
|
+
import { storeContext } from "../contexts/context.store.js";
|
|
12
|
+
import { provide } from "@lit/context";
|
|
13
|
+
import { customElement, property } from "lit/decorators.js";
|
|
14
|
+
import { StateNode } from "./node.state.js";
|
|
15
|
+
let RootNode = class RootNode extends StateNode {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
// Provide a default answer for optionContext at the root so
|
|
19
|
+
// consumers always receive a value (Promise<null>) even when
|
|
20
|
+
// not inside a <bd-option> subtree. A closer provider overrides it.
|
|
21
|
+
this._optionContextDefault = Promise.resolve(null);
|
|
22
|
+
// Provide a default product context so binders receive a value
|
|
23
|
+
// even outside a <bd-product> subtree (overridden by closer provider).
|
|
24
|
+
this._productContextDefault = null;
|
|
25
|
+
// Provide user-defined derived variables/functions for Eta + DSL
|
|
26
|
+
this.derived = null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
__decorate([
|
|
30
|
+
provide({ context: storeContext }),
|
|
31
|
+
property({ attribute: false })
|
|
32
|
+
], RootNode.prototype, "store", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
provide({ context: dataLayerContext }),
|
|
35
|
+
property({ attribute: false })
|
|
36
|
+
], RootNode.prototype, "dataLayer", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
provide({ context: optionContext }),
|
|
39
|
+
property({ attribute: false })
|
|
40
|
+
], RootNode.prototype, "_optionContextDefault", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
provide({ context: productContext }),
|
|
43
|
+
property({ attribute: false })
|
|
44
|
+
], RootNode.prototype, "_productContextDefault", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
provide({ context: derivedContext }),
|
|
47
|
+
property({ attribute: false })
|
|
48
|
+
], RootNode.prototype, "derived", void 0);
|
|
49
|
+
RootNode = __decorate([
|
|
50
|
+
customElement('bd-root')
|
|
51
|
+
], RootNode);
|
|
52
|
+
export { RootNode };
|
|
53
|
+
//# sourceMappingURL=node.root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.root.js","sourceRoot":"","sources":["../../../src/nodes/node.root.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAqB,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAoB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,SAAS;IAAhC;;QAYL,4DAA4D;QAC5D,6DAA6D;QAC7D,oEAAoE;QAGpE,0BAAqB,GAAuB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElE,+DAA+D;QAC/D,uEAAuE;QAGvE,2BAAsB,GAAwB,IAAI,CAAC;QAEnD,iEAAiE;QAGjE,YAAO,GAA+B,IAAI,CAAC;IAC7C,CAAC;CAAA,CAAA;AAvBC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,EAAG,CAAC;IACnC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uCACN;AAIzB;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACE;AAOjC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACmC;AAMlE;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wDACoB;AAKnD;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCACY;AA5BhC,QAAQ;IADpB,aAAa,CAAC,SAAS,CAAC;GACZ,QAAQ,CA6BpB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { derivedContextType } from "../contexts/context.derived.js";
|
|
2
|
+
import { eventContexType } from "../contexts/context.event.js";
|
|
3
|
+
import { stateContextType } from "../contexts/context.state.js";
|
|
4
|
+
import { storeContextType } from "../contexts/context.store.js";
|
|
5
|
+
import { Action, ActionEvent, CollectAction, CollectOption, CollectUpdateByDelta, EventType, UpdateByDeltaEvent } from "../events/events.js";
|
|
6
|
+
import { ProductBundleOption, ProductOption } from "@repobit/dex-store";
|
|
7
|
+
import { LitElement } from "lit";
|
|
8
|
+
type Options = Map<symbol | string, Promise<ProductOption[]>>;
|
|
9
|
+
type Actions = Map<symbol | string, NonNullable<CollectAction["action"]>>;
|
|
10
|
+
type DeltaUpdate = Map<symbol | string, NonNullable<CollectUpdateByDelta["update"]>>;
|
|
11
|
+
export declare class StateNode extends LitElement {
|
|
12
|
+
autoForward: boolean;
|
|
13
|
+
noCollect: boolean;
|
|
14
|
+
ignoreEvents?: string;
|
|
15
|
+
storeName: symbol | string;
|
|
16
|
+
ignoreEventsParent: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* all options as seens by this node
|
|
19
|
+
* options + partialOptions
|
|
20
|
+
*/
|
|
21
|
+
_options: Options;
|
|
22
|
+
/**
|
|
23
|
+
* all actions as seens by this node
|
|
24
|
+
*/
|
|
25
|
+
_actions: Actions;
|
|
26
|
+
/**
|
|
27
|
+
* all delta updates as seens by this node
|
|
28
|
+
* changes that affect only devices and subscription
|
|
29
|
+
*/
|
|
30
|
+
_deltaUpdates: DeltaUpdate;
|
|
31
|
+
/**
|
|
32
|
+
* all product changes as seens by this node
|
|
33
|
+
*/
|
|
34
|
+
_partialOptions: Actions;
|
|
35
|
+
/**
|
|
36
|
+
* all product changes as seens by this node
|
|
37
|
+
*/
|
|
38
|
+
_partialBundleOptions: Actions;
|
|
39
|
+
/**
|
|
40
|
+
* Consumes store provided by root node
|
|
41
|
+
*/
|
|
42
|
+
store?: storeContextType;
|
|
43
|
+
/**
|
|
44
|
+
* Consumes change event from parent
|
|
45
|
+
*/
|
|
46
|
+
_eventParent?: eventContexType;
|
|
47
|
+
_derived?: derivedContextType | null;
|
|
48
|
+
_event?: eventContexType;
|
|
49
|
+
_eventDom?: eventContexType;
|
|
50
|
+
private _prevParentEventRef?;
|
|
51
|
+
private _prevDomEventRef?;
|
|
52
|
+
/**
|
|
53
|
+
* Provides change event from parent or from it's context
|
|
54
|
+
*/
|
|
55
|
+
_fEvent?: eventContexType;
|
|
56
|
+
/**
|
|
57
|
+
* Local state
|
|
58
|
+
*/
|
|
59
|
+
state: stateContextType;
|
|
60
|
+
/**
|
|
61
|
+
* all options computed by this node
|
|
62
|
+
* options * actions
|
|
63
|
+
*/
|
|
64
|
+
get computedOptions(): ProductOption[] | undefined;
|
|
65
|
+
private _computeTask;
|
|
66
|
+
private _defaultForwardEventTask;
|
|
67
|
+
private _syncEventTask;
|
|
68
|
+
private _prevCollect?;
|
|
69
|
+
private _collectToggleTask;
|
|
70
|
+
private _tplElementTemplates;
|
|
71
|
+
private _tplAttrTemplates;
|
|
72
|
+
private _etaRenderTask;
|
|
73
|
+
protected shouldRunEtaStateRender(): boolean;
|
|
74
|
+
private _isStateNodeElement;
|
|
75
|
+
private _hasNestedStateNode;
|
|
76
|
+
private _safeEtaRender;
|
|
77
|
+
private _renderEtaAttributes;
|
|
78
|
+
private _hasRenderNodes;
|
|
79
|
+
private _morphElementFromHTML;
|
|
80
|
+
protected _renderEtaTemplates(context: object): Promise<void>;
|
|
81
|
+
connectedCallback(): void;
|
|
82
|
+
remove(): void;
|
|
83
|
+
disconnectedCallback(): void;
|
|
84
|
+
protected _eventChange(e: EventType): void;
|
|
85
|
+
protected _forwardEvent(e?: eventContexType): void;
|
|
86
|
+
private _collectOptionEvent;
|
|
87
|
+
collectOption({ name, options }: CollectOption): void;
|
|
88
|
+
private _collectActionEvent;
|
|
89
|
+
private _collectUpdateByDeltaEvent;
|
|
90
|
+
private _computeState;
|
|
91
|
+
private _applyPartials;
|
|
92
|
+
private _applyActions;
|
|
93
|
+
private _applyDeltaUpdates;
|
|
94
|
+
/**
|
|
95
|
+
* Attempts to apply the given delta action to the current value.
|
|
96
|
+
* Returns the updated value and whether we've exhausted variants.
|
|
97
|
+
*/
|
|
98
|
+
private _computeDelta;
|
|
99
|
+
private _computeContext;
|
|
100
|
+
protected _getOption({ id, campaign, devices, subscription }: Partial<Action>, bundle?: ProductBundleOption[]): Promise<ProductOption | null | undefined>;
|
|
101
|
+
private _applyBundles;
|
|
102
|
+
protected _notifyParent(): void;
|
|
103
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
104
|
+
protected isDeviceAndSubscriptionChange(evt: EventType): evt is ActionEvent;
|
|
105
|
+
protected isBundleToogle(evt: EventType): evt is ActionEvent;
|
|
106
|
+
protected isProductChange(evt: EventType): evt is ActionEvent;
|
|
107
|
+
protected isActionEvent(evt: EventType): evt is ActionEvent;
|
|
108
|
+
protected isDeltaUpdate(evt: EventType): evt is UpdateByDeltaEvent;
|
|
109
|
+
protected _isIgnoredSource(e: EventType): boolean;
|
|
110
|
+
private _getIgnoreSet;
|
|
111
|
+
}
|
|
112
|
+
export {};
|