@depict-ai/dpc 1.0.30 → 1.0.31
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/ES10/index.cjs +300 -0
- package/ES10/index.d.ts +153 -0
- package/ES10/index.js +290 -0
- package/latest/index.cjs +295 -0
- package/latest/index.d.ts +153 -0
- package/latest/index.js +285 -0
- package/multi_import_deduplicator.cjs +31 -0
- package/multi_import_deduplicator.mjs +31 -0
- package/package.json +61 -15
- package/dist/index.d.ts +0 -156
- package/dist/main.js +0 -3
- package/dist/module.js +0 -2
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export const version = "1.0.31";
|
|
2
|
+
enum ProductCardType {
|
|
3
|
+
Recommendation = 0,
|
|
4
|
+
SnakeRecommendation = 1,
|
|
5
|
+
SearchResult = 2,
|
|
6
|
+
ProductListingResult = 3,
|
|
7
|
+
}
|
|
8
|
+
type TrackingKey = "recommendation_id" | "search_result_id" | "product_listing_result_id";
|
|
9
|
+
/**
|
|
10
|
+
* The Depict Queue function used to register events to be sent to depict.
|
|
11
|
+
*/
|
|
12
|
+
export type DepictQueue = {
|
|
13
|
+
(eventName: string, ...args: unknown[]): void;
|
|
14
|
+
send_event?: (eventName: string, ...args: unknown[]) => void;
|
|
15
|
+
queue: [string, unknown][];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Depict Object containing everything depict-related on the page.
|
|
19
|
+
*/
|
|
20
|
+
export interface DepictObject {
|
|
21
|
+
eventHistory: [string, unknown][];
|
|
22
|
+
dpq: DepictQueue;
|
|
23
|
+
dpc: DPC;
|
|
24
|
+
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface Window {
|
|
27
|
+
/**
|
|
28
|
+
* Lifted DPQ function for ease-of-use
|
|
29
|
+
*/
|
|
30
|
+
dpq: DepictQueue;
|
|
31
|
+
depict: DepictObject;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Purchase format used by GA4 when sending a purchase event.
|
|
36
|
+
* See https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#make_a_purchase_or_issue_a_refund
|
|
37
|
+
*/
|
|
38
|
+
interface GA4Purchase {
|
|
39
|
+
transaction_id: string;
|
|
40
|
+
currency: string;
|
|
41
|
+
items: GA4PurchaseItem[];
|
|
42
|
+
[additional: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Product format used by GA4 when sending a purchase event.
|
|
46
|
+
* See https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#purchase_item
|
|
47
|
+
*/
|
|
48
|
+
interface GA4PurchaseItem {
|
|
49
|
+
item_id: string;
|
|
50
|
+
price: number;
|
|
51
|
+
quantity: number;
|
|
52
|
+
[additional: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
interface Options {
|
|
55
|
+
/**
|
|
56
|
+
* The initial market. Should be specified if the market is known at the point of intializing DPC.
|
|
57
|
+
*/
|
|
58
|
+
market?: string;
|
|
59
|
+
/**
|
|
60
|
+
* If we should observe for recommendations on creation. If false, you must call `trackRecommendationCard` manually.
|
|
61
|
+
*/
|
|
62
|
+
auto_observe?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export class DPC {
|
|
65
|
+
merchant: string;
|
|
66
|
+
auto_observe: boolean;
|
|
67
|
+
market?: string;
|
|
68
|
+
/** Latest product_id found in the DOM. Used in a2c & pageview events on PDPs. */
|
|
69
|
+
latest_product_id?: string;
|
|
70
|
+
/** The value of location.pathname when latest_product_id was set */
|
|
71
|
+
latest_product_id_path?: string;
|
|
72
|
+
/** Latest session_id set on the client. Used for all events. */
|
|
73
|
+
latest_session_id?: string;
|
|
74
|
+
/** Latest user_id found in the DOM. Used for all events. */
|
|
75
|
+
latest_user_id?: string;
|
|
76
|
+
constructor(merchant: string, options?: Options);
|
|
77
|
+
tracked_elements: WeakSet<HTMLElement>;
|
|
78
|
+
/**
|
|
79
|
+
* Make sure the tracking is not set up twice on the same element.
|
|
80
|
+
*/
|
|
81
|
+
checkIfTracked(element: HTMLElement): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Adds click and impression tracking to a product card
|
|
84
|
+
*/
|
|
85
|
+
trackProductCard(card: HTMLElement, tracking_id: string, type: ProductCardType): void;
|
|
86
|
+
/**
|
|
87
|
+
* Adds tracking to an Add to cart button.
|
|
88
|
+
*/
|
|
89
|
+
trackAddToCartButton(button: HTMLElement, productCard?: HTMLElement): void;
|
|
90
|
+
/**
|
|
91
|
+
* Sends an Add to Cart Event to depict
|
|
92
|
+
* If the add to cart unmistakably happened due to a click on a product card shown because of Depict (for example the add to cart button on a product card), set recommendation_id / search_result_id / product_listing_result_id (whatever applicable). If it happened on a PDP, set product_id instead.
|
|
93
|
+
*/
|
|
94
|
+
sendAddToCartEvent(data: {
|
|
95
|
+
product_id?: string;
|
|
96
|
+
} & { [x in TrackingKey]?: string }): void;
|
|
97
|
+
/**
|
|
98
|
+
* Sends a recommendation impression event to Depict
|
|
99
|
+
*/
|
|
100
|
+
sendRecommendationImpressionEvent(recommendation_id: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* Sends a search result impression event to Depict
|
|
103
|
+
*/
|
|
104
|
+
sendSearchResultImpressionEvent(search_result_id: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Sends a product listing result impression event to Depict
|
|
107
|
+
*/
|
|
108
|
+
sendProductListingResultImpressionEvent(product_listing_result_id: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Sends a recommendation click event to Depict
|
|
111
|
+
*/
|
|
112
|
+
sendRecommendationClickEvent(recommendation_id: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Sends a search result click event to Depict
|
|
115
|
+
*/
|
|
116
|
+
sendSearchResultClickEvent(search_result_id: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Sends a product listing result click event to Depict
|
|
119
|
+
*/
|
|
120
|
+
sendProductListingResultClickEvent(product_listing_result_id: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Sends a Purchase Event to Depict
|
|
123
|
+
*/
|
|
124
|
+
sendPurchaseEvent(data: GA4Purchase): void;
|
|
125
|
+
/**
|
|
126
|
+
* Update the market used for tracking events
|
|
127
|
+
*/
|
|
128
|
+
setMarket(market: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
131
|
+
*/
|
|
132
|
+
setProductId(product_id: string): void;
|
|
133
|
+
/**
|
|
134
|
+
* Set the user_id for logged in users.
|
|
135
|
+
*
|
|
136
|
+
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
137
|
+
*/
|
|
138
|
+
setUserId(user_id?: string | null): void;
|
|
139
|
+
/**
|
|
140
|
+
* Set the current session_id.
|
|
141
|
+
*
|
|
142
|
+
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
143
|
+
*/
|
|
144
|
+
setSessionId(session_id?: string | null): void;
|
|
145
|
+
/**
|
|
146
|
+
* Observe the DOM for recommendations to track
|
|
147
|
+
*/
|
|
148
|
+
observeRecommendations(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Observe the dom for add to cart buttons. Used on product detail pages.
|
|
151
|
+
*/
|
|
152
|
+
observePDPA2CButton(): void;
|
|
153
|
+
}
|
package/latest/index.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { add_to_version_info as t, dlog as e, impression_track_element as i, derror as s, depict_click as r, foolproof_send_beacon as n, observer as o, instant_exec_on_suspect_history_change as a, catchify as d, get_tracking_event_context_data as c, send_depict_unfiltered as u } from "@depict-ai/utilishared/latest";
|
|
2
|
+
import h from "@babel/runtime/helpers/classPrivateFieldLooseBase";
|
|
3
|
+
import _ from "@babel/runtime/helpers/classPrivateFieldLooseKey";
|
|
4
|
+
/*! Depict PerformanceClient */
|
|
5
|
+
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
6
|
+
register_es_version("performance-client", "latest");
|
|
7
|
+
const l = "1.0.31";
|
|
8
|
+
let m;
|
|
9
|
+
var p;
|
|
10
|
+
(p = m || (m = {}))[p.Recommendation = 0] = "Recommendation", p[p.SnakeRecommendation = 1] = "SnakeRecommendation", p[p.SearchResult = 2] = "SearchResult", p[p.ProductListingResult = 3] = "ProductListingResult";
|
|
11
|
+
const v = {
|
|
12
|
+
[m.Recommendation]: "recommendation_id",
|
|
13
|
+
[m.SnakeRecommendation]: "recommendation_id",
|
|
14
|
+
[m.SearchResult]: "search_result_id",
|
|
15
|
+
[m.ProductListingResult]: "product_listing_result_id"
|
|
16
|
+
},
|
|
17
|
+
f = ".depict-add-to-cart",
|
|
18
|
+
k = {
|
|
19
|
+
"data-recommendation_id": m.SnakeRecommendation,
|
|
20
|
+
"data-recommendation-id": m.Recommendation,
|
|
21
|
+
"data-search-result-id": m.SearchResult,
|
|
22
|
+
"data-product-listing-result-id": m.ProductListingResult
|
|
23
|
+
};
|
|
24
|
+
const g = (t, e) => {
|
|
25
|
+
if ("number" == typeof e && !isNaN(e)) return e.toString();
|
|
26
|
+
if ("string" != typeof e) throw new Error(`${t} event requires a string as an argument`);
|
|
27
|
+
return e;
|
|
28
|
+
},
|
|
29
|
+
y = (t, e) => null == e ? e : g(t, e),
|
|
30
|
+
b = (t, e, i) => {
|
|
31
|
+
if ("purchase" !== e) "number" == typeof i && (i = i.toString()), "addToCart" === e ? t.sendAddToCartEvent({
|
|
32
|
+
product_id: g(e, i)
|
|
33
|
+
}) : "setMarket" === e ? t.setMarket(g(e, i)) : "setProductId" === e ? t.setProductId(g(e, i)) : "setUserId" === e ? t.setUserId(y(e, i)) : "setSessionId" === e && t.setSessionId(y(e, i));else {
|
|
34
|
+
if (!(t => {
|
|
35
|
+
if ("object" != typeof t || null === t) throw new Error("purchase event requires an object as an argument");
|
|
36
|
+
if (!Array.isArray(t.items)) throw new Error("purchase event requires an items array of purchased products");
|
|
37
|
+
if (!t.currency || "string" != typeof t.currency) throw new Error("purchase event requires a currency string");
|
|
38
|
+
if (!t.transaction_id || "string" != typeof t.transaction_id && "number" != typeof t.transaction_id) throw new Error("purchase event requires a transaction_id string");
|
|
39
|
+
t.transaction_id = t.transaction_id.toString();
|
|
40
|
+
for (const e of t.items) {
|
|
41
|
+
if ("" == e.item_id || "string" != typeof e.item_id && ("number" != typeof e.item_id || isNaN(e.item_id))) throw new Error("purchased item requires an item_id of the purchased product");
|
|
42
|
+
if (isNaN(e.price)) throw new Error("purchase item requires a unit price for the product purchased");
|
|
43
|
+
if (!e.quantity || isNaN(e.quantity)) throw new Error("purchase item requires a quantity of products purchased");
|
|
44
|
+
e.item_id = e.item_id.toString();
|
|
45
|
+
}
|
|
46
|
+
return !0;
|
|
47
|
+
})(i)) return;
|
|
48
|
+
t.sendPurchaseEvent(i);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
w = t => {
|
|
52
|
+
const e = window.dpq ||= function () {
|
|
53
|
+
const t = function () {
|
|
54
|
+
const e = arguments;
|
|
55
|
+
t.send_event ? t.send_event.apply(this, e) : t.queue.push(e);
|
|
56
|
+
};
|
|
57
|
+
return t.queue = [], t;
|
|
58
|
+
}(),
|
|
59
|
+
i = window.depict ||= {};
|
|
60
|
+
i.dpq = e, i.eventHistory = e.queue, i.dpc = t, e.send_event || (e.send_event = (i, s) => {
|
|
61
|
+
e.queue.push([i, s]), b(t, i, s);
|
|
62
|
+
}, e.queue.forEach(([e, i]) => {
|
|
63
|
+
b(t, e, i);
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
var R = _("has_sent_pageview_for_current_href"),
|
|
67
|
+
E = _("resetSentPageViewForCurrentHref"),
|
|
68
|
+
P = _("parseOptions"),
|
|
69
|
+
S = _("getContextData"),
|
|
70
|
+
C = _("sendTrackingEvent"),
|
|
71
|
+
q = _("getProductId");
|
|
72
|
+
class I {
|
|
73
|
+
constructor(t, i) {
|
|
74
|
+
if (Object.defineProperty(this, q, {
|
|
75
|
+
value: N
|
|
76
|
+
}), Object.defineProperty(this, C, {
|
|
77
|
+
value: T
|
|
78
|
+
}), Object.defineProperty(this, S, {
|
|
79
|
+
value: j
|
|
80
|
+
}), Object.defineProperty(this, P, {
|
|
81
|
+
value: L
|
|
82
|
+
}), Object.defineProperty(this, E, {
|
|
83
|
+
value: A
|
|
84
|
+
}), this.merchant = void 0, this.auto_observe = !0, this.market = void 0, this.latest_product_id = void 0, this.latest_product_id_path = void 0, this.latest_session_id = void 0, this.latest_user_id = void 0, Object.defineProperty(this, R, {
|
|
85
|
+
writable: !0,
|
|
86
|
+
value: !1
|
|
87
|
+
}), this.tracked_elements = new WeakSet(), window.depict?.dpc instanceof I) return e("DPC already initialized. Returning existing instance."), window.depict.dpc;
|
|
88
|
+
w(this), this.merchant = t, h(this, P)[P](i), h(this, E)[E](), this.auto_observe && (this.observeRecommendations(), this.observePDPA2CButton());
|
|
89
|
+
}
|
|
90
|
+
checkIfTracked(t) {
|
|
91
|
+
return this.tracked_elements.has(t) ? (e("Already tracked", t), !0) : (this.tracked_elements.add(t), !1);
|
|
92
|
+
}
|
|
93
|
+
trackProductCard(t, e, s) {
|
|
94
|
+
if (this.checkIfTracked(t)) return;
|
|
95
|
+
switch (s) {
|
|
96
|
+
case m.Recommendation:
|
|
97
|
+
case m.SnakeRecommendation:
|
|
98
|
+
t.addEventListener("click", () => this.sendRecommendationClickEvent(e)), i({
|
|
99
|
+
element: t,
|
|
100
|
+
data: {
|
|
101
|
+
recommendation_id: e,
|
|
102
|
+
...h(this, S)[S]()
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
case m.SearchResult:
|
|
107
|
+
t.addEventListener("click", () => this.sendSearchResultClickEvent(e)), i({
|
|
108
|
+
element: t,
|
|
109
|
+
data: {
|
|
110
|
+
search_result_id: e,
|
|
111
|
+
...h(this, S)[S]()
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
case m.ProductListingResult:
|
|
116
|
+
t.addEventListener("click", () => this.sendProductListingResultClickEvent(e)), i({
|
|
117
|
+
element: t,
|
|
118
|
+
data: {
|
|
119
|
+
product_listing_result_id: e,
|
|
120
|
+
...h(this, S)[S]()
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const r = t.querySelectorAll(f);
|
|
125
|
+
for (const e of r) this.trackAddToCartButton(e, t);
|
|
126
|
+
}
|
|
127
|
+
trackAddToCartButton(t, e) {
|
|
128
|
+
this.checkIfTracked(t) || t.addEventListener("click", () => {
|
|
129
|
+
if (!e) {
|
|
130
|
+
const e = h(this, q)[q]();
|
|
131
|
+
return e ? void this.sendAddToCartEvent({
|
|
132
|
+
product_id: e
|
|
133
|
+
}) : void s("No product ID set for add-to-cart click outside of product card", t);
|
|
134
|
+
}
|
|
135
|
+
for (const [t, i] of Object.entries(k)) {
|
|
136
|
+
const s = e.getAttribute(t);
|
|
137
|
+
if (!s) continue;
|
|
138
|
+
const r = {
|
|
139
|
+
[v[i]]: s
|
|
140
|
+
};
|
|
141
|
+
return void this.sendAddToCartEvent(r);
|
|
142
|
+
}
|
|
143
|
+
s("Could not find tracking data for add-to-cart click on button", t);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
sendAddToCartEvent(t) {
|
|
147
|
+
h(this, C)[C]({
|
|
148
|
+
type: "add_to_cart",
|
|
149
|
+
...t
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
sendRecommendationImpressionEvent(t) {
|
|
153
|
+
h(this, C)[C]({
|
|
154
|
+
type: "element_visible",
|
|
155
|
+
recommendation_id: t
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
sendSearchResultImpressionEvent(t) {
|
|
159
|
+
h(this, C)[C]({
|
|
160
|
+
type: "element_visible",
|
|
161
|
+
search_result_id: t
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
sendProductListingResultImpressionEvent(t) {
|
|
165
|
+
h(this, C)[C]({
|
|
166
|
+
type: "element_visible",
|
|
167
|
+
product_listing_result_id: t
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
sendRecommendationClickEvent(t) {
|
|
171
|
+
r({
|
|
172
|
+
recommendation_id: t,
|
|
173
|
+
...h(this, S)[S]()
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
sendSearchResultClickEvent(t) {
|
|
177
|
+
r({
|
|
178
|
+
search_result_id: t,
|
|
179
|
+
...h(this, S)[S]()
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
sendProductListingResultClickEvent(t) {
|
|
183
|
+
r({
|
|
184
|
+
product_listing_result_id: t,
|
|
185
|
+
...h(this, S)[S]()
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
sendPurchaseEvent(t) {
|
|
189
|
+
if (!this.market) throw Error("Market not set");
|
|
190
|
+
const {
|
|
191
|
+
dsid: e,
|
|
192
|
+
user_id: i,
|
|
193
|
+
session_id: s
|
|
194
|
+
} = h(this, S)[S](),
|
|
195
|
+
r = t.items.map(t => ({
|
|
196
|
+
sku: t.item_id,
|
|
197
|
+
price: t.price,
|
|
198
|
+
quantity: t.quantity
|
|
199
|
+
})),
|
|
200
|
+
o = {
|
|
201
|
+
events: [{
|
|
202
|
+
event_type: "purchase",
|
|
203
|
+
dsid: e,
|
|
204
|
+
user_id: i,
|
|
205
|
+
session_id: s,
|
|
206
|
+
transaction_id: t.transaction_id,
|
|
207
|
+
currency: t.currency,
|
|
208
|
+
products: r
|
|
209
|
+
}],
|
|
210
|
+
tenant: this.merchant,
|
|
211
|
+
market: this.market
|
|
212
|
+
};
|
|
213
|
+
n(process.env.BASE_URL + "/v2/create-events", o);
|
|
214
|
+
}
|
|
215
|
+
setMarket(t) {
|
|
216
|
+
this.market = t;
|
|
217
|
+
}
|
|
218
|
+
setProductId(t) {
|
|
219
|
+
e("Setting product id", t), this.latest_product_id = t, this.latest_product_id_path = location.pathname, h(this, R)[R] || (h(this, C)[C]({
|
|
220
|
+
type: "page_view",
|
|
221
|
+
product_id: t
|
|
222
|
+
}), h(this, R)[R] = !0);
|
|
223
|
+
}
|
|
224
|
+
setUserId(t) {
|
|
225
|
+
e("Setting user id", t), this.latest_user_id = t || void 0;
|
|
226
|
+
}
|
|
227
|
+
setSessionId(t) {
|
|
228
|
+
e("Setting session id", t), this.latest_session_id = t || void 0;
|
|
229
|
+
}
|
|
230
|
+
observeRecommendations() {
|
|
231
|
+
for (const [t, i] of Object.entries(k)) {
|
|
232
|
+
const r = `[${t}]`;
|
|
233
|
+
e("Starting to observe product cards with selector", r), o.onexists(r, ({
|
|
234
|
+
element: e
|
|
235
|
+
}) => {
|
|
236
|
+
const n = e.getAttribute(t);
|
|
237
|
+
n ? this.trackProductCard(e, n, i) : s(`No tracking id found on element with attribute ${r}`, e);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
observePDPA2CButton() {
|
|
242
|
+
o.onexists(f, ({
|
|
243
|
+
element: t
|
|
244
|
+
}) => {
|
|
245
|
+
const i = Object.keys(k).map(t => `[${t}]`).join(","),
|
|
246
|
+
s = t.closest(i) || void 0;
|
|
247
|
+
e(`Found ${s ? "product card" : "pdp"} add-to-cart button`, t), this.trackAddToCartButton(t, s);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function A() {
|
|
252
|
+
let t = location.href;
|
|
253
|
+
a.add(d(() => {
|
|
254
|
+
const {
|
|
255
|
+
href: e
|
|
256
|
+
} = location;
|
|
257
|
+
t !== e && (h(this, R)[R] = !1, t = e);
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
function L(t) {
|
|
261
|
+
void 0 !== t && (void 0 !== t.auto_observe && (this.auto_observe = t.auto_observe), void 0 !== t.market && (this.market = t.market));
|
|
262
|
+
}
|
|
263
|
+
function j() {
|
|
264
|
+
const t = {
|
|
265
|
+
market: this.market,
|
|
266
|
+
tenant: this.merchant,
|
|
267
|
+
user_id: this.latest_user_id,
|
|
268
|
+
session_id: this.latest_session_id
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
...c(),
|
|
272
|
+
...t
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function T(t) {
|
|
276
|
+
u([{
|
|
277
|
+
...t,
|
|
278
|
+
...h(this, S)[S]()
|
|
279
|
+
}], !0);
|
|
280
|
+
}
|
|
281
|
+
function N() {
|
|
282
|
+
if (this.latest_product_id_path === location.pathname) return this.latest_product_id;
|
|
283
|
+
}
|
|
284
|
+
t("dpc", l);
|
|
285
|
+
export { I as DPC, l as version };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* To prevent that people accidentally import multiple flavours of the same type (i.e. @depict-ai/utilishared/latest and @depict-ai/utilishared/ES7) we have this module which needs to not be transformed by babel or bundled by parcel and therefore has to support ES5
|
|
3
|
+
*/
|
|
4
|
+
var versions_imported = [];
|
|
5
|
+
|
|
6
|
+
function register_es_version(package_name, es_version) {
|
|
7
|
+
package_name = "@depict-ai/" + package_name;
|
|
8
|
+
var already_imported = [];
|
|
9
|
+
for (var i = 0; i < versions_imported.length; i++) {
|
|
10
|
+
already_imported.push(package_name + "/" + versions_imported[i]);
|
|
11
|
+
}
|
|
12
|
+
var has_this_version = versions_imported.indexOf(es_version) !== -1;
|
|
13
|
+
if (!has_this_version) {
|
|
14
|
+
versions_imported.push(es_version);
|
|
15
|
+
}
|
|
16
|
+
if (versions_imported.length > 1) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You're trying to import multiple transpiled versions of " +
|
|
19
|
+
package_name +
|
|
20
|
+
"! Already imported: " +
|
|
21
|
+
already_imported.join(", ") +
|
|
22
|
+
" and you're trying to import " +
|
|
23
|
+
package_name +
|
|
24
|
+
"/" +
|
|
25
|
+
es_version +
|
|
26
|
+
" or a dependant thereof"
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { register_es_version };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* To prevent that people accidentally import multiple flavours of the same type (i.e. @depict-ai/utilishared/latest and @depict-ai/utilishared/ES7) we have this module which needs to not be transformed by babel or bundled by parcel and therefore has to support ES5
|
|
3
|
+
*/
|
|
4
|
+
var versions_imported = [];
|
|
5
|
+
|
|
6
|
+
function register_es_version(package_name, es_version) {
|
|
7
|
+
package_name = "@depict-ai/" + package_name;
|
|
8
|
+
var already_imported = [];
|
|
9
|
+
for (var i = 0; i < versions_imported.length; i++) {
|
|
10
|
+
already_imported.push(package_name + "/" + versions_imported[i]);
|
|
11
|
+
}
|
|
12
|
+
var has_this_version = versions_imported.indexOf(es_version) !== -1;
|
|
13
|
+
if (!has_this_version) {
|
|
14
|
+
versions_imported.push(es_version);
|
|
15
|
+
}
|
|
16
|
+
if (versions_imported.length > 1) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You're trying to import multiple transpiled versions of " +
|
|
19
|
+
package_name +
|
|
20
|
+
"! Already imported: " +
|
|
21
|
+
already_imported.join(", ") +
|
|
22
|
+
" and you're trying to import " +
|
|
23
|
+
package_name +
|
|
24
|
+
"/" +
|
|
25
|
+
es_version +
|
|
26
|
+
" or a dependant thereof"
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { register_es_version };
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/dpc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
|
-
"source": "
|
|
6
|
-
"
|
|
7
|
-
"module": "dist/module.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"source": "./src/index.ts",
|
|
6
|
+
"types": "ES10/index.d.ts",
|
|
9
7
|
"description": "Depict Performance Client",
|
|
10
8
|
"license": "MIT",
|
|
11
9
|
"publishConfig": {
|
|
12
10
|
"access": "public"
|
|
13
11
|
},
|
|
12
|
+
"type": "module",
|
|
14
13
|
"scripts": {
|
|
15
14
|
"serve": "yarn workspace depict-ai parcel serve --port 1234 --target dev --hmr-port 2345 ./packages/performance-client/index_cdn.ts",
|
|
16
15
|
"build": "./scripts/build",
|
|
@@ -19,32 +18,79 @@
|
|
|
19
18
|
"typecheck": "yarn g:tsc --build tsconfig.json"
|
|
20
19
|
},
|
|
21
20
|
"targets": {
|
|
22
|
-
"
|
|
21
|
+
"module_latest": {
|
|
22
|
+
"outputFormat": "esmodule",
|
|
23
23
|
"isLibrary": true,
|
|
24
|
-
"context": "
|
|
24
|
+
"context": "node",
|
|
25
25
|
"engines": {
|
|
26
26
|
"browsers": "last 1 chrome version"
|
|
27
27
|
},
|
|
28
28
|
"optimize": true
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"main_latest": {
|
|
31
|
+
"outputFormat": "commonjs",
|
|
31
32
|
"isLibrary": true,
|
|
32
|
-
"context": "
|
|
33
|
+
"context": "node",
|
|
33
34
|
"engines": {
|
|
34
35
|
"browsers": "last 1 chrome version"
|
|
35
36
|
},
|
|
36
37
|
"optimize": true
|
|
38
|
+
},
|
|
39
|
+
"module_es10": {
|
|
40
|
+
"outputFormat": "esmodule",
|
|
41
|
+
"isLibrary": true,
|
|
42
|
+
"context": "node",
|
|
43
|
+
"engines": {
|
|
44
|
+
"browsers": "supports array-flat"
|
|
45
|
+
},
|
|
46
|
+
"optimize": true
|
|
47
|
+
},
|
|
48
|
+
"main_es10": {
|
|
49
|
+
"outputFormat": "commonjs",
|
|
50
|
+
"isLibrary": true,
|
|
51
|
+
"context": "node",
|
|
52
|
+
"engines": {
|
|
53
|
+
"browsers": "supports array-flat"
|
|
54
|
+
},
|
|
55
|
+
"optimize": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"exports": {
|
|
59
|
+
".": {
|
|
60
|
+
"types": "./ES10/index.d.ts",
|
|
61
|
+
"import": "./ES10/index.js",
|
|
62
|
+
"require": "./ES10/index.cjs"
|
|
63
|
+
},
|
|
64
|
+
"./latest": {
|
|
65
|
+
"types": "./latest/index.d.ts",
|
|
66
|
+
"import": "./latest/index.js",
|
|
67
|
+
"require": "./latest/index.cjs"
|
|
68
|
+
},
|
|
69
|
+
"./ES10": {
|
|
70
|
+
"types": "./ES10/index.d.ts",
|
|
71
|
+
"import": "./ES10/index.js",
|
|
72
|
+
"require": "./ES10/index.cjs"
|
|
37
73
|
}
|
|
38
74
|
},
|
|
75
|
+
"files": [
|
|
76
|
+
"/latest",
|
|
77
|
+
"/ES10",
|
|
78
|
+
"./multi_import_deduplicator.mjs",
|
|
79
|
+
"./multi_import_deduplicator.cjs"
|
|
80
|
+
],
|
|
39
81
|
"devDependencies": {
|
|
40
82
|
"@babel/core": "latest",
|
|
41
|
-
"@babel/runtime": "^7.21.0",
|
|
42
83
|
"@parcel/resolver-default": "^2.8.0",
|
|
43
|
-
"@types/node": "^18.11.10"
|
|
84
|
+
"@types/node": "^18.11.10",
|
|
85
|
+
"parcel": "latest"
|
|
44
86
|
},
|
|
45
87
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
|
|
88
|
+
"@babel/plugin-transform-typescript": "^7.22.9",
|
|
89
|
+
"@babel/runtime": "latest",
|
|
90
|
+
"@babel/runtime-corejs3": "^7.22.6",
|
|
91
|
+
"@depict-ai/types": "^1.0.33",
|
|
92
|
+
"@depict-ai/utilishared": "^1.0.29"
|
|
93
|
+
},
|
|
94
|
+
"main": "ES10/index.cjs",
|
|
95
|
+
"module": "ES10/index.js"
|
|
50
96
|
}
|