@adobe/alloy 2.29.0 → 2.30.0-beta.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/libEs5/components/PushNotifications/helpers/constants.js +19 -0
- package/libEs5/components/PushNotifications/helpers/readFromIndexedDb.js +41 -0
- package/libEs5/components/PushNotifications/helpers/saveToIndexedDb.js +50 -0
- package/libEs5/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.js +85 -0
- package/libEs5/components/PushNotifications/helpers/serviceWorkerPushListener.js +70 -0
- package/libEs5/components/PushNotifications/index.js +43 -10
- package/libEs5/components/PushNotifications/request/createSendPushSubscriptionPayload.js +3 -3
- package/libEs5/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +8 -3
- package/libEs5/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +146 -0
- package/libEs5/components/PushNotifications/serviceWorker.js +91 -0
- package/libEs5/components/PushNotifications/types.js +81 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/utils/index.js +19 -0
- package/libEs5/utils/indexedDb.js +73 -0
- package/libEs6/components/PushNotifications/helpers/constants.js +16 -0
- package/libEs6/components/PushNotifications/helpers/readFromIndexedDb.js +40 -0
- package/libEs6/components/PushNotifications/helpers/saveToIndexedDb.js +48 -0
- package/libEs6/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.js +82 -0
- package/libEs6/components/PushNotifications/helpers/serviceWorkerPushListener.js +69 -0
- package/libEs6/components/PushNotifications/index.js +43 -10
- package/libEs6/components/PushNotifications/request/createSendPushSubscriptionPayload.js +3 -3
- package/libEs6/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +8 -3
- package/libEs6/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +146 -0
- package/libEs6/components/PushNotifications/serviceWorker.js +90 -0
- package/libEs6/components/PushNotifications/types.js +81 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/utils/index.js +1 -0
- package/libEs6/utils/indexedDb.js +67 -0
- package/package.json +29 -36
- package/scripts/alloyBuilder.js +130 -4
- package/types/components/PushNotifications/helpers/constants.d.ts +5 -0
- package/types/components/PushNotifications/helpers/constants.d.ts.map +1 -0
- package/types/components/PushNotifications/helpers/readFromIndexedDb.d.ts +4 -0
- package/types/components/PushNotifications/helpers/readFromIndexedDb.d.ts.map +1 -0
- package/types/components/PushNotifications/helpers/saveToIndexedDb.d.ts +9 -0
- package/types/components/PushNotifications/helpers/saveToIndexedDb.d.ts.map +1 -0
- package/types/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.d.ts +9 -0
- package/types/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.d.ts.map +1 -0
- package/types/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts +8 -0
- package/types/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts.map +1 -0
- package/types/components/PushNotifications/index.d.ts +11 -3
- package/types/components/PushNotifications/index.d.ts.map +1 -1
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts +2 -2
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts.map +1 -1
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +2 -1
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts.map +1 -1
- package/types/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts +11 -0
- package/types/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts.map +1 -0
- package/types/components/PushNotifications/serviceWorker.d.ts +2 -0
- package/types/components/PushNotifications/serviceWorker.d.ts.map +1 -0
- package/types/components/PushNotifications/types.d.ts +167 -0
- package/types/components/PushNotifications/types.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/indexedDb.d.ts +4 -0
- package/types/utils/indexedDb.d.ts.map +1 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* eslint-disable no-underscore-dangle */
|
|
14
|
+
|
|
15
|
+
/** @import { ServiceWorkerLogger } from '../types.js' */
|
|
16
|
+
/** @import { TrackingDataPayload } from '../types.js' */
|
|
17
|
+
|
|
18
|
+
import readFromIndexedDb from "../helpers/readFromIndexedDb.js";
|
|
19
|
+
import uuidv4 from "../../../utils/uuid.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @async
|
|
23
|
+
* @function
|
|
24
|
+
* @param {Object} options
|
|
25
|
+
* @param {Object} options.xdm
|
|
26
|
+
* @param {string} [options.actionLabel]
|
|
27
|
+
* @param {number} [options.applicationLaunches=0]
|
|
28
|
+
* @param {Object} utils
|
|
29
|
+
* @param {ServiceWorkerLogger} utils.logger
|
|
30
|
+
* @param {(url: string, options: object) => Promise<Response>} utils.fetch
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<boolean>}
|
|
33
|
+
* @throws {Error}
|
|
34
|
+
*/
|
|
35
|
+
export default async ({
|
|
36
|
+
xdm,
|
|
37
|
+
actionLabel,
|
|
38
|
+
applicationLaunches = 0
|
|
39
|
+
}, {
|
|
40
|
+
logger,
|
|
41
|
+
fetch
|
|
42
|
+
}) => {
|
|
43
|
+
const configData = await readFromIndexedDb(logger);
|
|
44
|
+
const {
|
|
45
|
+
browser,
|
|
46
|
+
ecid,
|
|
47
|
+
edgeDomain,
|
|
48
|
+
edgeBasePath,
|
|
49
|
+
datastreamId,
|
|
50
|
+
datasetId
|
|
51
|
+
} = configData || {};
|
|
52
|
+
let customActionData = {};
|
|
53
|
+
if (actionLabel) {
|
|
54
|
+
customActionData = {
|
|
55
|
+
customAction: {
|
|
56
|
+
actionID: actionLabel
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const requiredFields = [{
|
|
61
|
+
name: "browser",
|
|
62
|
+
errorField: "Browser"
|
|
63
|
+
}, {
|
|
64
|
+
name: "ecid",
|
|
65
|
+
errorField: "ECID"
|
|
66
|
+
}, {
|
|
67
|
+
name: "edgeDomain",
|
|
68
|
+
errorField: "Edge domain"
|
|
69
|
+
}, {
|
|
70
|
+
name: "edgeBasePath",
|
|
71
|
+
errorField: "Edge base path"
|
|
72
|
+
}, {
|
|
73
|
+
name: "datastreamId",
|
|
74
|
+
errorField: "Datastream ID"
|
|
75
|
+
}, {
|
|
76
|
+
name: "datasetId",
|
|
77
|
+
errorField: "Dataset ID"
|
|
78
|
+
}];
|
|
79
|
+
try {
|
|
80
|
+
for (const field of requiredFields) {
|
|
81
|
+
if (!configData[field.name]) {
|
|
82
|
+
throw new Error(`Cannot send tracking call. ${field.errorField} is missing.`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const url = `https://${edgeDomain}/${edgeBasePath}/v1/interact?configId=${datastreamId}`;
|
|
86
|
+
|
|
87
|
+
/** @type {TrackingDataPayload} */
|
|
88
|
+
const payload = {
|
|
89
|
+
events: [{
|
|
90
|
+
xdm: {
|
|
91
|
+
identityMap: {
|
|
92
|
+
ECID: [{
|
|
93
|
+
id: ecid
|
|
94
|
+
}]
|
|
95
|
+
},
|
|
96
|
+
timestamp: new Date().toISOString(),
|
|
97
|
+
pushNotificationTracking: {
|
|
98
|
+
...customActionData,
|
|
99
|
+
pushProviderMessageID: uuidv4(),
|
|
100
|
+
pushProvider: browser.toLowerCase()
|
|
101
|
+
},
|
|
102
|
+
application: {
|
|
103
|
+
launches: {
|
|
104
|
+
value: applicationLaunches
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
eventType: actionLabel ? "pushTracking.customAction" : "pushTracking.applicationOpened",
|
|
108
|
+
_experience: {
|
|
109
|
+
...xdm._experience,
|
|
110
|
+
customerJourneyManagement: {
|
|
111
|
+
...xdm._experience.customerJourneyManagement,
|
|
112
|
+
pushChannelContext: {
|
|
113
|
+
platform: "web"
|
|
114
|
+
},
|
|
115
|
+
messageProfile: {
|
|
116
|
+
channel: {
|
|
117
|
+
_id: "https://ns.adobe.com/xdm/channels/push"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
meta: {
|
|
124
|
+
collect: {
|
|
125
|
+
datasetId
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}]
|
|
129
|
+
};
|
|
130
|
+
const response = await fetch(url, {
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: {
|
|
133
|
+
"content-type": "text/plain; charset=UTF-8"
|
|
134
|
+
},
|
|
135
|
+
body: JSON.stringify(payload)
|
|
136
|
+
});
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
logger.error("Tracking call failed: ", response.status, response.statusText);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
logger.error("Error sending tracking call:", error);
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** @import { ServiceWorkerLogger } from './types.js' */
|
|
14
|
+
|
|
15
|
+
import serviceWorkerNotificationClickListener from "./helpers/serviceWorkerNotificationClickListener.js";
|
|
16
|
+
import serviceWorkerPushListener from "./helpers/serviceWorkerPushListener.js";
|
|
17
|
+
import makeSendServiceWorkerTrackingData from "./request/makeSendServiceWorkerTrackingData.js";
|
|
18
|
+
|
|
19
|
+
/* eslint-disable no-console */
|
|
20
|
+
/* eslint-disable no-underscore-dangle */
|
|
21
|
+
|
|
22
|
+
// @ts-check
|
|
23
|
+
/// <reference lib="webworker" />
|
|
24
|
+
|
|
25
|
+
/** @type {ServiceWorkerGlobalScope} */
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
const sw = self;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type {ServiceWorkerLogger}
|
|
31
|
+
*/
|
|
32
|
+
const logger = {
|
|
33
|
+
namespace: "[alloy][pushNotificationWorker]",
|
|
34
|
+
info: (...args) => console.log(logger.namespace, ...args),
|
|
35
|
+
error: (...args) => console.error(logger.namespace, ...args)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @listens install
|
|
40
|
+
*/
|
|
41
|
+
sw.addEventListener("install", () => {
|
|
42
|
+
sw.skipWaiting();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @listens activate
|
|
47
|
+
* @param {ExtendableEvent} event
|
|
48
|
+
*/
|
|
49
|
+
sw.addEventListener("activate", event => {
|
|
50
|
+
event.waitUntil(sw.clients.claim());
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @listens push
|
|
55
|
+
* @param {PushEvent} event
|
|
56
|
+
* @returns {Promise<void>}
|
|
57
|
+
*/
|
|
58
|
+
sw.addEventListener("push", event => serviceWorkerPushListener({
|
|
59
|
+
event,
|
|
60
|
+
logger,
|
|
61
|
+
sw
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @listens notificationclick
|
|
66
|
+
* @param {NotificationEvent} event
|
|
67
|
+
*/
|
|
68
|
+
sw.addEventListener("notificationclick", event => serviceWorkerNotificationClickListener({
|
|
69
|
+
event,
|
|
70
|
+
sw,
|
|
71
|
+
logger,
|
|
72
|
+
fetch
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @listens notificationclose
|
|
77
|
+
* @param {NotificationEvent} event
|
|
78
|
+
*/
|
|
79
|
+
sw.addEventListener("notificationclose", event => {
|
|
80
|
+
const data = event.notification.data;
|
|
81
|
+
makeSendServiceWorkerTrackingData({
|
|
82
|
+
xdm: data._xdm.mixins,
|
|
83
|
+
actionLabel: "Dismiss"
|
|
84
|
+
}, {
|
|
85
|
+
logger,
|
|
86
|
+
fetch
|
|
87
|
+
}).catch(error => {
|
|
88
|
+
logger.error("Failed to send tracking call:", error);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -8,4 +8,85 @@
|
|
|
8
8
|
* @property {string|null} keys.auth - The authentication secret as an ArrayBuffer, or null if not available
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} CustomerJourneyManagement
|
|
13
|
+
* @property {Object} messageExecution
|
|
14
|
+
* @property {string} messageExecution.messageExecutionID
|
|
15
|
+
* @property {string} messageExecution.messageID
|
|
16
|
+
* @property {string} messageExecution.messageType
|
|
17
|
+
* @property {string} messageExecution.campaignID
|
|
18
|
+
* @property {string} messageExecution.campaignVersionID
|
|
19
|
+
* @property {string} messageExecution.batchInstanceID
|
|
20
|
+
* @property {Object} [pushChannelContext]
|
|
21
|
+
* @property {"web"} [pushChannelContext.platform]
|
|
22
|
+
* @property {Object} [messageProfile]
|
|
23
|
+
* @property {Object} [messageProfile.channel]
|
|
24
|
+
* @property {string} [messageProfile.channel._id]
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} Decisioning
|
|
29
|
+
* @property {Object[]} propositions
|
|
30
|
+
* @property {Object} propositions[].scopeDetails
|
|
31
|
+
* @property {string} propositions[].scopeDetails.correlationID
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} XdmTrackingContext
|
|
36
|
+
* @property {Object} _experience
|
|
37
|
+
* @property {CustomerJourneyManagement} _experience.customerJourneyManagement
|
|
38
|
+
* @property {Decisioning} _experience.decisioning
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {Object} PushNotificationData
|
|
43
|
+
* @property {Object} web
|
|
44
|
+
* @property {string} web.title
|
|
45
|
+
* @property {string} web.body
|
|
46
|
+
* @property {string|null} web.media
|
|
47
|
+
* @property {Object} web.interaction
|
|
48
|
+
* @property {string} web.interaction.type
|
|
49
|
+
* @property {string|null} web.interaction.uri
|
|
50
|
+
* @property {Object} web.actions
|
|
51
|
+
* @property {Object[]} web.actions.buttons
|
|
52
|
+
* @property {string} web.actions.buttons[].label
|
|
53
|
+
* @property {string} web.actions.buttons[].type
|
|
54
|
+
* @property {string} web.actions.buttons[].uri
|
|
55
|
+
* @property {string} web.priority
|
|
56
|
+
* @property {Object} web._xdm
|
|
57
|
+
* @property {XdmTrackingContext} web._xdm.mixins
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @typedef {Object} TrackingDataPayload
|
|
62
|
+
* @property {Object[]} events
|
|
63
|
+
* @property {Object} events[].xdm
|
|
64
|
+
* @property {Object} events[].xdm.identityMap
|
|
65
|
+
* @property {Object[]} events[].xdm.identityMap.ECID
|
|
66
|
+
* @property {string} events[].xdm.identityMap.ECID[].id
|
|
67
|
+
* @property {string} events[].xdm.timestamp
|
|
68
|
+
* @property {Object} events[].xdm.pushNotificationTracking
|
|
69
|
+
* @property {string} events[].xdm.pushNotificationTracking.pushProviderMessageID
|
|
70
|
+
* @property {string} events[].xdm.pushNotificationTracking.pushProvider
|
|
71
|
+
* @property {Object} [events[].xdm.pushNotificationTracking.customAction]
|
|
72
|
+
* @property {string} [events[].xdm.pushNotificationTracking.customAction.actionID]
|
|
73
|
+
* @property {Object} events[].xdm.application
|
|
74
|
+
* @property {Object} events[].xdm.application.launches
|
|
75
|
+
* @property {number} events[].xdm.application.launches.value
|
|
76
|
+
* @property {string} events[].xdm.eventType
|
|
77
|
+
* @property {Object} events[].xdm._experience
|
|
78
|
+
* @property {CustomerJourneyManagement} events[].xdm._experience.customerJourneyManagement
|
|
79
|
+
* @property {Decisioning} events[].xdm._experience.decisioning
|
|
80
|
+
* @property {Object} events[].meta
|
|
81
|
+
* @property {Object} events[].meta.collect
|
|
82
|
+
* @property {string} events[].meta.collect.datasetId
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {Object} ServiceWorkerLogger
|
|
87
|
+
* @property {string} namespace
|
|
88
|
+
* @property {(...args: any[]) => void} info
|
|
89
|
+
* @property {(...args: any[]) => void} error
|
|
90
|
+
*/
|
|
91
|
+
|
|
11
92
|
export const Types = {};
|
package/libEs6/utils/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { default as getNamespacedCookieName } from "./getNamespacedCookieName.js
|
|
|
32
32
|
export { default as groupBy } from "./groupBy.js";
|
|
33
33
|
export { default as injectAreThirdPartyCookiesSupportedByDefault } from "./injectAreThirdPartyCookiesSupportedByDefault.js";
|
|
34
34
|
export { default as injectDoesIdentityCookieExist } from "./injectDoesIdentityCookieExist.js";
|
|
35
|
+
export { openIndexedDb, getFromIndexedDbStore, putToIndexedDbStore } from "./indexedDb.js";
|
|
35
36
|
export { default as injectGetBrowser } from "./injectGetBrowser.js";
|
|
36
37
|
export { default as injectStorage } from "./injectStorage.js";
|
|
37
38
|
export { default as intersection } from "./intersection.js";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} dbName
|
|
15
|
+
* @param {number} dbVersion
|
|
16
|
+
* @param {Function} [upgradeCallback] - Optional callback function to handle database upgrades.
|
|
17
|
+
* Called with the database instance when the database is being upgraded.
|
|
18
|
+
* @returns {Promise<IDBDatabase>}
|
|
19
|
+
*/
|
|
20
|
+
export const openIndexedDb = (dbName, dbVersion, upgradeCallback) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const request = indexedDB.open(dbName, dbVersion);
|
|
23
|
+
request.onerror = () => reject(request.error);
|
|
24
|
+
request.onsuccess = () => resolve(request.result);
|
|
25
|
+
request.onupgradeneeded = event => {
|
|
26
|
+
const db = /** @type {IDBOpenDBRequest} */event.target.result;
|
|
27
|
+
if (upgradeCallback) {
|
|
28
|
+
upgradeCallback(db);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {IDBDatabase} db
|
|
36
|
+
* @param {string} storeName
|
|
37
|
+
* @param {string|number|Date|ArrayBuffer|Array} key
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<any>}
|
|
40
|
+
*/
|
|
41
|
+
export const getFromIndexedDbStore = (db, storeName, key) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const transaction = db.transaction([storeName], "readonly");
|
|
44
|
+
const store = transaction.objectStore(storeName);
|
|
45
|
+
const request = store.get(key);
|
|
46
|
+
request.onerror = () => reject(request.error);
|
|
47
|
+
request.onsuccess = () => resolve(request.result);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {IDBDatabase} db
|
|
54
|
+
* @param {string} storeName
|
|
55
|
+
* @param {any} data
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise<any>}
|
|
58
|
+
*/
|
|
59
|
+
export const putToIndexedDbStore = (db, storeName, data) => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const transaction = db.transaction([storeName], "readwrite");
|
|
62
|
+
const store = transaction.objectStore(storeName);
|
|
63
|
+
const request = store.put(data);
|
|
64
|
+
request.onerror = () => reject(request.error);
|
|
65
|
+
request.onsuccess = () => resolve(request.result);
|
|
66
|
+
});
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0-beta.0",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "libEs5/index.js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"lint": "eslint --cache --fix \"*.{js,cjs,mjs,jsx}\" \"{src,test,scripts,sandbox}/**/*.{js,cjs,mjs,jsx}\"",
|
|
27
27
|
"format": "prettier --write \"*.{html,js,cjs,mjs,jsx}\" \"{sandbox,src,test,scripts}/**/*.{html,js,cjs,mjs,jsx}\"",
|
|
28
28
|
"types": "tsc",
|
|
29
|
-
"test": "
|
|
30
|
-
"test:coverage": "rimraf coverage &&
|
|
31
|
-
"test:unit": "
|
|
32
|
-
"test:unit:debug": "
|
|
33
|
-
"test:unit:watch": "
|
|
34
|
-
"test:unit:coverage": "
|
|
35
|
-
"test:integration": "
|
|
36
|
-
"test:integration:debug": "
|
|
37
|
-
"test:integration:watch": "
|
|
38
|
-
"test:integration:coverage": "
|
|
29
|
+
"test": "pnpm exec playwright install chromium && vitest run && pnpm run test:scripts",
|
|
30
|
+
"test:coverage": "rimraf coverage && pnpm exec playwright install chromium && vitest run --coverage",
|
|
31
|
+
"test:unit": "pnpm exec playwright install chromium && vitest run --project=unit",
|
|
32
|
+
"test:unit:debug": "pnpm exec playwright install chromium && vitest --no-file-parallelism --project=unit --browser=chromium --browser.provider=playwright --browser.headless=false",
|
|
33
|
+
"test:unit:watch": "pnpm exec playwright install chromium && vitest --project=unit",
|
|
34
|
+
"test:unit:coverage": "pnpm exec playwright install chromium && vitest run --coverage --project=unit",
|
|
35
|
+
"test:integration": "pnpm exec playwright install chromium && vitest run --project=integration",
|
|
36
|
+
"test:integration:debug": "pnpm exec playwright install chromium && vitest --no-file-parallelism --project=integration --browser=chromium --browser.provider=playwright --browser.headless=false",
|
|
37
|
+
"test:integration:watch": "pnpm exec playwright install chromium && vitest --project=integration",
|
|
38
|
+
"test:integration:coverage": "pnpm exec playwright install chromium && vitest run --coverage --project=integration",
|
|
39
39
|
"test:functional": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe chrome",
|
|
40
40
|
"test:functional:custom": "node scripts/helpers/runFunctionalTests.js",
|
|
41
41
|
"test:functional:watch": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" ./scripts/watchFunctionalTests.js --browsers chrome",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"test:functional:build:int": "rollup -c --environment BASE_CODE_MIN,STANDALONE,NPM_PACKAGE_LOCAL",
|
|
44
44
|
"test:functional:build:prod": "rollup -c --environment BASE_CODE_MIN,NPM_PACKAGE_PROD",
|
|
45
45
|
"test:scripts": "vitest run --config=./scripts/specs/vitest.config.js",
|
|
46
|
-
"dev": "concurrently --names build,sandbox \"rollup -c -w --environment SANDBOX\" \"cd sandbox && export REACT_APP_NONCE=321 &&
|
|
47
|
-
"build": "
|
|
48
|
-
"build:watch": "
|
|
46
|
+
"dev": "concurrently --names build,sandbox \"rollup -c -w --environment SANDBOX\" \"cd sandbox && export REACT_APP_NONCE=321 && pnpm start\"",
|
|
47
|
+
"build": "pnpm run clean && rollup -c --environment BASE_CODE_MIN,STANDALONE,STANDALONE_MIN,BUNDLESIZE && echo \"Base Code:\" && cat distTest/baseCode.min.js",
|
|
48
|
+
"build:watch": "pnpm run clean && rollup -c --watch --environment BASE_CODE_MIN,STANDALONE",
|
|
49
49
|
"build:custom": "node scripts/alloyBuilder.js",
|
|
50
|
-
"prepare": "husky
|
|
51
|
-
"prepack": "
|
|
50
|
+
"prepare": "husky",
|
|
51
|
+
"prepack": "pnpm run clean && babel src -d libEs5 --env-name npmEs5 && babel src -d libEs6 --env-name npmEs6 && pnpm run types",
|
|
52
52
|
"checkthattestfilesexist": "./scripts/checkThatTestFilesExist.js",
|
|
53
53
|
"add-license": "./scripts/add-license.js"
|
|
54
54
|
},
|
|
@@ -74,11 +74,8 @@
|
|
|
74
74
|
"license": "Apache-2.0",
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@adobe/aep-rules-engine": "^3.1.1",
|
|
77
|
-
"@adobe/reactor-cookie": "^1.1.0",
|
|
78
|
-
"@adobe/reactor-load-script": "^1.1.1",
|
|
79
|
-
"@adobe/reactor-object-assign": "^2.0.0",
|
|
80
77
|
"@adobe/reactor-query-string": "^2.0.0",
|
|
81
|
-
"@babel/core": "^7.28.
|
|
78
|
+
"@babel/core": "^7.28.4",
|
|
82
79
|
"@babel/plugin-transform-template-literals": "^7.27.1",
|
|
83
80
|
"@babel/preset-env": "^7.28.3",
|
|
84
81
|
"@inquirer/prompts": "^7.8.4",
|
|
@@ -89,37 +86,37 @@
|
|
|
89
86
|
"commander": "^14.0.0",
|
|
90
87
|
"css.escape": "^1.5.1",
|
|
91
88
|
"js-cookie": "3.0.5",
|
|
92
|
-
"rollup": "^4.
|
|
89
|
+
"rollup": "^4.50.1",
|
|
93
90
|
"rollup-plugin-license": "^3.6.0",
|
|
94
91
|
"uuid": "^11.1.0"
|
|
95
92
|
},
|
|
96
93
|
"devDependencies": {
|
|
97
|
-
"@adobe/alloy": "^2.29.0
|
|
94
|
+
"@adobe/alloy": "^2.29.0",
|
|
98
95
|
"@babel/cli": "^7.28.3",
|
|
99
96
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
100
|
-
"@
|
|
101
|
-
"@eslint/js": "^9.34.0",
|
|
97
|
+
"@eslint/js": "^9.35.0",
|
|
102
98
|
"@octokit/rest": "^22.0.0",
|
|
99
|
+
"@types/node": "^24.3.1",
|
|
103
100
|
"@vitest/browser": "^3.2.4",
|
|
104
101
|
"@vitest/coverage-v8": "^3.2.4",
|
|
105
|
-
"@vitest/eslint-plugin": "^1.3.
|
|
106
|
-
"chalk": "^5.6.
|
|
102
|
+
"@vitest/eslint-plugin": "^1.3.9",
|
|
103
|
+
"chalk": "^5.6.2",
|
|
107
104
|
"concurrently": "^9.2.1",
|
|
108
105
|
"date-fns": "^4.1.0",
|
|
109
|
-
"
|
|
110
|
-
"eslint": "^9.34.0",
|
|
106
|
+
"eslint": "^9.35.0",
|
|
111
107
|
"eslint-config-prettier": "^10.1.8",
|
|
112
108
|
"eslint-plugin-compat": "^6.0.2",
|
|
113
109
|
"eslint-plugin-import": "^2.32.0",
|
|
114
110
|
"eslint-plugin-prettier": "^5.5.4",
|
|
115
111
|
"eslint-plugin-react": "^7.37.5",
|
|
116
112
|
"glob": "^11.0.3",
|
|
117
|
-
"globals": "^16.
|
|
113
|
+
"globals": "^16.4.0",
|
|
118
114
|
"handlebars": "^4.7.8",
|
|
119
115
|
"happy-dom": "^18.0.1",
|
|
120
116
|
"husky": "^9.1.7",
|
|
121
|
-
"lint-staged": "^16.1.
|
|
122
|
-
"
|
|
117
|
+
"lint-staged": "^16.1.6",
|
|
118
|
+
"minimatch": "^10.0.3",
|
|
119
|
+
"msw": "^2.11.2",
|
|
123
120
|
"playwright": "^1.55.0",
|
|
124
121
|
"prettier": "^3.6.2",
|
|
125
122
|
"read-cache": "^1.0.0",
|
|
@@ -128,15 +125,11 @@
|
|
|
128
125
|
"semver": "^7.7.2",
|
|
129
126
|
"staged-git-files": "^1.3.0",
|
|
130
127
|
"testcafe": "^3.7.2",
|
|
131
|
-
"testcafe-browser-provider-saucelabs": "^3.0.0",
|
|
132
|
-
"testcafe-reporter-junit": "^3.0.2",
|
|
133
|
-
"testcafe-reporter-saucelabs": "^3.6.0",
|
|
134
128
|
"typescript": "^5.9.2",
|
|
135
129
|
"url-exists-nodejs": "^0.2.4",
|
|
136
|
-
"url-parse": "^1.5.10",
|
|
137
130
|
"vitest": "^3.2.4"
|
|
138
131
|
},
|
|
139
132
|
"optionalDependencies": {
|
|
140
|
-
"@rollup/rollup-linux-x64-gnu": "^4.
|
|
133
|
+
"@rollup/rollup-linux-x64-gnu": "^4.50.1"
|
|
141
134
|
}
|
|
142
135
|
}
|