@c15t/scripts 2.0.0 → 2.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/README.md +9 -9
- package/dist/e2e-test-utils.cjs +125 -0
- package/dist/e2e-test-utils.js +67 -0
- package/dist/engine/runtime.cjs +19 -9
- package/dist/engine/runtime.js +19 -9
- package/dist/registry.cjs +338 -0
- package/dist/registry.js +292 -0
- package/dist/types.cjs +18 -0
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +51 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +64 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +55 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +74 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
- package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
- package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- package/dist/vendors/analytics/hotjar.cjs +81 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
- package/dist/vendors/analytics/microsoft-clarity.js +73 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +66 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +93 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +76 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +139 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +85 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
- package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
- package/dist-types/__tests__/helpers.d.ts +141 -0
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/registry.d.ts +368 -0
- package/dist-types/types.d.ts +13 -0
- package/dist-types/vendors/_shared/attributes.d.ts +35 -0
- package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
- package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
- package/dist-types/vendors/_shared/script-url.d.ts +75 -0
- package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
- package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
- package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
- package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
- package/dist-types/vendors/analytics/segment.d.ts +158 -0
- package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
- package/dist-types/vendors/functional/crisp.d.ts +78 -0
- package/dist-types/vendors/functional/intercom.d.ts +135 -0
- package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
- package/package.json +166 -5
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.js +0 -100
- package/dist-types/engine.test.d.ts +0 -1
- package/dist-types/helpers.test.d.ts +0 -1
- package/dist-types/meta-pixel.d.ts +0 -185
- /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://c15t.com?utm_source=
|
|
2
|
+
<a href="https://c15t.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts" target="_blank" rel="noopener noreferrer">
|
|
3
3
|
<picture>
|
|
4
4
|
<source media="(prefers-color-scheme: dark)" srcset="../../docs/assets/c15t-banner-readme-dark.svg" type="image/svg+xml">
|
|
5
5
|
<img src="../../docs/assets/c15t-banner-readme-light.svg" alt="c15t Banner" type="image/svg+xml">
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
-
<br />
|
|
9
|
-
<h1 align="center">@c15t/scripts: Prebuilt Consent Scripts</h1>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
10
|
+
# @c15t/scripts: Prebuilt Consent Scripts
|
|
11
|
+
|
|
12
12
|
[](https://github.com/c15t/c15t)
|
|
13
13
|
[](https://github.com/c15t/c15t/actions/workflows/ci.yml)
|
|
14
14
|
[](https://github.com/c15t/c15t/blob/main/LICENSE.md)
|
|
@@ -46,24 +46,24 @@ For further information, guides, and examples visit the [reference documentation
|
|
|
46
46
|
|
|
47
47
|
- Join our [Discord community](https://c15t.link/discord)
|
|
48
48
|
- Open an issue on our [GitHub repository](https://github.com/c15t/c15t/issues)
|
|
49
|
-
- Visit [
|
|
50
|
-
- Contact our support team via email [support@
|
|
49
|
+
- Visit [inth.com](https://inth.com) and use the chat widget
|
|
50
|
+
- Contact our support team via email [support@inth.com](mailto:support@inth.com)
|
|
51
51
|
|
|
52
52
|
## Contributing
|
|
53
53
|
|
|
54
|
-
- We're open to all community contributions
|
|
54
|
+
- We're open to all community contributions.
|
|
55
55
|
- Read our [Contribution Guidelines](https://c15t.com/docs/oss/contributing)
|
|
56
56
|
- Review our [Code of Conduct](https://c15t.com/docs/oss/code-of-conduct)
|
|
57
57
|
- Fork the repository
|
|
58
58
|
- Create a new branch for your feature
|
|
59
59
|
- Submit a pull request
|
|
60
|
-
- **All contributions, big or small, are welcome and appreciated
|
|
60
|
+
- **All contributions, big or small, are welcome and appreciated.**
|
|
61
61
|
|
|
62
62
|
## Security
|
|
63
63
|
|
|
64
64
|
If you believe you have found a security vulnerability in c15t, we encourage you to **_responsibly disclose this and NOT open a public issue_**. We will investigate all legitimate reports.
|
|
65
65
|
|
|
66
|
-
Our preference is that you make use of GitHub's private vulnerability reporting feature to disclose potential security vulnerabilities in our
|
|
66
|
+
Our preference is that you make use of GitHub's private vulnerability reporting feature to disclose potential security vulnerabilities in our open-source software. To do this, please visit [https://github.com/c15t/c15t/security](https://github.com/c15t/c15t/security) and click the "Report a vulnerability" button.
|
|
67
67
|
|
|
68
68
|
### Security Policy
|
|
69
69
|
|
|
@@ -78,4 +78,4 @@ Our preference is that you make use of GitHub's private vulnerability reporting
|
|
|
78
78
|
|
|
79
79
|
---
|
|
80
80
|
|
|
81
|
-
**Built by [Inth](https://inth.com?utm_source=
|
|
81
|
+
**Built by [Inth](https://inth.com?utm_source=npm&utm_medium=readme&utm_campaign=oss_readme&utm_content=%40c15t%2Fscripts)**
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
deniedConsents: ()=>deniedConsents,
|
|
28
|
+
grantedMeasurementConsents: ()=>grantedMeasurementConsents,
|
|
29
|
+
installBodyProbe: ()=>installBodyProbe,
|
|
30
|
+
loadScripts: ()=>script_loader_namespaceObject.loadScripts,
|
|
31
|
+
registerVendorContractCleanup: ()=>registerVendorContractCleanup,
|
|
32
|
+
installHeadProbe: ()=>installHeadProbe,
|
|
33
|
+
isArgumentsPayload: ()=>isArgumentsPayload,
|
|
34
|
+
toArgs: ()=>toArgs,
|
|
35
|
+
grantedMarketingConsents: ()=>grantedMarketingConsents
|
|
36
|
+
});
|
|
37
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
38
|
+
const script_loader_namespaceObject = require("../../core/src/libs/script-loader");
|
|
39
|
+
const deniedConsents = {
|
|
40
|
+
necessary: true,
|
|
41
|
+
functionality: false,
|
|
42
|
+
measurement: false,
|
|
43
|
+
marketing: false,
|
|
44
|
+
experience: false
|
|
45
|
+
};
|
|
46
|
+
const grantedMeasurementConsents = {
|
|
47
|
+
...deniedConsents,
|
|
48
|
+
measurement: true
|
|
49
|
+
};
|
|
50
|
+
const grantedMarketingConsents = {
|
|
51
|
+
...deniedConsents,
|
|
52
|
+
marketing: true
|
|
53
|
+
};
|
|
54
|
+
function isArgumentsPayload(value) {
|
|
55
|
+
return '[object Arguments]' === Object.prototype.toString.call(value);
|
|
56
|
+
}
|
|
57
|
+
function toArgs(value) {
|
|
58
|
+
return Array.from(value);
|
|
59
|
+
}
|
|
60
|
+
function installAppendProbe(target, onAppend) {
|
|
61
|
+
const originalAppendChild = target.appendChild.bind(target);
|
|
62
|
+
return external_vitest_namespaceObject.vi.spyOn(target, 'appendChild').mockImplementation((node)=>{
|
|
63
|
+
const appended = originalAppendChild(node);
|
|
64
|
+
if (node instanceof HTMLScriptElement) onAppend(node, window);
|
|
65
|
+
return appended;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function installHeadProbe(onAppend) {
|
|
69
|
+
return installAppendProbe(document.head, onAppend);
|
|
70
|
+
}
|
|
71
|
+
function installBodyProbe(onAppend) {
|
|
72
|
+
return installAppendProbe(document.body, onAppend);
|
|
73
|
+
}
|
|
74
|
+
function resetVendorGlobals() {
|
|
75
|
+
const win = window;
|
|
76
|
+
for (const key of [
|
|
77
|
+
'TiktokAnalyticsObject',
|
|
78
|
+
'UET',
|
|
79
|
+
'_linkedin_data_partner_ids',
|
|
80
|
+
'_linkedin_partner_id',
|
|
81
|
+
'_fbq',
|
|
82
|
+
'dataLayer',
|
|
83
|
+
'databuddy',
|
|
84
|
+
'databuddyConfig',
|
|
85
|
+
'fbq',
|
|
86
|
+
'google_tag_data',
|
|
87
|
+
'lintrk',
|
|
88
|
+
'posthog',
|
|
89
|
+
'ttq',
|
|
90
|
+
'twq',
|
|
91
|
+
'uetq'
|
|
92
|
+
])delete win[key];
|
|
93
|
+
}
|
|
94
|
+
function registerVendorContractCleanup() {
|
|
95
|
+
(0, external_vitest_namespaceObject.afterEach)(()=>{
|
|
96
|
+
(0, script_loader_namespaceObject.clearAllScripts)();
|
|
97
|
+
external_vitest_namespaceObject.vi.restoreAllMocks();
|
|
98
|
+
document.head.innerHTML = '';
|
|
99
|
+
document.body.innerHTML = '';
|
|
100
|
+
resetVendorGlobals();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.deniedConsents = __webpack_exports__.deniedConsents;
|
|
104
|
+
exports.grantedMarketingConsents = __webpack_exports__.grantedMarketingConsents;
|
|
105
|
+
exports.grantedMeasurementConsents = __webpack_exports__.grantedMeasurementConsents;
|
|
106
|
+
exports.installBodyProbe = __webpack_exports__.installBodyProbe;
|
|
107
|
+
exports.installHeadProbe = __webpack_exports__.installHeadProbe;
|
|
108
|
+
exports.isArgumentsPayload = __webpack_exports__.isArgumentsPayload;
|
|
109
|
+
exports.loadScripts = __webpack_exports__.loadScripts;
|
|
110
|
+
exports.registerVendorContractCleanup = __webpack_exports__.registerVendorContractCleanup;
|
|
111
|
+
exports.toArgs = __webpack_exports__.toArgs;
|
|
112
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
|
+
"deniedConsents",
|
|
114
|
+
"grantedMarketingConsents",
|
|
115
|
+
"grantedMeasurementConsents",
|
|
116
|
+
"installBodyProbe",
|
|
117
|
+
"installHeadProbe",
|
|
118
|
+
"isArgumentsPayload",
|
|
119
|
+
"loadScripts",
|
|
120
|
+
"registerVendorContractCleanup",
|
|
121
|
+
"toArgs"
|
|
122
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
123
|
+
Object.defineProperty(exports, '__esModule', {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { afterEach, vi } from "vitest";
|
|
2
|
+
import { clearAllScripts, loadScripts } from "../../core/src/libs/script-loader";
|
|
3
|
+
const deniedConsents = {
|
|
4
|
+
necessary: true,
|
|
5
|
+
functionality: false,
|
|
6
|
+
measurement: false,
|
|
7
|
+
marketing: false,
|
|
8
|
+
experience: false
|
|
9
|
+
};
|
|
10
|
+
const grantedMeasurementConsents = {
|
|
11
|
+
...deniedConsents,
|
|
12
|
+
measurement: true
|
|
13
|
+
};
|
|
14
|
+
const grantedMarketingConsents = {
|
|
15
|
+
...deniedConsents,
|
|
16
|
+
marketing: true
|
|
17
|
+
};
|
|
18
|
+
function isArgumentsPayload(value) {
|
|
19
|
+
return '[object Arguments]' === Object.prototype.toString.call(value);
|
|
20
|
+
}
|
|
21
|
+
function toArgs(value) {
|
|
22
|
+
return Array.from(value);
|
|
23
|
+
}
|
|
24
|
+
function installAppendProbe(target, onAppend) {
|
|
25
|
+
const originalAppendChild = target.appendChild.bind(target);
|
|
26
|
+
return vi.spyOn(target, 'appendChild').mockImplementation((node)=>{
|
|
27
|
+
const appended = originalAppendChild(node);
|
|
28
|
+
if (node instanceof HTMLScriptElement) onAppend(node, window);
|
|
29
|
+
return appended;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function installHeadProbe(onAppend) {
|
|
33
|
+
return installAppendProbe(document.head, onAppend);
|
|
34
|
+
}
|
|
35
|
+
function installBodyProbe(onAppend) {
|
|
36
|
+
return installAppendProbe(document.body, onAppend);
|
|
37
|
+
}
|
|
38
|
+
function resetVendorGlobals() {
|
|
39
|
+
const win = window;
|
|
40
|
+
for (const key of [
|
|
41
|
+
'TiktokAnalyticsObject',
|
|
42
|
+
'UET',
|
|
43
|
+
'_linkedin_data_partner_ids',
|
|
44
|
+
'_linkedin_partner_id',
|
|
45
|
+
'_fbq',
|
|
46
|
+
'dataLayer',
|
|
47
|
+
'databuddy',
|
|
48
|
+
'databuddyConfig',
|
|
49
|
+
'fbq',
|
|
50
|
+
'google_tag_data',
|
|
51
|
+
'lintrk',
|
|
52
|
+
'posthog',
|
|
53
|
+
'ttq',
|
|
54
|
+
'twq',
|
|
55
|
+
'uetq'
|
|
56
|
+
])delete win[key];
|
|
57
|
+
}
|
|
58
|
+
function registerVendorContractCleanup() {
|
|
59
|
+
afterEach(()=>{
|
|
60
|
+
clearAllScripts();
|
|
61
|
+
vi.restoreAllMocks();
|
|
62
|
+
document.head.innerHTML = '';
|
|
63
|
+
document.body.innerHTML = '';
|
|
64
|
+
resetVendorGlobals();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export { deniedConsents, grantedMarketingConsents, grantedMeasurementConsents, installBodyProbe, installHeadProbe, isArgumentsPayload, loadScripts, registerVendorContractCleanup, toArgs };
|
package/dist/engine/runtime.cjs
CHANGED
|
@@ -27,7 +27,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
resolvedManifestToScript: ()=>resolvedManifestToScript
|
|
28
28
|
});
|
|
29
29
|
const external_c15t_namespaceObject = require("c15t");
|
|
30
|
+
const external_types_cjs_namespaceObject = require("../types.cjs");
|
|
31
|
+
function isRuntimeValue(value) {
|
|
32
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
|
|
33
|
+
const candidate = value;
|
|
34
|
+
return candidate.kind === external_types_cjs_namespaceObject.RUNTIME_VALUE_KIND && ('date' === candidate.value || 'timestamp' === candidate.value);
|
|
35
|
+
}
|
|
36
|
+
function resolveRuntimeValue(value) {
|
|
37
|
+
if ('date' === value.value) return new Date();
|
|
38
|
+
return Date.now();
|
|
39
|
+
}
|
|
30
40
|
function cloneStepValue(value) {
|
|
41
|
+
if (isRuntimeValue(value)) return resolveRuntimeValue(value);
|
|
31
42
|
if (value instanceof Date) return new Date(value);
|
|
32
43
|
if (Array.isArray(value)) return value.map((item)=>cloneStepValue(item));
|
|
33
44
|
if (null !== value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).map(([key, nestedValue])=>[
|
|
@@ -76,12 +87,11 @@ function executeStep(step) {
|
|
|
76
87
|
{
|
|
77
88
|
const shouldSet = false !== step.ifUndefined;
|
|
78
89
|
if (shouldSet && void 0 !== win[step.name]) break;
|
|
79
|
-
win[step.name] = function(
|
|
90
|
+
win[step.name] = function() {
|
|
80
91
|
const queueTarget = win[step.queue];
|
|
81
92
|
if (!Array.isArray(queueTarget)) return;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
] : args);
|
|
93
|
+
if ('array' === step.pushStyle) return void queueTarget.push(Array.from(arguments));
|
|
94
|
+
queueTarget.push(arguments);
|
|
85
95
|
};
|
|
86
96
|
break;
|
|
87
97
|
}
|
|
@@ -89,15 +99,15 @@ function executeStep(step) {
|
|
|
89
99
|
{
|
|
90
100
|
const shouldSet = false !== step.ifUndefined;
|
|
91
101
|
if (shouldSet && void 0 !== win[step.name]) break;
|
|
92
|
-
const stub = function(
|
|
102
|
+
const stub = function() {
|
|
93
103
|
const self = win[step.name];
|
|
94
104
|
const dispatcher = self && step.dispatchProperty ? self[step.dispatchProperty] : void 0;
|
|
95
|
-
|
|
105
|
+
const runtimeArgs = Array.from(arguments);
|
|
106
|
+
if ('function' == typeof dispatcher) return void dispatcher.apply(self, runtimeArgs);
|
|
96
107
|
const queueTarget = resolveQueueTarget(win, step.queue, self);
|
|
97
108
|
if (!queueTarget) return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
] : args);
|
|
109
|
+
if ('array' === step.queueFormat) return void queueTarget.push(runtimeArgs);
|
|
110
|
+
queueTarget.push(arguments);
|
|
101
111
|
};
|
|
102
112
|
win[step.name] = stub;
|
|
103
113
|
const stubRecord = stub;
|
package/dist/engine/runtime.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { emitScriptDebugEvent } from "c15t";
|
|
2
|
+
import { RUNTIME_VALUE_KIND } from "../types.js";
|
|
3
|
+
function isRuntimeValue(value) {
|
|
4
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
|
|
5
|
+
const candidate = value;
|
|
6
|
+
return candidate.kind === RUNTIME_VALUE_KIND && ('date' === candidate.value || 'timestamp' === candidate.value);
|
|
7
|
+
}
|
|
8
|
+
function resolveRuntimeValue(value) {
|
|
9
|
+
if ('date' === value.value) return new Date();
|
|
10
|
+
return Date.now();
|
|
11
|
+
}
|
|
2
12
|
function cloneStepValue(value) {
|
|
13
|
+
if (isRuntimeValue(value)) return resolveRuntimeValue(value);
|
|
3
14
|
if (value instanceof Date) return new Date(value);
|
|
4
15
|
if (Array.isArray(value)) return value.map((item)=>cloneStepValue(item));
|
|
5
16
|
if (null !== value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).map(([key, nestedValue])=>[
|
|
@@ -48,12 +59,11 @@ function executeStep(step) {
|
|
|
48
59
|
{
|
|
49
60
|
const shouldSet = false !== step.ifUndefined;
|
|
50
61
|
if (shouldSet && void 0 !== win[step.name]) break;
|
|
51
|
-
win[step.name] = function(
|
|
62
|
+
win[step.name] = function() {
|
|
52
63
|
const queueTarget = win[step.queue];
|
|
53
64
|
if (!Array.isArray(queueTarget)) return;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
] : args);
|
|
65
|
+
if ('array' === step.pushStyle) return void queueTarget.push(Array.from(arguments));
|
|
66
|
+
queueTarget.push(arguments);
|
|
57
67
|
};
|
|
58
68
|
break;
|
|
59
69
|
}
|
|
@@ -61,15 +71,15 @@ function executeStep(step) {
|
|
|
61
71
|
{
|
|
62
72
|
const shouldSet = false !== step.ifUndefined;
|
|
63
73
|
if (shouldSet && void 0 !== win[step.name]) break;
|
|
64
|
-
const stub = function(
|
|
74
|
+
const stub = function() {
|
|
65
75
|
const self = win[step.name];
|
|
66
76
|
const dispatcher = self && step.dispatchProperty ? self[step.dispatchProperty] : void 0;
|
|
67
|
-
|
|
77
|
+
const runtimeArgs = Array.from(arguments);
|
|
78
|
+
if ('function' == typeof dispatcher) return void dispatcher.apply(self, runtimeArgs);
|
|
68
79
|
const queueTarget = resolveQueueTarget(win, step.queue, self);
|
|
69
80
|
if (!queueTarget) return;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
] : args);
|
|
81
|
+
if ('array' === step.queueFormat) return void queueTarget.push(runtimeArgs);
|
|
82
|
+
queueTarget.push(arguments);
|
|
73
83
|
};
|
|
74
84
|
win[step.name] = stub;
|
|
75
85
|
const stubRecord = stub;
|