├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── dev.yaml ├── .gitignore ├── .npmignore ├── .prettierrc ├── .sandbox-3rdPartyTags ├── container.js ├── files │ ├── non_sequential_HTML_1.html │ ├── non_sequential_global_1.js │ ├── non_sequential_global_2.js │ ├── non_sequential_global_3.js │ ├── non_sequential_non_global_1.js │ ├── non_sequential_non_global_2.js │ ├── non_sequential_non_global_3.js │ ├── pl_non_sequential_HTML_1.html │ ├── pl_sequential_global_1.js │ ├── pl_sequential_global_2.js │ ├── sequential_global_1.js │ ├── sequential_global_2.js │ ├── sequential_global_3.js │ ├── sequential_non_global_1.js │ ├── sequential_non_global_2.js │ └── sequential_non_global_3.js └── libSandbox.html ├── .yarn ├── plugins │ └── plugin-rsp-duplicates.cjs └── releases │ └── yarn-4.9.1.cjs ├── .yarnrc.yml ├── CODE_OF_CONDUCT.md ├── COPYRIGHT ├── LICENSE ├── README.md ├── createEntryFile.js ├── dedupe.md ├── extension.json ├── helpers ├── mockTurbineVariable.js └── waitUntil.js ├── karma.conf.js ├── lock-check.js ├── package.json ├── react-collection-view-4.1.5.tgz ├── react-react-spectrum-2.25.0.tgz ├── resources └── icons │ └── core.svg ├── src ├── lib │ ├── __tests__ │ │ └── helpers │ │ │ └── flushPromiseChains.js │ ├── actions │ │ ├── __tests__ │ │ │ ├── customCode.test.js │ │ │ └── directCall.test.js │ │ ├── customCode.js │ │ ├── directCall.js │ │ └── helpers │ │ │ ├── __tests__ │ │ │ ├── decorateCode.test.js │ │ │ ├── getSourceByUrl.test.js │ │ │ ├── loadCodeSequentially.test.js │ │ │ └── unescapeHtmlCode.test.js │ │ │ ├── decorateCode.js │ │ │ ├── decorators │ │ │ ├── __tests__ │ │ │ │ ├── decorateGlobalJavaScriptCode.test.js │ │ │ │ ├── decorateHtmlCode.test.js │ │ │ │ └── decorateNonGlobalJavaScriptCode.test.js │ │ │ ├── decorateGlobalJavaScriptCode.js │ │ │ ├── decorateHtmlCode.js │ │ │ └── decorateNonGlobalJavaScriptCode.js │ │ │ ├── getSourceByUrl.js │ │ │ ├── loadCodeSequentially.js │ │ │ └── unescapeHtmlCode.js │ ├── conditions │ │ ├── __tests__ │ │ │ ├── browser.test.js │ │ │ ├── cookie.test.js │ │ │ ├── customCode.test.js │ │ │ ├── dateRange.test.js │ │ │ ├── deviceType.test.js │ │ │ ├── domain.test.js │ │ │ ├── hash.test.js │ │ │ ├── landingPage.test.js │ │ │ ├── maxFrequency.test.js │ │ │ ├── newReturningVisitor.test.js │ │ │ ├── operatingSystem.test.js │ │ │ ├── pageViews.test.js │ │ │ ├── path.test.js │ │ │ ├── pathAndQuerystring.test.js │ │ │ ├── protocol.test.js │ │ │ ├── queryStringParameter.test.js │ │ │ ├── sampling.test.js │ │ │ ├── screenResolution.test.js │ │ │ ├── sessions.test.js │ │ │ ├── subdomain.test.js │ │ │ ├── timeOnSite.test.js │ │ │ ├── trafficSource.test.js │ │ │ ├── valueComparison.test.js │ │ │ ├── variable.test.js │ │ │ └── windowSize.test.js │ │ ├── browser.js │ │ ├── cookie.js │ │ ├── customCode.js │ │ ├── dateRange.js │ │ ├── deviceType.js │ │ ├── domain.js │ │ ├── hash.js │ │ ├── helpers │ │ │ ├── __tests__ │ │ │ │ └── compareNumbers.test.js │ │ │ ├── clientInfo.js │ │ │ └── compareNumbers.js │ │ ├── landingPage.js │ │ ├── maxFrequency.js │ │ ├── newReturningVisitor.js │ │ ├── operatingSystem.js │ │ ├── pageViews.js │ │ ├── path.js │ │ ├── pathAndQuerystring.js │ │ ├── protocol.js │ │ ├── queryStringParameter.js │ │ ├── sampling.js │ │ ├── screenResolution.js │ │ ├── sessions.js │ │ ├── subdomain.js │ │ ├── timeOnSite.js │ │ ├── trafficSource.js │ │ ├── valueComparison.js │ │ ├── variable.js │ │ └── windowSize.js │ ├── dataElements │ │ ├── __tests__ │ │ │ ├── conditionalValue.test.js │ │ │ ├── constant.test.js │ │ │ ├── cookie.test.js │ │ │ ├── customCode.test.js │ │ │ ├── deviceAttributes.test.js │ │ │ ├── domAttribute.test.js │ │ │ ├── javascriptTools.test.js │ │ │ ├── javascriptVariable.test.js │ │ │ ├── localStorage.test.js │ │ │ ├── mergedObjects.test.js │ │ │ ├── pageInfo.test.js │ │ │ ├── queryStringParameter.test.js │ │ │ ├── randomNumber.test.js │ │ │ ├── runtimeEnvironment.test.js │ │ │ ├── sessionStorage.test.js │ │ │ └── visitorBehavior.test.js │ │ ├── conditionalValue.js │ │ ├── constant.js │ │ ├── cookie.js │ │ ├── customCode.js │ │ ├── deviceAttributes.js │ │ ├── domAttribute.js │ │ ├── javascriptTools.js │ │ ├── javascriptVariable.js │ │ ├── localStorage.js │ │ ├── mergedObjects.js │ │ ├── pageInfo.js │ │ ├── queryStringParameter.js │ │ ├── randomNumber.js │ │ ├── runtimeEnvironment.js │ │ ├── sessionStorage.js │ │ └── visitorBehavior.js │ ├── events │ │ ├── __tests__ │ │ │ ├── blur.test.js │ │ │ ├── change.test.js │ │ │ ├── click.test.js │ │ │ ├── customCode.test.js │ │ │ ├── customEvent.test.js │ │ │ ├── dataElementChange.test.js │ │ │ ├── directCall.test.js │ │ │ ├── domReady.test.js │ │ │ ├── elementExists.test.js │ │ │ ├── entersViewport.test.js │ │ │ ├── focus.test.js │ │ │ ├── helpers │ │ │ │ └── testStandardEvent.js │ │ │ ├── historyChange.test.js │ │ │ ├── hover.test.js │ │ │ ├── keyDown.test.js │ │ │ ├── keyPress.test.js │ │ │ ├── keyUp.test.js │ │ │ ├── libraryLoaded.test.js │ │ │ ├── mediaEnded.test.js │ │ │ ├── mediaLoadedData.test.js │ │ │ ├── mediaPause.test.js │ │ │ ├── mediaPlay.test.js │ │ │ ├── mediaStalled.test.js │ │ │ ├── mediaTimePlayed.test.js │ │ │ ├── mediaVolumeChange.test.js │ │ │ ├── mousedown.test.js │ │ │ ├── orientationChange.test.js │ │ │ ├── pageBottom.test.js │ │ │ ├── submit.test.js │ │ │ ├── tabBlur.test.js │ │ │ ├── tabFocus.test.js │ │ │ ├── timeOnPage.test.js │ │ │ ├── windowLoaded.test.js │ │ │ └── zoomChange.test.js │ │ ├── blur.js │ │ ├── change.js │ │ ├── click.js │ │ ├── customCode.js │ │ ├── customEvent.js │ │ ├── dataElementChange.js │ │ ├── directCall.js │ │ ├── domReady.js │ │ ├── elementExists.js │ │ ├── entersViewport.js │ │ ├── focus.js │ │ ├── helpers │ │ │ ├── __tests__ │ │ │ │ ├── createBubbly.test.js │ │ │ │ ├── debounce.test.js │ │ │ │ ├── enableWeakMapDefaultValue.test.js │ │ │ │ ├── liveQuerySelector.test.js │ │ │ │ ├── matchesProperties.test.js │ │ │ │ ├── matchesSelector.test.js │ │ │ │ ├── once.test.js │ │ │ │ ├── pageLifecycleEvents.test.js │ │ │ │ ├── timer.test.js │ │ │ │ └── weakMap.test.js │ │ │ ├── createBubbly.js │ │ │ ├── debounce.js │ │ │ ├── enableWeakMapDefaultValue.js │ │ │ ├── liveQuerySelector.js │ │ │ ├── matchesProperties.js │ │ │ ├── matchesSelector.js │ │ │ ├── once.js │ │ │ ├── pageLifecycleEvents.js │ │ │ ├── timer.js │ │ │ ├── visibilityApi.js │ │ │ └── weakMap.js │ │ ├── historyChange.js │ │ ├── hover.js │ │ ├── keyDown.js │ │ ├── keyPress.js │ │ ├── keyUp.js │ │ ├── libraryLoaded.js │ │ ├── mediaEnded.js │ │ ├── mediaLoadedData.js │ │ ├── mediaPause.js │ │ ├── mediaPlay.js │ │ ├── mediaStalled.js │ │ ├── mediaTimePlayed.js │ │ ├── mediaVolumeChange.js │ │ ├── mousedown.js │ │ ├── orientationChange.js │ │ ├── pageBottom.js │ │ ├── submit.js │ │ ├── tabBlur.js │ │ ├── tabFocus.js │ │ ├── timeOnPage.js │ │ ├── windowLoaded.js │ │ └── zoomChange.js │ └── helpers │ │ ├── __tests__ │ │ ├── deepMerge.test.js │ │ ├── getNamespacedStorage.test.js │ │ ├── getObjectProperty.test.js │ │ ├── isPlainObject.test.js │ │ ├── textMatch.test.js │ │ └── visitorTracking.test.js │ │ ├── deepMerge.js │ │ ├── findPageScript.js │ │ ├── getNamespacedStorage.js │ │ ├── getObjectProperty.js │ │ ├── intersectionObserverIntervals.js │ │ ├── isPlainObject.js │ │ ├── stringAndNumberUtils.js │ │ ├── textMatch.js │ │ └── visitorTracking.js └── view │ ├── .eslintrc │ ├── __tests__ │ └── helpers │ │ ├── createExtensionBridge.jsx │ │ └── react-testing-library.jsx │ ├── actions │ ├── __tests__ │ │ ├── customCode.test.jsx │ │ └── directCall.test.jsx │ ├── customCode.jsx │ ├── directCall.jsx │ └── directCall.styl │ ├── bootstrap.jsx │ ├── bridgeAdapter.js │ ├── components │ ├── __tests__ │ │ ├── disclosureButton.test.jsx │ │ ├── editorButton.test.jsx │ │ ├── multipleItemEditor.test.jsx │ │ ├── regexTestButton.test.jsx │ │ ├── regexToggle.test.jsx │ │ └── wrappedField.test.jsx │ ├── disclosureButton.jsx │ ├── editorButton.jsx │ ├── fullWidthField.jsx │ ├── helpText.jsx │ ├── helpText.styl │ ├── infoTip.jsx │ ├── multipleItemEditor.jsx │ ├── noWrapText.jsx │ ├── regexTestButton.jsx │ ├── regexToggle.jsx │ ├── selectorLearnMoreLink.jsx │ ├── spectrumLabel.jsx │ ├── tooltipClone.jsx │ ├── tooltipClone.styl │ ├── warningContainer.jsx │ └── wrappedField.jsx │ ├── conditions │ ├── __tests__ │ │ ├── browser.test.jsx │ │ ├── cookie.test.jsx │ │ ├── customCode.test.jsx │ │ ├── dateRange.test.jsx │ │ ├── deviceType.test.jsx │ │ ├── domain.test.jsx │ │ ├── hash.test.jsx │ │ ├── landingPage.test.jsx │ │ ├── maxFrequency.test.jsx │ │ ├── newReturningVisitor.test.jsx │ │ ├── operatingSystem.test.jsx │ │ ├── pageViews.test.jsx │ │ ├── path.test.jsx │ │ ├── pathAndQuerystring.test.jsx │ │ ├── protocol.test.jsx │ │ ├── queryStringParameter.test.jsx │ │ ├── sampling.test.jsx │ │ ├── screenResolution.test.jsx │ │ ├── sessions.test.jsx │ │ ├── subdomain.test.jsx │ │ ├── timeOnSite.test.jsx │ │ ├── trafficSource.test.jsx │ │ ├── valueComparison.test.jsx │ │ ├── variable.test.jsx │ │ └── windowSize.test.jsx │ ├── browser.jsx │ ├── comparisonOperatorOptions.js │ ├── cookie.jsx │ ├── customCode.jsx │ ├── dateRange.jsx │ ├── dateRange.styl │ ├── deviceType.jsx │ ├── domain.jsx │ ├── hash.jsx │ ├── landingPage.jsx │ ├── maxFrequency.jsx │ ├── newReturningVisitor.jsx │ ├── operatingSystem.jsx │ ├── pageViews.jsx │ ├── path.jsx │ ├── pathAndQuerystring.jsx │ ├── protocol.jsx │ ├── queryStringParameter.jsx │ ├── sampling.jsx │ ├── screenResolution.jsx │ ├── sessions.jsx │ ├── subdomain.jsx │ ├── timeOnSite.jsx │ ├── trafficSource.jsx │ ├── valueComparison.jsx │ ├── variable.jsx │ └── windowSize.jsx │ ├── configuration │ ├── __tests__ │ │ └── configuration.test.jsx │ └── configuration.jsx │ ├── dataElements │ ├── __tests__ │ │ ├── conditionalValue.test.jsx │ │ ├── constant.test.jsx │ │ ├── cookie.test.jsx │ │ ├── customCode.test.jsx │ │ ├── deviceAttributes.test.jsx │ │ ├── domAttribute.test.jsx │ │ ├── javascriptTools.test.jsx │ │ ├── javascriptVariable.test.jsx │ │ ├── localStorage.test.jsx │ │ ├── mergedObjects.test.jsx │ │ ├── pageInfo.test.jsx │ │ ├── queryStringParameter.test.jsx │ │ ├── randomNumber.test.jsx │ │ ├── runtimeEnvironment.test.jsx │ │ ├── sessionStorage.test.jsx │ │ └── visitorBehavior.test.jsx │ ├── components │ │ └── javascriptTools │ │ │ ├── regexMatch.jsx │ │ │ ├── regexReplace.jsx │ │ │ ├── replacementValue.jsx │ │ │ ├── searchValue.jsx │ │ │ ├── simpleReplace.jsx │ │ │ ├── startEndPosition.jsx │ │ │ └── valueSeparator.jsx │ ├── conditionalValue.jsx │ ├── constant.jsx │ ├── cookie.jsx │ ├── customCode.jsx │ ├── deviceAttributes.jsx │ ├── domAttribute.jsx │ ├── javascriptTools.jsx │ ├── javascriptVariable.jsx │ ├── localStorage.jsx │ ├── mergedObjects.jsx │ ├── pageInfo.jsx │ ├── queryStringParameter.jsx │ ├── randomNumber.jsx │ ├── runtimeEnvironment.jsx │ ├── sessionStorage.jsx │ ├── utils │ │ └── javascriptTools │ │ │ ├── metaByOperator.jsx │ │ │ └── operators.js │ └── visitorBehavior.jsx │ ├── events │ ├── __tests__ │ │ ├── change.test.jsx │ │ ├── click.test.jsx │ │ ├── customCode.test.jsx │ │ ├── customEvent.test.jsx │ │ ├── dataElementChange.test.jsx │ │ ├── directCall.test.jsx │ │ ├── elementExists.test.jsx │ │ ├── entersViewport.test.jsx │ │ ├── hover.test.jsx │ │ ├── mediaTimePlayed.test.jsx │ │ └── timeOnPage.test.jsx │ ├── blur.jsx │ ├── change.jsx │ ├── change.styl │ ├── click.jsx │ ├── components │ │ ├── __tests__ │ │ │ ├── advancedEventOptions.test.jsx │ │ │ ├── delayType.test.jsx │ │ │ ├── elementFilter.test.jsx │ │ │ ├── elementPropertiesEditor.test.jsx │ │ │ ├── elementSelectorField.test.jsx │ │ │ ├── specificElements.test.jsx │ │ │ └── standardEvent.test.jsx │ │ ├── advancedEventOptions.jsx │ │ ├── delayType.jsx │ │ ├── elementFilter.jsx │ │ ├── elementPropertiesEditor.jsx │ │ ├── elementSelector.jsx │ │ ├── specificElements.jsx │ │ └── standardEvent.jsx │ ├── customCode.jsx │ ├── customEvent.jsx │ ├── dataElementChange.jsx │ ├── directCall.jsx │ ├── elementExists.jsx │ ├── entersViewport.jsx │ ├── focus.jsx │ ├── hover.jsx │ ├── keyDown.jsx │ ├── keyPress.jsx │ ├── keyUp.jsx │ ├── mediaEnded.jsx │ ├── mediaLoadedData.jsx │ ├── mediaPause.jsx │ ├── mediaPlay.jsx │ ├── mediaStalled.jsx │ ├── mediaTimePlayed.jsx │ ├── mediaVolumeChange.jsx │ ├── mousedown.jsx │ ├── submit.jsx │ └── timeOnPage.jsx │ ├── global.styl │ ├── reduxActions │ ├── bridgeAdapterActions.js │ └── reducer.js │ ├── renderView.jsx │ ├── template.html │ └── utils │ ├── mergeFormConfigs.js │ └── validators.js ├── testIndex.js ├── webpack.config.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "plugins": [ "istanbul" ] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.css 3 | *.styl 4 | *.json 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "jasmine": true, 5 | "node": true 6 | }, 7 | "extends": ["plugin:prettier/recommended"], 8 | "rules": { 9 | "camelcase": [2, { "properties": "always" }], 10 | "semi": [2, "always"], 11 | "keyword-spacing": [2], 12 | "space-before-blocks": [2, "always"], 13 | "space-infix-ops": [2, { "int32Hint": false }], 14 | "quotes": [1, "single", "avoid-escape"], 15 | "max-len": [ 16 | 2, 17 | 100, 18 | 4, 19 | { 20 | "ignoreUrls": true, 21 | "ignorePattern": "^(\\s*(var|let|const)\\s.+=\\s*require\\s*\\()|(^\\s*import)" 22 | } 23 | ], 24 | "eqeqeq": [2, "allow-null"], 25 | "strict": [2, "global"], 26 | "no-nested-ternary": [2], 27 | "no-underscore-dangle": 0, 28 | "comma-style": [2], 29 | "one-var": [2, "never"], 30 | "brace-style": [2, "1tbs", { "allowSingleLine": true }], 31 | "consistent-this": [0, "self"], 32 | "spaced-comment": 0, // To support our copyright banner. 33 | "implicit-arrow-linebreak": 0, 34 | "prefer-const": [ 35 | "error", 36 | { 37 | "destructuring": "all" 38 | } 39 | ] 40 | }, 41 | "globals": { 42 | "Simulate": true, 43 | "_satellite": true 44 | }, 45 | "settings": { 46 | "import/resolver": { 47 | "webpack": { 48 | "config": "webpack.config.js" 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Expected Behaviour 5 | 6 | ### Actual Behaviour 7 | 8 | ### Reproduce Scenario (including but not limited to) 9 | 10 | #### Steps to Reproduce 11 | 12 | #### Platform and Version 13 | 14 | #### Sample Code that illustrates the problem 15 | 16 | #### Logs taken while reproducing problem 17 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | 7 | ## Related Issue 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Motivation and Context 15 | 16 | 17 | 18 | ## Screenshots (if appropriate): 19 | 20 | ## Types of changes 21 | 22 | 23 | 24 | - [ ] Bug fix (non-breaking change which fixes an issue) 25 | - [ ] New feature (non-breaking change which adds functionality) 26 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 27 | 28 | ## Checklist: 29 | 30 | 31 | 32 | 33 | - [ ] I have signed the [Adobe Open Source CLA](http://opensource.adobe.com/cla.html). 34 | - [ ] My code follows the code style of this project. 35 | - [ ] I have updated the Experience League documentation for the [Core Extension](https://git.corp.adobe.com/AdobeDocs/experience-platform.en/tree/master/help/tags/extensions/web/core) 36 | - [ ] All tests pass and I've made any necessary test changes. 37 | - [ ] I have run the extension sandbox successfully. 38 | -------------------------------------------------------------------------------- /.github/workflows/dev.yaml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: ci 5 | 6 | on: 7 | pull_request: 8 | branches: [master] 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build: 13 | name: "Unit Test" 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: 'lts/iron' 20 | registry-url: https://registry.npmjs.org/ 21 | - uses: actions/cache@v4 22 | id: npm-cache 23 | with: 24 | path: '**/node_modules' 25 | key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} 26 | - name: Setup kernel for react native, increase watchers 27 | run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p 28 | - name: Install dependencies 29 | if: steps.npm-cache.outputs.cache-hit != 'true' 30 | run: yarn install --immutable 31 | - name: Linting files 32 | run: npm run lint 33 | - uses: saucelabs/sauce-connect-action@v1 34 | with: 35 | username: ${{ secrets.SAUCE_USERNAME }} 36 | accessKey: ${{ secrets.SAUCE_ACCESS_KEY }} 37 | noSSLBumpDomains: all 38 | noProxyCaching: true 39 | tunnelIdentifier: github-action-tunnel 40 | - run: npm test 41 | env: 42 | SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} 43 | SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} 44 | - name: Coveralls 45 | uses: coverallsapp/github-action@master 46 | with: 47 | github-token: ${{ secrets.GITHUB_TOKEN }} 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | test_results 4 | dist 5 | .sonar 6 | .sandbox 7 | .entries 8 | package-core* 9 | **/install-state.gz -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | __tests__ 2 | coverage 3 | test_results 4 | testrunner 5 | sonar-project.properties 6 | src/view 7 | reactor-core-extension-2.0.0.tgz 8 | createEntryFile.js 9 | \.* 10 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_HTML_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_global_1.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Non Sequential Global script 1"); 3 | console.log("Window object `nsg1` should now be set."); 4 | var nsg1 = "This is the `nsg1` object"; 5 | alert("Non Sequential Global script 1"); 6 | } finally { 7 | _satellite._customJSLoaded('def'); 8 | } 9 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_global_2.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Non Sequential Global script 2"); 3 | console.log("Window object `nsg2` should now be set."); 4 | var nsg2 = "This is the `nsg2` object"; 5 | console.log("DE_One Value : " + _satellite.getVar("DE_One")); 6 | } finally { 7 | _satellite._customJSLoaded('efg'); 8 | } 9 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_global_3.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Non Sequential Global script 3"); 3 | console.log("Window object `nsg3` should now be set."); 4 | var nsg3 = "This is the `nsg3` object" 5 | } finally { 6 | _satellite._customJSLoaded('fgh'); 7 | } 8 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_non_global_1.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('jkl', function(event, target) { 2 | console.log("Sequential Non Global script 1"); 3 | console.log("Window object `nsng1` should now be set."); 4 | window.nsng1 = "This is the `nsng1` object"; 5 | }); 6 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_non_global_2.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('klm', function(event, target) { 2 | console.log("Sequential Non Global script 2"); 3 | console.log("Window object `nsng2` should now be set."); 4 | window.nsng2 = "This is the `nsng2` object"; 5 | console.log("DE_One Value : " + _satellite.getVar("DE_One")); 6 | }); 7 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/non_sequential_non_global_3.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('lmn', function(event, target) { 2 | console.log("Sequential Non Global script 3"); 3 | console.log("Window object `nsng3` should now be set."); 4 | window.nsng3 = "This is the `nsng3` object"; 5 | }); 6 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/pl_non_sequential_HTML_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/pl_sequential_global_1.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Page Load Sequential Global script 1"); 3 | console.log("Window object `plsg1` should now be set."); 4 | var plsg1 = "This is the `plsg1` object"; 5 | } finally { 6 | _satellite._customJSLoaded('opq'); 7 | } 8 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/pl_sequential_global_2.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Page Load Sequential Global script 2"); 3 | console.log("Window object `plsg2` should now be set."); 4 | var plsg2 = "This is the `plsg2` object" 5 | } finally { 6 | _satellite._customJSLoaded('pqr'); 7 | } 8 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_global_1.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Sequential Global script 1"); 3 | console.log("Window object `sg1` should now be set."); 4 | var sg1 = "This is the `sg1` object"; 5 | } finally { 6 | _satellite._customJSLoaded('abc'); 7 | } 8 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_global_2.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Sequential Global script 2"); 3 | console.log("Window object `sg2` should now be set."); 4 | var sg2 = "This is the `sg2` object"; 5 | console.log("DE_One Value : " + _satellite.getVar("DE_One")); 6 | } finally { 7 | _satellite._customJSLoaded('bcd'); 8 | } 9 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_global_3.js: -------------------------------------------------------------------------------- 1 | try { 2 | console.log("Sequential Global script 3"); 3 | console.log("Window object `sg3` should now be set."); 4 | var sg3 = "This is the `sg3` object" 5 | } finally { 6 | _satellite._customJSLoaded('cde'); 7 | } 8 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_non_global_1.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('ghi', function(event, target) { 2 | console.log("Sequential Non Global script 1"); 3 | console.log("Window object `sng1` should now be set."); 4 | window.sng1 = "This is the `sng1` object"; 5 | }); 6 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_non_global_2.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('hij', function(event, target) { 2 | console.log("Sequential Non Global script 2"); 3 | console.log("Window object `sng2` should now be set."); 4 | window.sng2 = "This is the `sng2` object"; 5 | console.log("DE_One Value : " + _satellite.getVar("DE_One")); 6 | }); 7 | -------------------------------------------------------------------------------- /.sandbox-3rdPartyTags/files/sequential_non_global_3.js: -------------------------------------------------------------------------------- 1 | _satellite._customJSLoaded('ijk', function(event, target) { 2 | console.log("Sequential Non Global script 3"); 3 | console.log("Window object `sng3` should now be set."); 4 | window.sng3 = "This is the `sng3` object"; 5 | }); 6 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | 3 | plugins: 4 | - checksum: 0c15f3682f03dfdd8bbf8497b3fdaa55938167d8909356804ab90898eb816dc911f9220c536d03fe7a028a48622afe58aaf6ff382cd20dad11dc527d85fcf21b 5 | path: .yarn/plugins/plugin-rsp-duplicates.cjs 6 | spec: "https://raw.githubusercontent.com/adobe/react-spectrum/refs/heads/main/lib/yarn-plugin-rsp-duplicates.js" 7 | 8 | yarnPath: .yarn/releases/yarn-4.9.1.cjs 9 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | © Copyright 2015-2019 Adobe. All rights reserved. 2 | 3 | Adobe holds the copyright for all the files found in this repository. 4 | 5 | See the LICENSE file for licensing information. 6 | -------------------------------------------------------------------------------- /createEntryFile.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs-extra'); 2 | 3 | module.exports = function(outputPath, componentName, viewFileName) { 4 | fs.outputFileSync(outputPath, 5 | `import renderView from '../../src/view/renderView'; 6 | import ${componentName}, { formConfig } from '../../src/view/${viewFileName}'; 7 | 8 | export default renderView(${componentName}, formConfig);` 9 | ); 10 | }; 11 | -------------------------------------------------------------------------------- /dedupe.md: -------------------------------------------------------------------------------- 1 | # Upgrade Yarn 2 | yarn set version berry 3 | 4 | # Yarn Dedupe Plugin 5 | * Written by react-spectrum team 6 | * https://github.com/adobe/react-spectrum/blob/main/lib/yarn-plugin-rsp-duplicates.js 7 | * runs after every `yarn install` command 8 | * Ensure an entry within .yarnrc.yml 9 | * Can handle dedupes with `yarn dedupe` (yarn@v4) 10 | 11 | # Node Lock Check File 12 | * Prints out duplicates 13 | * https://git.corp.adobe.com/gist/luyau/5033d7b6fb95deb94be24c623e0b1118 14 | -------------------------------------------------------------------------------- /helpers/mockTurbineVariable.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This allows us to mock the turbine free variable in our tests. This is the turbine object that 4 | // extension library modules can access and is provided by turbine. Although turbine won't be on 5 | // window when running in Launch, this seems to be the easiest way to simulate a free variable 6 | // when testing. 7 | window.mockTurbineVariable = function(turbine) { 8 | window.turbine = turbine; 9 | }; 10 | 11 | window.resetTurbineVariable = function() { 12 | window.turbine = {}; 13 | }; 14 | 15 | window.resetTurbineVariable(); 16 | -------------------------------------------------------------------------------- /helpers/waitUntil.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Polls an escape function. Once the escape function returns true, executes a run function. 5 | * @param {Function} escapeFunction A function that will be repeatedly executed and should return 6 | * true when the run function should be called. 7 | * @param {number} checkDelay Number of milliseconds to wait before running the escape function 8 | * again. 9 | * @returns {{then: Function}} The run function should be registered via the then method. 10 | */ 11 | (function() { 12 | window.waitUntil = function(escapeFunction, checkDelay) { 13 | var _runFunction; 14 | 15 | var interval = setInterval(function() { 16 | if (escapeFunction()) { 17 | clearInterval(interval); 18 | 19 | if (_runFunction) { 20 | _runFunction(); 21 | } 22 | } 23 | }, checkDelay || 1); 24 | 25 | return { 26 | then: function(runFunction) { 27 | _runFunction = runFunction; 28 | } 29 | }; 30 | }; 31 | })(); 32 | -------------------------------------------------------------------------------- /react-collection-view-4.1.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe/reactor-extension-core/3e56c565a6f01ee186fbb9b24a49ce1230a59f30/react-collection-view-4.1.5.tgz -------------------------------------------------------------------------------- /react-react-spectrum-2.25.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe/reactor-extension-core/3e56c565a6f01ee186fbb9b24a49ce1230a59f30/react-react-spectrum-2.25.0.tgz -------------------------------------------------------------------------------- /src/lib/__tests__/helpers/flushPromiseChains.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | /** 15 | * Returns a promise that will be resolved after all outstanding promise chains 16 | * have been flushed. This assumes (1) that the promise chains to be flushed 17 | * resolve their promises promptly (rather than doing something like 18 | * setTimeout(..., 100) somewhere in the chain) and (2) that the chains 19 | * are no longer than 10 promises long. 20 | * @returns {Promise} 21 | */ 22 | module.exports = function () { 23 | var promise; 24 | 25 | for (var i = 0; i < 10; i += 1) { 26 | promise = promise 27 | ? promise.then(function () { 28 | return Promise.resolve(); 29 | }) 30 | : Promise.resolve(); 31 | } 32 | 33 | return promise; 34 | }; 35 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/__tests__/unescapeHtmlCode.test.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | var unescapeHtmlCode = require('../unescapeHtmlCode'); 15 | 16 | describe('unescape html code', function () { 17 | it('decodes html entities', function () { 18 | expect( 19 | unescapeHtmlCode('https://www.google.com/?id=DC&l=gtmData>Layer') 20 | ).toBe('https://www.google.com/?id=DC&l=gtmData>Layer'); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/decorateCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | var decorateGlobalJavaScriptCode = require('./decorators/decorateGlobalJavaScriptCode'); 15 | var decorateNonGlobalJavaScriptCode = require('./decorators/decorateNonGlobalJavaScriptCode'); 16 | var decorateHtmlCode = require('./decorators/decorateHtmlCode'); 17 | 18 | var decorators = { 19 | javascript: function (action, source) { 20 | return action.settings.global 21 | ? decorateGlobalJavaScriptCode(action, source) 22 | : decorateNonGlobalJavaScriptCode(action, source); 23 | }, 24 | html: decorateHtmlCode 25 | }; 26 | 27 | module.exports = function (action, source) { 28 | return decorators[action.settings.language](action, source); 29 | }; 30 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/decorators/decorateGlobalJavaScriptCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 'use strict'; 12 | 13 | var Promise = require('@adobe/reactor-promise'); 14 | 15 | module.exports = function (_, source) { 16 | // The line break after the source is important in case their last line of code is a comment. 17 | return { 18 | code: '\n' + source + '\n', 19 | promise: Promise.resolve() 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/decorators/decorateNonGlobalJavaScriptCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 'use strict'; 12 | 13 | var Promise = require('@adobe/reactor-promise'); 14 | var id = 0; 15 | 16 | module.exports = function (action, source) { 17 | var runScriptFnName = '_runScript' + ++id; 18 | 19 | var promise = new Promise(function (resolve, reject) { 20 | _satellite[runScriptFnName] = function (fn) { 21 | delete _satellite[runScriptFnName]; 22 | 23 | // Use Promise constructor instead of Promise.resolve() so we can 24 | // catch errors from custom code. 25 | new Promise(function (_resolve) { 26 | _resolve( 27 | fn.call( 28 | action.event.element, 29 | action.event, 30 | action.event.target, 31 | Promise 32 | ) 33 | ); 34 | }).then(resolve, reject); 35 | }; 36 | }); 37 | 38 | // The line break after the source is important in case their last line of code is a comment. 39 | var code = 40 | '_satellite["' + 42 | runScriptFnName + 43 | '"](function(event, target, Promise) {\n' + 44 | source + 45 | '\n});'; 47 | 48 | return { 49 | code: code, 50 | promise: promise 51 | }; 52 | }; 53 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/loadCodeSequentially.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var Promise = require('@adobe/reactor-promise'); 16 | var getSourceByUrl = require('./getSourceByUrl'); 17 | 18 | var previousExecuteCodePromise = Promise.resolve(); 19 | 20 | module.exports = function (sourceUrl) { 21 | var sequentiallyLoadCodePromise = new Promise(function (resolve) { 22 | var loadCodePromise = getSourceByUrl(sourceUrl); 23 | 24 | Promise.all([loadCodePromise, previousExecuteCodePromise]).then(function ( 25 | values 26 | ) { 27 | var source = values[0]; 28 | resolve(source); 29 | }); 30 | }); 31 | 32 | previousExecuteCodePromise = sequentiallyLoadCodePromise; 33 | return sequentiallyLoadCodePromise; 34 | }; 35 | -------------------------------------------------------------------------------- /src/lib/actions/helpers/unescapeHtmlCode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | var document = require('@adobe/reactor-document'); 15 | var el = document.createElement('div'); 16 | 17 | module.exports = function (html) { 18 | el.innerHTML = html; 19 | 20 | // IE and Firefox differ. 21 | return el.textContent || el.innerText || html; 22 | }; 23 | -------------------------------------------------------------------------------- /src/lib/conditions/__tests__/browser.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var mockClientInfo = { 16 | browser: 'Foo' 17 | }; 18 | 19 | var conditionDelegateInjector = require('inject-loader!../browser'); 20 | var conditionDelegate = conditionDelegateInjector({ 21 | './helpers/clientInfo': mockClientInfo 22 | }); 23 | 24 | var getSettings = function (browsers) { 25 | return { 26 | browsers: browsers 27 | }; 28 | }; 29 | 30 | describe('browser condition delegate', function () { 31 | it('returns true when the current browser matches one of the selected browsers', function () { 32 | var settings = getSettings(['Shoe', 'Goo', 'Foo', 'Moo']); 33 | expect(conditionDelegate(settings)).toBe(true); 34 | }); 35 | 36 | it( 37 | 'returns false when the current browser does not match any of the ' + 38 | 'selected browsers', 39 | function () { 40 | var settings = getSettings(['Shoe', 'Goo', 'Boo', 'Moo']); 41 | expect(conditionDelegate(settings)).toBe(false); 42 | } 43 | ); 44 | }); 45 | -------------------------------------------------------------------------------- /src/lib/conditions/__tests__/customCode.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var conditionDelegate = require('../customCode'); 16 | 17 | describe('custom code condition delegate', function () { 18 | it('should run a user-defined function', function () { 19 | var settings = { 20 | source: function () { 21 | return true; 22 | } 23 | }; 24 | 25 | var event = { 26 | element: {}, 27 | target: {} 28 | }; 29 | 30 | spyOn(settings, 'source').and.callThrough(); 31 | conditionDelegate(settings, event); 32 | 33 | expect(settings.source.calls.first()).toEqual({ 34 | object: event.element, 35 | invocationOrder: jasmine.any(Number), 36 | args: [event, event.target], 37 | returnValue: true 38 | }); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /src/lib/conditions/__tests__/deviceType.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var mockClientInfo = { 16 | deviceType: 'Foo' 17 | }; 18 | 19 | var conditionDelegateInjector = require('inject-loader!../deviceType'); 20 | var conditionDelegate = conditionDelegateInjector({ 21 | './helpers/clientInfo': mockClientInfo 22 | }); 23 | 24 | var getSettings = function (deviceTypes) { 25 | return { 26 | deviceTypes: deviceTypes 27 | }; 28 | }; 29 | 30 | describe('device type condition delegate', function () { 31 | it( 32 | 'returns true when the current device type matches one of the selected ' + 33 | 'device types', 34 | function () { 35 | var settings = getSettings(['Shoe', 'Goo', 'Foo', 'Moo']); 36 | expect(conditionDelegate(settings)).toBe(true); 37 | } 38 | ); 39 | 40 | it( 41 | 'returns false when the current device type does not match any of the selected ' + 42 | 'device types', 43 | function () { 44 | var settings = getSettings(['Shoe', 'Goo', 'Boo', 'Moo']); 45 | expect(conditionDelegate(settings)).toBe(false); 46 | } 47 | ); 48 | }); 49 | -------------------------------------------------------------------------------- /src/lib/conditions/__tests__/operatingSystem.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var mockClientInfo = { 16 | os: 'Foo' 17 | }; 18 | 19 | var conditionDelegateInjector = require('inject-loader!../operatingSystem'); 20 | var conditionDelegate = conditionDelegateInjector({ 21 | './helpers/clientInfo': mockClientInfo 22 | }); 23 | 24 | var getSettings = function (operatingSystems) { 25 | return { 26 | operatingSystems: operatingSystems 27 | }; 28 | }; 29 | 30 | describe('operating system condition delegate', function () { 31 | it('returns true when the current OS matches one of the selected OSs', function () { 32 | var settings = getSettings(['Shoe', 'Goo', 'Foo', 'Moo']); 33 | expect(conditionDelegate(settings)).toBe(true); 34 | }); 35 | 36 | it('returns false when the current OS does not match any of the selected OSs', function () { 37 | var settings = getSettings(['Shoe', 'Goo', 'Boo', 'Moo']); 38 | expect(conditionDelegate(settings)).toBe(false); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /src/lib/conditions/__tests__/protocol.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var conditionDelegate = require('../protocol'); 16 | 17 | var getSettings = function (protocol) { 18 | return { 19 | protocol: protocol 20 | }; 21 | }; 22 | 23 | describe('protocol condition delegate', function () { 24 | it('returns true when the browser protocol matches', function () { 25 | var settings = getSettings('http:'); 26 | expect(conditionDelegate(settings)).toBe(true); 27 | }); 28 | 29 | it('returns false when the browser protocol does not match', function () { 30 | var settings = getSettings('javascript:'); 31 | expect(conditionDelegate(settings)).toBe(false); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /src/lib/conditions/browser.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var clientInfo = require('./helpers/clientInfo'); 16 | 17 | /** 18 | * Browser condition. Determines if the actual browser matches at least one acceptable browser. 19 | * @param {Object} settings Condition settings. 20 | * @param {string[]} settings.browsers An array of acceptable browsers. 21 | * @returns {boolean} 22 | */ 23 | module.exports = function (settings) { 24 | return settings.browsers.indexOf(clientInfo.browser) !== -1; 25 | }; 26 | -------------------------------------------------------------------------------- /src/lib/conditions/customCode.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Custom code condition. This executes condition code provided by the user. 17 | * @param {Object} settings Condition settings. 18 | * @param {Function} settings.source The custom script function. 19 | * @param {Object} event The underlying event object that triggered the rule. 20 | * @param {Object} event.element The element that the rule was targeting. 21 | * @param {Object} event.target The element on which the event occurred. 22 | * @returns {boolean} 23 | */ 24 | module.exports = function (settings, event) { 25 | // `this` and `target` are provided separately from event for backward-compatibility. 26 | return settings.source.call(event.element, event, event.target); 27 | }; 28 | -------------------------------------------------------------------------------- /src/lib/conditions/dateRange.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Date range condition. Determines if we are within a specific date range. 17 | * @param {Object} settings Condition settings. 18 | * @param {string} [settings.start] A date, in ISO 8601, indicating when the condition should 19 | * start returning true. 20 | * @param {string} [settings.end] A date, in ISO 8601, indicating when the condition should 21 | * stop returning true. 22 | * @returns {boolean} 23 | */ 24 | module.exports = function (settings) { 25 | var now = new Date(); 26 | 27 | if (settings.start && now < new Date(settings.start)) { 28 | return false; 29 | } 30 | 31 | if (settings.end && now > new Date(settings.end)) { 32 | return false; 33 | } 34 | 35 | return true; 36 | }; 37 | -------------------------------------------------------------------------------- /src/lib/conditions/deviceType.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var clientInfo = require('./helpers/clientInfo'); 16 | 17 | /** 18 | * Device type condition. Determines if the actual device type matches at least one acceptable 19 | * device type. 20 | * @param {Object} settings Condition settings. 21 | * @param {string[]} settings.deviceTypes An array of device types. 22 | * @returns {boolean} 23 | */ 24 | module.exports = function (settings) { 25 | return settings.deviceTypes.indexOf(clientInfo.deviceType) !== -1; 26 | }; 27 | -------------------------------------------------------------------------------- /src/lib/conditions/hash.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var textMatch = require('../helpers/textMatch'); 16 | 17 | /** 18 | * Hash condition. Determines if the actual hash (URL fragment identifier) matches at least one 19 | * acceptable hash. 20 | * @param {Object} settings Condition settings. 21 | * @param {Object[]} settings.hashes Acceptable hashes. 22 | * @param {string} settings.hashes[].value An acceptable hash value 23 | * @param {boolean} [settings.hashes[].valueIsRegex=false] Whether value on the object 24 | * instance is intended to be a regular expression. 25 | * @returns {boolean} 26 | */ 27 | module.exports = function (settings) { 28 | var hash = document.location.hash; 29 | return settings.hashes.some(function (acceptableHash) { 30 | var acceptableValue = acceptableHash.valueIsRegex 31 | ? new RegExp(acceptableHash.value, 'i') 32 | : acceptableHash.value; 33 | return textMatch(hash, acceptableValue); 34 | }); 35 | }; 36 | -------------------------------------------------------------------------------- /src/lib/conditions/helpers/compareNumbers.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Enum for comparison operators. 17 | * @readonly 18 | * @enum {string} 19 | */ 20 | var comparisonOperator = { 21 | GREATER_THAN: '>', 22 | LESS_THAN: '<', 23 | EQUALS: '=' 24 | }; 25 | 26 | /** 27 | * Compares two numbers using a comparison operator enumeration value. 28 | * @param {number} num1 The first number. 29 | * @param {comparisonOperator} The comparison operator. 30 | * @param {number} num2 The second number. 31 | * @returns {Function} 32 | */ 33 | var compareNumbers = function (num1, op, num2) { 34 | switch (op) { 35 | case comparisonOperator.GREATER_THAN: 36 | return num1 > num2; 37 | case comparisonOperator.LESS_THAN: 38 | return num1 < num2; 39 | case comparisonOperator.EQUALS: 40 | return num1 === num2; 41 | } 42 | }; 43 | 44 | /** 45 | * Utility for comparing two numbers. 46 | * @returns {Function} 47 | */ 48 | module.exports = compareNumbers; 49 | -------------------------------------------------------------------------------- /src/lib/conditions/newReturningVisitor.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | var visitorTracking = require('../helpers/visitorTracking'); 15 | 16 | /** 17 | * New vs. returning visitor condition. Determines if the visitor is a new or returning visitor. 18 | * @param {Object} settings Condition settings. 19 | * @param {boolean} settings.isNewVisitor When true, the condition returns true if the 20 | * visitor is a new visitor. When false, the condition returns true if the visitor is a returning 21 | * visitor. 22 | * @returns {boolean} 23 | */ 24 | module.exports = function (settings) { 25 | var isNewVisitor = visitorTracking.getIsNewVisitor(); 26 | return settings.isNewVisitor ? isNewVisitor : !isNewVisitor; 27 | }; 28 | -------------------------------------------------------------------------------- /src/lib/conditions/operatingSystem.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var clientInfo = require('./helpers/clientInfo'); 16 | 17 | /** 18 | * Operating system condition. Determines if the actual operating system matches at least one 19 | * acceptable operating system. 20 | * @param {Object} settings Condition settings. 21 | * @param {string[]} settings.operatingSystems An array of acceptable operating 22 | * systems. 23 | * @returns {boolean} 24 | */ 25 | module.exports = function (settings) { 26 | return settings.operatingSystems.indexOf(clientInfo.os) !== -1; 27 | }; 28 | -------------------------------------------------------------------------------- /src/lib/conditions/path.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | var textMatch = require('../helpers/textMatch'); 17 | 18 | /** 19 | * Path condition. Determines if the actual path matches at least one acceptable path. 20 | * @param {Object} settings Condition settings. 21 | * @param {Object[]} settings.paths Acceptable paths. 22 | * @param {string} settings.paths[].value An acceptable path value. 23 | * @param {boolean} [settings.paths[].valueIsRegex=false] Whether value on the object 24 | * instance is intended to be a regular expression. 25 | * @returns {boolean} 26 | */ 27 | module.exports = function (settings) { 28 | var path = document.location.pathname; 29 | return settings.paths.some(function (acceptablePath) { 30 | var acceptableValue = acceptablePath.valueIsRegex 31 | ? new RegExp(acceptablePath.value, 'i') 32 | : acceptablePath.value; 33 | return textMatch(path, acceptableValue); 34 | }); 35 | }; 36 | -------------------------------------------------------------------------------- /src/lib/conditions/pathAndQuerystring.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | var textMatch = require('../helpers/textMatch'); 17 | 18 | /** 19 | * Path and query string condition. Provided for legacy reasons. Determines if the actual path + 20 | * query string matches at least one acceptable path + query string. 21 | * @param {Object} settings Condition settings. 22 | * @param {Object[]} settings.paths Acceptable paths. 23 | * @param {string} settings.paths[].value An acceptable path value. 24 | * @param {boolean} [settings.paths[].valueIsRegex=false] Whether value on the object 25 | * instance is intended to be a regular expression. 26 | * @returns {boolean} 27 | */ 28 | module.exports = function (settings) { 29 | var path = document.location.pathname + document.location.search; 30 | return settings.paths.some(function (acceptablePath) { 31 | var acceptableValue = acceptablePath.valueIsRegex 32 | ? new RegExp(acceptablePath.value, 'i') 33 | : acceptablePath.value; 34 | return textMatch(path, acceptableValue); 35 | }); 36 | }; 37 | -------------------------------------------------------------------------------- /src/lib/conditions/protocol.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Protocol condition. Determines if the actual protocol matches at least one acceptable 17 | * protocol. 18 | * @param {Object} settings Condition settings. 19 | * @param {string} settings.protocol An acceptable protocol. 20 | * @returns {boolean} 21 | */ 22 | module.exports = function (settings) { 23 | return ( 24 | document.location.protocol.toLowerCase() === settings.protocol.toLowerCase() 25 | ); 26 | }; 27 | -------------------------------------------------------------------------------- /src/lib/conditions/sessions.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var visitorTracking = require('../helpers/visitorTracking'); 16 | var compareNumbers = require('./helpers/compareNumbers'); 17 | 18 | /** 19 | * Sessions condition. Determines if the number of sessions matches constraints. 20 | * @param {Object} settings Condition settings. 21 | * @param {number} settings.count The number of sessions to compare against. 22 | * @param {comparisonOperator} settings.operator The comparison operator to use to 23 | * compare against count. 24 | * @returns {boolean} 25 | */ 26 | module.exports = function (settings) { 27 | return compareNumbers( 28 | visitorTracking.getSessionCount(), 29 | settings.operator, 30 | settings.count 31 | ); 32 | }; 33 | -------------------------------------------------------------------------------- /src/lib/conditions/subdomain.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | var textMatch = require('../helpers/textMatch'); 17 | 18 | /** 19 | * Subdomain condition. Determines if the actual subdomain matches at least one acceptable 20 | * subdomain. 21 | * @param {Object} settings Condition settings. 22 | * @param {Object[]} settings.subdomains Acceptable subdomains. 23 | * @param {string} settings.subdomains[].value An acceptable subdomain value. 24 | * @param {boolean} [settings.subdomains[].valueIsRegex=false] Whether value on the 25 | * object instance is intended to be a regular expression. 26 | * @returns {boolean} 27 | */ 28 | module.exports = function (settings) { 29 | var subdomain = document.location.hostname; 30 | return settings.subdomains.some(function (acceptableSubdomain) { 31 | var acceptableValue = acceptableSubdomain.valueIsRegex 32 | ? new RegExp(acceptableSubdomain.value, 'i') 33 | : acceptableSubdomain.value; 34 | return textMatch(subdomain, acceptableValue); 35 | }); 36 | }; 37 | -------------------------------------------------------------------------------- /src/lib/conditions/timeOnSite.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var visitorTracking = require('../helpers/visitorTracking'); 16 | var compareNumbers = require('./helpers/compareNumbers'); 17 | var castToNumberIfString = 18 | require('../helpers/stringAndNumberUtils').castToNumberIfString; 19 | 20 | /** 21 | * Time on site condition. Determines if the user has been on the site for a certain amount 22 | * of time. 23 | * @param {Object} settings Condition settings. 24 | * @param {number} settings.minutes The number of minutes to compare against. 25 | * @param {comparisonOperator} settings.operator The comparison operator to use to 26 | * compare against minutes. 27 | * @returns {boolean} 28 | */ 29 | module.exports = function (settings) { 30 | return compareNumbers( 31 | visitorTracking.getMinutesOnSite(), 32 | settings.operator, 33 | castToNumberIfString(settings.minutes) 34 | ); 35 | }; 36 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/constant.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var dataElementDelegate = require('../constant'); 16 | 17 | describe('constant data element delegate', function () { 18 | it('returns the value set', function () { 19 | var settings = { 20 | value: 'foo' 21 | }; 22 | 23 | expect(dataElementDelegate(settings)).toBe('foo'); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/cookie.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var cookie = require('js-cookie'); 16 | var dataElementDelegate = require('../cookie'); 17 | 18 | describe('cookie data element delegate', function () { 19 | beforeAll(function () { 20 | cookie.set('foo', 'bar'); 21 | }); 22 | 23 | afterAll(function () { 24 | cookie.remove('foo'); 25 | }); 26 | 27 | it('returns the value of a cookie', function () { 28 | var settings = { 29 | name: 'foo' 30 | }; 31 | 32 | expect(dataElementDelegate(settings)).toBe('bar'); 33 | }); 34 | 35 | it('returns undefined if the cookie is not set', function () { 36 | var settings = { 37 | name: 'unicorn' 38 | }; 39 | 40 | expect(dataElementDelegate(settings)).toBe(undefined); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/customCode.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var dataElementDelegate = require('../customCode'); 16 | 17 | describe('custom code data element delegate', function () { 18 | it('returns the return value of a user-defined script', function () { 19 | var settings = { 20 | source: function () { 21 | return 'foo'; 22 | } 23 | }; 24 | 25 | expect(dataElementDelegate(settings)).toBe('foo'); 26 | }); 27 | 28 | it('receives the event parameter if provided', function () { 29 | var settings = { 30 | source: function (event) { 31 | return event.foo; 32 | } 33 | }; 34 | var event = { 35 | foo: 'bar' 36 | }; 37 | 38 | expect(dataElementDelegate(settings, event)).toBe('bar'); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/deviceAttributes.test.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | var deviceAttributesDelegateInjector = require('inject-loader!../deviceAttributes'); 15 | 16 | describe('visitor attributes data element delegate', function () { 17 | it('returns the window size', function () { 18 | var deviceAttributesDelegate = deviceAttributesDelegateInjector({ 19 | '@adobe/reactor-window': { 20 | screen: { width: 100, height: 200 } 21 | } 22 | }); 23 | 24 | expect(deviceAttributesDelegate({ attribute: 'screenSize' })).toBe( 25 | '100x200' 26 | ); 27 | }); 28 | 29 | it('returns the window size', function () { 30 | var deviceAttributesDelegate = deviceAttributesDelegateInjector({ 31 | '@adobe/reactor-document': { 32 | documentElement: { clientWidth: 150, clientHeight: 250 } 33 | } 34 | }); 35 | 36 | expect(deviceAttributesDelegate({ attribute: 'windowSize' })).toBe( 37 | '150x250' 38 | ); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/mergedObjects.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2021 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 | 'use strict'; 14 | 15 | describe('merged objects data element delegate', function () { 16 | var deepMerge; 17 | var mergedObjects; 18 | 19 | beforeEach(function () { 20 | deepMerge = jasmine.createSpy().and.returnValue({ 21 | a: 'b', 22 | c: 'd' 23 | }); 24 | mergedObjects = require('inject-loader!../mergedObjects')({ 25 | '../helpers/deepMerge': deepMerge 26 | }); 27 | }); 28 | 29 | it('calls deepMerge with objects and returns result', function () { 30 | var result = mergedObjects({ 31 | objects: [ 32 | { 33 | a: 'b' 34 | }, 35 | { 36 | c: 'd' 37 | } 38 | ] 39 | }); 40 | expect(deepMerge).toHaveBeenCalledWith( 41 | {}, 42 | { 43 | a: 'b' 44 | }, 45 | { 46 | c: 'd' 47 | } 48 | ); 49 | expect(result).toEqual({ 50 | a: 'b', 51 | c: 'd' 52 | }); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /src/lib/dataElements/__tests__/randomNumber.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var dataElementDelegate = require('../randomNumber'); 16 | 17 | describe('random number data element delegate', function () { 18 | it('returns a random number between the min and the max', function () { 19 | var settings = { 20 | min: 10, 21 | max: 20 22 | }; 23 | 24 | var result = dataElementDelegate(settings); 25 | expect(result).toBeGreaterThanOrEqual(10); 26 | expect(result).toBeLessThanOrEqual(20); 27 | }); 28 | 29 | it('returns NaN if min is greater than max', function () { 30 | var settings = { 31 | min: 20, 32 | max: 10 33 | }; 34 | 35 | expect(dataElementDelegate(settings)).toEqual(NaN); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /src/lib/dataElements/conditionalValue.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | var valueComparison = require('../conditions/valueComparison'); 15 | 16 | module.exports = function (settings) { 17 | return valueComparison(settings) 18 | ? settings.conditionalValue 19 | : settings.fallbackValue; 20 | }; 21 | -------------------------------------------------------------------------------- /src/lib/dataElements/constant.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * The cookie data element. 17 | * @param {Object} settings The data element settings object. 18 | * @param {string} settings.value The constant value that should be returned. 19 | * @returns {string} 20 | */ 21 | 22 | module.exports = function (settings) { 23 | return settings.value; 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/dataElements/cookie.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var cookie = require('@adobe/reactor-cookie'); 16 | 17 | /** 18 | * The cookie data element. 19 | * @param {Object} settings The data element settings object. 20 | * @param {string} settings.name The name of the cookie for which a value should be retrieved. 21 | * @returns {string} 22 | */ 23 | module.exports = function (settings) { 24 | return cookie.get(settings.name); 25 | }; 26 | -------------------------------------------------------------------------------- /src/lib/dataElements/customCode.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * The custom data element. 17 | * @param {Object} settings The data element settings object. 18 | * @param {string} settings.source The function that should be called which will return a value. 19 | * @param {string} event The event (if any) that triggered the evaluation of the data element. 20 | * @returns {string} 21 | */ 22 | module.exports = function (settings, event) { 23 | return settings.source(event); 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/dataElements/deviceAttributes.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | /** 15 | * The visitor attributes data element. 16 | * @param {Object} settings The data element settings object. 17 | * @param {string} settings.attribute The attribute that should be returned. 18 | * @returns {string} 19 | */ 20 | 21 | var document = require('@adobe/reactor-document'); 22 | var window = require('@adobe/reactor-window'); 23 | 24 | module.exports = function (settings) { 25 | switch (settings.attribute) { 26 | case 'windowSize': 27 | return ( 28 | document.documentElement.clientWidth + 29 | 'x' + 30 | document.documentElement.clientHeight 31 | ); 32 | case 'screenSize': 33 | return window.screen.width + 'x' + window.screen.height; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /src/lib/dataElements/domAttribute.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * The dom data element. 17 | * @param {Object} settings The data element settings object. 18 | * @param {string} settings.elementSelector The CSS selector for a DOM element. 19 | * @param {string} settings.elementProperty The name of the property or attribute of the DOM 20 | * element. 21 | * @returns {string} 22 | */ 23 | module.exports = function (settings) { 24 | var element = document.querySelector(settings.elementSelector); 25 | 26 | if (element) { 27 | var property = settings.elementProperty; 28 | 29 | if (property === 'text') { 30 | return element.innerText || element.textContent; 31 | } else if (property in element) { 32 | return element[property]; 33 | } else { 34 | return element.getAttribute ? element.getAttribute(property) : undefined; 35 | } 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /src/lib/dataElements/javascriptVariable.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | var getObjectProperty = require('../helpers/getObjectProperty.js'); 15 | 16 | /** 17 | * The variable data element. 18 | * @param {Object} settings The data element settings object. 19 | * @param {string} settings.path The global path to the variable holding the data element value. 20 | * @returns {string} 21 | */ 22 | module.exports = function (settings) { 23 | return getObjectProperty(window, settings.path); 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/dataElements/localStorage.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var window = require('@adobe/reactor-window'); 16 | 17 | /** 18 | * The local storage data element. 19 | * @param {Object} settings The data element settings object. 20 | * @param {string} settings.name The name of the local storage item for which a value should be 21 | * retrieved. 22 | * @returns {string} 23 | */ 24 | module.exports = function (settings) { 25 | // When local storage is disabled on Safari, the mere act of referencing window.localStorage 26 | // throws an error. For this reason, referencing window.localStorage without being inside 27 | // a try-catch should be avoided. 28 | try { 29 | return window.localStorage.getItem(settings.name); 30 | } catch (e) { 31 | return null; 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/lib/dataElements/mergedObjects.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2021 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 | 'use strict'; 14 | 15 | var deepMerge = require('../helpers/deepMerge'); 16 | 17 | module.exports = function (settings) { 18 | var args = settings.objects.slice(); 19 | // This object will be the target object that all other objects 20 | // get merged into. 21 | args.unshift({}); 22 | return deepMerge.apply(null, args); 23 | }; 24 | -------------------------------------------------------------------------------- /src/lib/dataElements/pageInfo.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | 17 | /** 18 | * The page info data element. 19 | * @param {Object} settings The data element settings object. 20 | * @param {string} settings.attribute The attribute that should be returned. 21 | * @returns {string} 22 | */ 23 | module.exports = function (settings) { 24 | switch (settings.attribute) { 25 | case 'url': 26 | return document.location.href; 27 | case 'hostname': 28 | return document.location.hostname; 29 | case 'pathname': 30 | return document.location.pathname; 31 | case 'protocol': 32 | return document.location.protocol; 33 | case 'referrer': 34 | return document.referrer; 35 | case 'title': 36 | return document.title; 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /src/lib/dataElements/queryStringParameter.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var window = require('@adobe/reactor-window'); 16 | var queryString = require('@adobe/reactor-query-string'); 17 | 18 | /** 19 | * The query string parameter data element. 20 | * @param {Object} settings The data element settings object. 21 | * @param {string} settings.name The query string parameter name. 22 | * @param {string} [settings.caseInsensitive] Whether casing should be ignored. 23 | * @returns {string} 24 | */ 25 | module.exports = function (settings) { 26 | var queryParams = queryString.parse(window.location.search); 27 | 28 | if (settings.caseInsensitive) { 29 | var lowerCaseName = settings.name.toLowerCase(); 30 | var keys = Object.keys(queryParams); 31 | for (var i = 0; i < keys.length; i++) { 32 | var key = keys[i]; 33 | if (key.toLowerCase() === lowerCaseName) { 34 | return queryParams[key]; 35 | } 36 | } 37 | } else { 38 | return queryParams[settings.name]; 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /src/lib/dataElements/randomNumber.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * The random number data element. 17 | * @param {Object} settings The data element settings object. 18 | * @param {number} settings.min The minimum (inclusive) of the range from which to derive a 19 | * random number. 20 | * @param {number} settings.max The maximum (inclusive) of the range from which to derive a 21 | * random number. 22 | * @returns {number} 23 | */ 24 | module.exports = function (settings) { 25 | var min = Math.ceil(settings.min); 26 | var max = Math.floor(settings.max); 27 | 28 | return min > max ? NaN : Math.floor(Math.random() * (max - min + 1)) + min; 29 | }; 30 | -------------------------------------------------------------------------------- /src/lib/dataElements/runtimeEnvironment.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | 'use strict'; 13 | 14 | /** 15 | * The launch environment data element. 16 | * @param {Object} settings The data element settings object. 17 | * @param {string} settings.attribute The attribute that should be returned. 18 | * @returns {string} 19 | */ 20 | 21 | var window = require('@adobe/reactor-window'); 22 | 23 | module.exports = function (settings, event) { 24 | switch (settings.attribute) { 25 | case 'buildDate': 26 | return turbine.buildInfo.buildDate; 27 | case 'environmentStage': 28 | return window._satellite.environment.stage; 29 | case 'propertyName': 30 | return window._satellite.property.name; 31 | case 'propertyId': 32 | return window._satellite.property.id; 33 | case 'ruleName': 34 | return event.$rule.name; 35 | case 'ruleId': 36 | return event.$rule.id; 37 | case 'eventType': 38 | return event.$type; 39 | case 'eventDetail': 40 | return event.detail; 41 | case 'DCRIdentifier': 42 | return event.identifier; 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /src/lib/dataElements/sessionStorage.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var window = require('@adobe/reactor-window'); 16 | 17 | /** 18 | * The session storage data element. 19 | * @param {Object} settings The data element settings object. 20 | * @param {string} settings.name The name of the session storage item for which a value should be 21 | * retrieved. 22 | * @returns {string} 23 | */ 24 | module.exports = function (settings) { 25 | // When session storage is disabled on Safari, the mere act of referencing window.sessionStorage 26 | // throws an error. For this reason, referencing window.sessionStorage without being inside 27 | // a try-catch should be avoided. 28 | try { 29 | return window.sessionStorage.getItem(settings.name); 30 | } catch (e) { 31 | return null; 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/lib/dataElements/visitorBehavior.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | var visitorTracking = require('../helpers/visitorTracking'); 15 | 16 | /** 17 | * The page info data element. 18 | * @param {Object} settings The data element settings object. 19 | * @param {string} settings.attribute The attribute that should be returned. 20 | * @returns {string} 21 | */ 22 | module.exports = function (settings) { 23 | switch (settings.attribute) { 24 | case 'landingPage': 25 | return visitorTracking.getLandingPage(); 26 | case 'trafficSource': 27 | return visitorTracking.getTrafficSource(); 28 | case 'minutesOnSite': 29 | return visitorTracking.getMinutesOnSite(); 30 | case 'sessionCount': 31 | return visitorTracking.getSessionCount(); 32 | case 'sessionPageViewCount': 33 | return visitorTracking.getSessionPageViewCount(); 34 | case 'lifetimePageViewCount': 35 | return visitorTracking.getLifetimePageViewCount(); 36 | case 'isNewVisitor': 37 | return visitorTracking.getIsNewVisitor(); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/blur.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('blur event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../blur'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'blur'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/customCode.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('custom code event delegate', function () { 16 | var delegate = require('../customCode'); 17 | 18 | it('triggers rule when custom code calls trigger', function () { 19 | var trigger = jasmine.createSpy(); 20 | var contextualData = { 21 | foo: 'bar' 22 | }; 23 | 24 | delegate( 25 | { 26 | source: function (trigger) { 27 | trigger(contextualData); 28 | } 29 | }, 30 | trigger 31 | ); 32 | 33 | expect(trigger.calls.count()).toBe(1); 34 | expect(trigger).toHaveBeenCalledWith(contextualData); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/domReady.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('dom ready event delegate', function () { 16 | it('sends the trigger to the pageLifecycleEvents helper module', function () { 17 | var domReadyInjector = require('inject-loader!../domReady'); 18 | var trigger = function () {}; 19 | var pageLifecycleEventsSpy = jasmine.createSpyObj('pageLifecycleEvents', [ 20 | 'registerDomReadyTrigger' 21 | ]); 22 | 23 | var delegate = domReadyInjector({ 24 | './helpers/pageLifecycleEvents': pageLifecycleEventsSpy 25 | }); 26 | 27 | delegate({}, trigger); 28 | expect(pageLifecycleEventsSpy.registerDomReadyTrigger).toHaveBeenCalledWith( 29 | trigger 30 | ); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/focus.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('focus event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../focus'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'focus'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/keyDown.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('key press event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../keyDown'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'keydown'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/keyPress.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('key press event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../keyPress'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'keypress'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/keyUp.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('key press event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../keyUp'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'keyup'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/libraryLoaded.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('library loaded event delegate', function () { 16 | it('sends the trigger to the pageLifecycleEvents helper module', function () { 17 | var libraryLoadedInjector = require('inject-loader!../libraryLoaded'); 18 | var trigger = function () {}; 19 | var pageLifecycleEventsSpy = jasmine.createSpyObj('pageLifecycleEvents', [ 20 | 'registerLibraryLoadedTrigger' 21 | ]); 22 | 23 | var delegate = libraryLoadedInjector({ 24 | './helpers/pageLifecycleEvents': pageLifecycleEventsSpy 25 | }); 26 | 27 | delegate({}, trigger); 28 | expect( 29 | pageLifecycleEventsSpy.registerLibraryLoadedTrigger 30 | ).toHaveBeenCalledWith(trigger); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaEnded.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media ended event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaEnded'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'ended'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaLoadedData.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media loaded data event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaLoadedData'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'loadeddata'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaPause.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media pause event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaPause'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'pause'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaPlay.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media play event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaPlay'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'play'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaStalled.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media stalled event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaStalled'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'stalled'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mediaVolumeChange.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('media volume change event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mediaVolumeChange'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'volumechange'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/mousedown.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('mousedown event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../mousedown'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'mousedown'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/pageBottom.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('page bottom event delegate', function () { 16 | it('sends the trigger to the pageLifecycleEvents helper module', function () { 17 | var pageBottomInjector = require('inject-loader!../pageBottom'); 18 | var trigger = function () {}; 19 | var pageLifecycleEventsSpy = jasmine.createSpyObj('pageLifecycleEvents', [ 20 | 'registerPageBottomTrigger' 21 | ]); 22 | 23 | var delegate = pageBottomInjector({ 24 | './helpers/pageLifecycleEvents': pageLifecycleEventsSpy 25 | }); 26 | 27 | delegate({}, trigger); 28 | expect( 29 | pageLifecycleEventsSpy.registerPageBottomTrigger 30 | ).toHaveBeenCalledWith(trigger); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/submit.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('submit event delegate', function () { 16 | var testStandardEvent = require('./helpers/testStandardEvent'); 17 | var delegate = require('../submit'); 18 | 19 | testStandardEvent(function () { 20 | return delegate; 21 | }, 'submit'); 22 | }); 23 | -------------------------------------------------------------------------------- /src/lib/events/__tests__/windowLoaded.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | describe('window loaded event delegate', function () { 16 | it('sends the trigger to the pageLifecycleEvents helper module', function () { 17 | var windowLoadedInjector = require('inject-loader!../windowLoaded'); 18 | var trigger = function () {}; 19 | var pageLifecycleEventsSpy = jasmine.createSpyObj('pageLifecycleEvents', [ 20 | 'registerWindowLoadedTrigger' 21 | ]); 22 | 23 | var delegate = windowLoadedInjector({ 24 | './helpers/pageLifecycleEvents': pageLifecycleEventsSpy 25 | }); 26 | 27 | delegate({}, trigger); 28 | expect( 29 | pageLifecycleEventsSpy.registerWindowLoadedTrigger 30 | ).toHaveBeenCalledWith(trigger); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/lib/events/customCode.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Custom code event. This executes event code provided by the user. The user's code will call 17 | * trigger when the rule should fire. 18 | * @param {Object} settings The event settings object. 19 | * @param {Function} settings.source The custom script function. 20 | */ 21 | module.exports = function (settings, trigger) { 22 | settings.source(trigger); 23 | }; 24 | -------------------------------------------------------------------------------- /src/lib/events/domReady.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var pageLifecycleEvents = require('./helpers/pageLifecycleEvents'); 16 | 17 | /** 18 | * DOM ready event. This event occurs as soon as HTML document has been completely loaded and 19 | * parsed, without waiting for stylesheets, images, and subframes to finish loading. 20 | * @param {Object} settings The event settings object. 21 | * @param {ruleTrigger} trigger The trigger callback. 22 | */ 23 | module.exports = function (settings, trigger) { 24 | pageLifecycleEvents.registerDomReadyTrigger(trigger); 25 | }; 26 | -------------------------------------------------------------------------------- /src/lib/events/helpers/__tests__/enableWeakMapDefaultValue.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var enableWeakMapDefaultValue = require('../enableWeakMapDefaultValue'); 16 | var WeakMap = require('../weakMap'); 17 | 18 | describe('enableWeakMapDefaultValue', function () { 19 | it('stores and returns the provided default value', function () { 20 | var map = new WeakMap(); 21 | enableWeakMapDefaultValue(map, function () { 22 | return []; 23 | }); 24 | 25 | var key = {}; 26 | 27 | var value1 = map.get(key); 28 | 29 | expect(value1).toEqual([]); 30 | 31 | value1.push('foo'); 32 | 33 | var value2 = map.get(key); 34 | 35 | expect(value2).toBe(value1); 36 | expect(value2).toEqual(['foo']); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /src/lib/events/helpers/__tests__/once.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 13 | 14 | describe('once', function () { 15 | var once; 16 | 17 | beforeAll(function () { 18 | once = require('../once'); 19 | }); 20 | 21 | it('calls the target function at most a single time', function () { 22 | var targetFn = jasmine.createSpy(); 23 | var oncified = once(targetFn); 24 | 25 | oncified(); 26 | 27 | expect(targetFn.calls.count()).toBe(1); 28 | 29 | oncified(); 30 | 31 | expect(targetFn.calls.count()).toBe(1); 32 | }); 33 | 34 | it('calls the target function with the provided context', function () { 35 | var targetFn = jasmine.createSpy(); 36 | var context = {}; 37 | var oncified = once(targetFn, context); 38 | 39 | oncified(); 40 | 41 | expect(targetFn.calls.first().object).toBe(context); 42 | }); 43 | 44 | it('calls the target function with the provided arguments', function () { 45 | var targetFn = jasmine.createSpy(); 46 | var oncified = once(targetFn); 47 | 48 | oncified('a', 'b'); 49 | 50 | expect(targetFn.calls.first().args).toEqual(['a', 'b']); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /src/lib/events/helpers/debounce.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Debounce function. Returns a proxy function that, when called multiple times, will only execute 17 | * the target function after a certain delay has passed without the proxy function being called 18 | * again. 19 | * @param {Function} fn The target function to call once the delay period has passed. 20 | * @param {number} delay The number of milliseconds that must pass before the target function is 21 | * called. 22 | * @param {Object} [context] The context in which to call the target function. 23 | * @returns {Function} 24 | */ 25 | module.exports = function (fn, delay, context) { 26 | var timeoutId = null; 27 | return function () { 28 | var ctx = context || this; 29 | var args = arguments; 30 | clearTimeout(timeoutId); 31 | timeoutId = setTimeout(function () { 32 | fn.apply(ctx, args); 33 | }, delay); 34 | }; 35 | }; 36 | -------------------------------------------------------------------------------- /src/lib/events/helpers/enableWeakMapDefaultValue.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Modifies a weakmap so that when get() is called with a key for which no entry is found, 17 | * a default value will be stored and then returned for the key. 18 | * @param {Object} weakMap The WeakMap instance to modify. 19 | * @param {Function} defaultValueFactory A function that returns the default value that should 20 | * be used. 21 | */ 22 | module.exports = function (weakMap, defaultValueFactory) { 23 | var originalGet = weakMap.get; 24 | 25 | weakMap.get = function (key) { 26 | if (!weakMap.has(key)) { 27 | weakMap.set(key, defaultValueFactory()); 28 | } 29 | 30 | return originalGet.apply(this, arguments); 31 | }; 32 | 33 | return weakMap; 34 | }; 35 | -------------------------------------------------------------------------------- /src/lib/events/helpers/matchesSelector.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Returns whether an element matches a selector. 17 | * @param {HTMLElement} element The HTML element being tested. 18 | * @param {string} selector The CSS selector. 19 | * @returns {boolean} 20 | */ 21 | module.exports = function (element, selector) { 22 | var matches = element.matches || element.msMatchesSelector; 23 | 24 | if (matches) { 25 | try { 26 | return matches.call(element, selector); 27 | } catch (error) { 28 | turbine.logger.warn( 29 | 'Matching element failed. ' + selector + ' is not a valid selector.' 30 | ); 31 | return false; 32 | } 33 | } 34 | 35 | return false; 36 | }; 37 | -------------------------------------------------------------------------------- /src/lib/events/helpers/once.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 13 | 14 | /** 15 | * Returns a proxy function that, when call the first time, will call a target function. 16 | * Subsequent calls will not call the target function. 17 | * @param {Function} fn That target function to call a single time. 18 | * @param {Object} [context] The context in which to call the target function. 19 | * @returns {Function} 20 | */ 21 | module.exports = function (fn, context) { 22 | var result; 23 | 24 | return function () { 25 | if (fn) { 26 | result = fn.apply(context || this, arguments); 27 | fn = null; 28 | } 29 | 30 | return result; 31 | }; 32 | }; 33 | -------------------------------------------------------------------------------- /src/lib/events/helpers/visibilityApi.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | module.exports = function () { 16 | var properties = { 17 | hidden: 'visibilitychange', 18 | mozHidden: 'mozvisibilitychange', 19 | msHidden: 'msvisibilitychange', 20 | webkitHidden: 'webkitvisibilitychange' 21 | }; 22 | 23 | for (var key in properties) { 24 | if ( 25 | properties.hasOwnProperty(key) && 26 | typeof document[key] !== 'undefined' 27 | ) { 28 | return { 29 | hiddenProperty: key, 30 | visibilityChangeEventType: properties[key] 31 | }; 32 | } 33 | } 34 | 35 | return {}; 36 | }; 37 | -------------------------------------------------------------------------------- /src/lib/events/libraryLoaded.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var pageLifecycleEvents = require('./helpers/pageLifecycleEvents'); 16 | 17 | /** 18 | * Library loaded event. This event occurs as soon as the runtime library is loaded. 19 | * @param {Object} settings The event settings object. 20 | * @param {ruleTrigger} trigger The trigger callback. 21 | */ 22 | module.exports = function (settings, trigger) { 23 | pageLifecycleEvents.registerLibraryLoadedTrigger(trigger); 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/events/orientationChange.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var window = require('@adobe/reactor-window'); 16 | var triggers = []; 17 | 18 | window.addEventListener('orientationchange', function (event) { 19 | if (triggers.length) { 20 | var syntheticEvent = { 21 | element: window, 22 | target: window, 23 | nativeEvent: event 24 | }; 25 | 26 | triggers.forEach(function (trigger) { 27 | trigger(syntheticEvent); 28 | }); 29 | } 30 | }); 31 | 32 | /** 33 | * The orientationchange event. This event occurs when the orientation of the device has changed. 34 | * @param {Object} settings The event settings object. 35 | * @param {ruleTrigger} trigger The trigger callback. 36 | */ 37 | module.exports = function (settings, trigger) { 38 | triggers.push(trigger); 39 | }; 40 | -------------------------------------------------------------------------------- /src/lib/events/pageBottom.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var pageLifecycleEvents = require('./helpers/pageLifecycleEvents'); 16 | 17 | /** 18 | * Page bottom event. This event occurs as soon as the user calls _satellite.pageBottom() (which is 19 | * supposed to be at the bottom of the page). 20 | * @param {Object} settings The event settings object. 21 | * @param {ruleTrigger} trigger The trigger callback. 22 | */ 23 | module.exports = function (settings, trigger) { 24 | pageLifecycleEvents.registerPageBottomTrigger(trigger); 25 | }; 26 | -------------------------------------------------------------------------------- /src/lib/events/tabBlur.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | var visibilityApi = require('./helpers/visibilityApi')(); 17 | var hiddenProperty = visibilityApi.hiddenProperty; 18 | var visibilityChangeEventType = visibilityApi.visibilityChangeEventType; 19 | var once = require('./helpers/once'); 20 | 21 | /** 22 | * All trigger methods registered for this event type. 23 | * @type {ruleTrigger[]} 24 | */ 25 | var triggers = []; 26 | 27 | var watchForTabBlur = once(function () { 28 | document.addEventListener( 29 | visibilityChangeEventType, 30 | function () { 31 | if (document[hiddenProperty]) { 32 | triggers.forEach(function (trigger) { 33 | trigger(); 34 | }); 35 | } 36 | }, 37 | true 38 | ); 39 | }); 40 | 41 | /** 42 | * Tabblur event. This event occurs when a webpage is not visible or not in focus. 43 | * @param {Object} settings The event settings object. 44 | * @param {ruleTrigger} trigger The trigger callback. 45 | */ 46 | module.exports = function (settings, trigger) { 47 | watchForTabBlur(); 48 | triggers.push(trigger); 49 | }; 50 | -------------------------------------------------------------------------------- /src/lib/events/windowLoaded.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var pageLifecycleEvents = require('./helpers/pageLifecycleEvents'); 16 | 17 | /** 18 | * Window loaded event. This event occurs at the end of the document loading process. At this point, 19 | * all of the objects in the document are loaded in the DOM, and all images, scripts, links, 20 | * and sub-frames have finished loading. 21 | * @param {Object} settings The event settings object. 22 | * @param {ruleTrigger} trigger The trigger callback. 23 | */ 24 | module.exports = function (settings, trigger) { 25 | pageLifecycleEvents.registerWindowLoadedTrigger(trigger); 26 | }; 27 | -------------------------------------------------------------------------------- /src/lib/helpers/__tests__/getObjectProperty.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | var getObjectProperty = require('../getObjectProperty'); 16 | 17 | describe('getObjectProperty', function () { 18 | it('returns an object property value', function () { 19 | var obj = { 20 | my: { 21 | path: 'bar' 22 | } 23 | }; 24 | 25 | expect(getObjectProperty(obj, 'my.path')).toBe('bar'); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/lib/helpers/__tests__/isPlainObject.test.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2021 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 | 'use strict'; 14 | 15 | var isPlainObject = require('../isPlainObject'); 16 | 17 | describe('isPlainObject', function () { 18 | it('returns true for plain objects', function () { 19 | [ 20 | Object.create({}), 21 | Object.create(Object.prototype), 22 | { foo: 'bar' }, 23 | {}, 24 | Object.create(null) 25 | ].forEach(function (value) { 26 | expect(isPlainObject(value)).toBeTrue(); 27 | }); 28 | }); 29 | 30 | it('returns false for values that are not plain objects', function () { 31 | function Foo() { 32 | this.abc = {}; 33 | } 34 | 35 | [ 36 | /foo/, 37 | function () {}, 38 | 1, 39 | ['foo', 'bar'], 40 | [], 41 | new Foo(), 42 | null, 43 | new Date() 44 | ].forEach(function (value) { 45 | expect(isPlainObject(value)).toBeFalse(); 46 | }); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /src/lib/helpers/findPageScript.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2021 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 | 'use strict'; 14 | 15 | var document = require('@adobe/reactor-document'); 16 | 17 | var byRegexPattern = function (regexScriptSrcPattern) { 18 | var scripts = document.querySelectorAll('script'); 19 | 20 | for (var i = 0; i < scripts.length; i++) { 21 | var script = scripts[i]; 22 | // Find the script that loaded our library. Take into account embed scripts migrated 23 | // from DTM. We'll also consider that they may have added a querystring for cache-busting 24 | // or whatever. 25 | if (regexScriptSrcPattern.test(script.src)) { 26 | return script; 27 | } 28 | } 29 | }; 30 | 31 | var getTurbine = function () { 32 | return byRegexPattern(new RegExp(/(launch|satelliteLib)-[^\/]+.js(\?.*)?$/)); 33 | }; 34 | 35 | module.exports = { 36 | getTurbine: getTurbine, 37 | byRegexPattern: byRegexPattern 38 | }; 39 | -------------------------------------------------------------------------------- /src/lib/helpers/getObjectProperty.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Returns the deep property value of an object. 17 | * @param obj The object where the property will be searched. 18 | * @param property The property name to be returned. It can contain dots. (eg. prop.subprop1) 19 | * @returns {*} 20 | */ 21 | module.exports = function (obj, property) { 22 | var propertyChain = property.split('.'); 23 | var currentValue = obj; 24 | 25 | for (var i = 0, len = propertyChain.length; i < len; i++) { 26 | if (currentValue == null) { 27 | return undefined; 28 | } 29 | 30 | currentValue = currentValue[propertyChain[i]]; 31 | } 32 | 33 | return currentValue; 34 | }; 35 | -------------------------------------------------------------------------------- /src/lib/helpers/intersectionObserverIntervals.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2023 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 | 'use strict'; 14 | 15 | // this was JSON, but there are a lot of changes necessary in the reactor API 16 | // and Library Build Tooling to support JSON natively. 17 | module.exports = { 18 | standard: { 19 | pageElementsRefresh: 3000 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /src/lib/helpers/isPlainObject.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2021 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 | 'use strict'; 14 | 15 | var isPlainObject = 16 | require('../../../node_modules/is-plain-object/dist/is-plain-object').isPlainObject; 17 | 18 | module.exports = isPlainObject; 19 | -------------------------------------------------------------------------------- /src/lib/helpers/stringAndNumberUtils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var isNumber = function (value) { 4 | return typeof value === 'number' && isFinite(value); // isFinite weeds out NaNs. 5 | }; 6 | 7 | var isString = function (value) { 8 | return typeof value === 'string' || value instanceof String; 9 | }; 10 | 11 | var castToStringIfNumber = function (value) { 12 | return isNumber(value) ? String(value) : value; 13 | }; 14 | 15 | var castToNumberIfString = function (value) { 16 | return isString(value) ? Number(value) : value; 17 | }; 18 | 19 | module.exports = { 20 | isNumber: isNumber, 21 | isString: isString, 22 | castToStringIfNumber: castToStringIfNumber, 23 | castToNumberIfString: castToNumberIfString 24 | }; 25 | -------------------------------------------------------------------------------- /src/lib/helpers/textMatch.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | 'use strict'; 14 | 15 | /** 16 | * Performs a string match based on another string or a regex. 17 | * @param {string} str The string to be evaluate. 18 | * @param {string|RegExp} pattern The pattern to match against. 19 | * @returns {boolean} Whether the string matches the pattern. 20 | */ 21 | module.exports = function (str, pattern) { 22 | if (pattern == null) { 23 | throw new Error('Illegal Argument: Pattern is not present'); 24 | } 25 | if (str == null) { 26 | return false; 27 | } 28 | if (typeof pattern === 'string') { 29 | return str === pattern; 30 | } else if (pattern instanceof RegExp) { 31 | return pattern.test(str); 32 | } else { 33 | return false; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /src/view/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@babel/eslint-parser", 3 | "parserOptions": { 4 | "ecmaVersion": 6, 5 | "sourceType": "module", 6 | "ecmaFeatures": { 7 | "jsx": true, 8 | "experimentalObjectRestSpread": true 9 | }, 10 | "requireConfigFile": false, 11 | "babelOptions": { 12 | "presets": ["@babel/preset-react"] 13 | } 14 | }, 15 | "extends": ["airbnb", "plugin:prettier/recommended"], 16 | "rules": { 17 | "jsx-a11y/label-has-associated-control": [ 18 | 2, 19 | { 20 | "controlComponents": ["WrappedField"], 21 | "depth": 1 22 | } 23 | ], 24 | "max-len": [ 25 | 2, 26 | 100, 27 | 4, 28 | { 29 | "ignoreUrls": true, 30 | "ignorePattern": "^(\\s*(var|let|const)\\s.+=\\s*require\\s*\\()|(^\\s*import)" 31 | } 32 | ], 33 | "comma-dangle": ["error", "never"], 34 | "react/prop-types": 0, 35 | "react/jsx-no-bind": 0, 36 | "no-param-reassign": 0, 37 | "no-prototype-builtins": 0, 38 | "jsx-a11y/label-has-for": 0, 39 | "spaced-comment": 0, // To support our copyright banner. 40 | "implicit-arrow-linebreak": 0, 41 | "prefer-const": [ 42 | "error", 43 | { 44 | "destructuring": "all" 45 | } 46 | ], 47 | "operator-linebreak": 0, 48 | "object-curly-newline": 0, 49 | "react/jsx-props-no-spreading": 0, 50 | "jsx-a11y/anchor-is-valid": 0 51 | }, 52 | "env": { 53 | "es6": true, 54 | "jasmine": true 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/view/__tests__/helpers/createExtensionBridge.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | export default () => { 14 | let registeredOptions; 15 | 16 | return { 17 | register(options) { 18 | registeredOptions = options; 19 | }, 20 | init(...args) { 21 | return registeredOptions.init.apply(this, args); 22 | }, 23 | validate(...args) { 24 | return registeredOptions.validate.apply(this, args); 25 | }, 26 | getSettings(...args) { 27 | return registeredOptions.getSettings.apply(this, args); 28 | }, 29 | openCodeEditor() {}, 30 | openRegexTester() {}, 31 | openDataElementSelector() {} 32 | }; 33 | }; 34 | -------------------------------------------------------------------------------- /src/view/actions/directCall.styl: -------------------------------------------------------------------------------- 1 | .directCall { 2 | .codeLine, .codeText { 3 | font-size: var(--spectrum-global-dimension-size-200); 4 | font-family: Monaco, "Lucida Console", monospace 5 | margin-top: 20px; 6 | } 7 | 8 | .codeLine { 9 | display: block; 10 | 11 | &.mt10 { 12 | margin-top: 10px; 13 | } 14 | 15 | &.mb10 { 16 | margin-bottom: 10px; 17 | } 18 | } 19 | 20 | .directCallMultipleItemEditor-body { 21 | margin-left: 20px 22 | } 23 | 24 | .directCallMultipleItemEditor-footer { 25 | button { 26 | margin-left: 20px 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/view/components/__tests__/disclosureButton.test.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { fireEvent, render as rtlRender, screen } from '@testing-library/react'; 15 | import DisclosureButton from '../disclosureButton'; 16 | 17 | const render = (props) => rtlRender(); 18 | 19 | describe('disclosure button', () => { 20 | it('shows down chevron when selected', () => { 21 | render({ 22 | selected: true 23 | }); 24 | 25 | expect(screen.getByTestId('chevron-down')).toBeTruthy(); 26 | expect(screen.queryByTestId('chevron-right')).toBeFalsy(); 27 | }); 28 | 29 | it('shows right chevron when not selected', () => { 30 | render({ 31 | selected: false 32 | }); 33 | 34 | expect(screen.queryByTestId('chevron-down')).toBeFalsy(); 35 | expect(screen.getByTestId('chevron-right')).toBeTruthy(); 36 | }); 37 | 38 | it('calls onClick when clicked', () => { 39 | const onClick = jasmine.createSpy(); 40 | render({ 41 | onClick 42 | }); 43 | 44 | fireEvent.click(screen.getByRole('button')); 45 | expect(onClick).toHaveBeenCalled(); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /src/view/components/disclosureButton.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { ActionButton, Text } from '@adobe/react-spectrum'; 15 | import ChevronDown from '@spectrum-icons/workflow/ChevronDown'; 16 | import ChevronRight from '@spectrum-icons/workflow/ChevronRight'; 17 | 18 | export default ({ onClick, selected, label }) => ( 19 | 20 | {selected ? ( 21 | 22 | ) : ( 23 | 24 | )} 25 | {label} 26 | 27 | ); 28 | -------------------------------------------------------------------------------- /src/view/components/editorButton.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Flex, Text } from '@adobe/react-spectrum'; 3 | import Code from '@spectrum-icons/workflow/Code'; 4 | 5 | const onClick = ({ onChange, value, language }) => { 6 | const options = { 7 | code: value 8 | }; 9 | 10 | if (language) { 11 | options.language = language; 12 | } 13 | 14 | window.extensionBridge.openCodeEditor(options).then(onChange); 15 | }; 16 | export default React.forwardRef( 17 | ({ onChange, value, language, validationState }, ref) => ( 18 | 19 | 27 | 28 | ) 29 | ); 30 | -------------------------------------------------------------------------------- /src/view/components/fullWidthField.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | import { View, Flex, TextField } from '@adobe/react-spectrum'; 14 | import WrappedField from './wrappedField'; 15 | import RegexToggle from './regexToggle'; 16 | import NoWrapText from './noWrapText'; 17 | 18 | export const DEFAULT_BLANK_SPACE_PROPS = { 19 | width: 'size-1600' 20 | }; 21 | 22 | export default React.forwardRef( 23 | ( 24 | { 25 | component = TextField, 26 | blankSpace = DEFAULT_BLANK_SPACE_PROPS, 27 | beginText, 28 | regexName, 29 | regexValueFieldName, 30 | containerMinWidth, 31 | children, 32 | ...rest 33 | }, 34 | ref 35 | ) => ( 36 | 37 | {beginText && {beginText}} 38 | 39 | 40 | {children} 41 | 42 | 43 | {regexName && regexValueFieldName && ( 44 | 50 | )} 51 | {blankSpace && } 52 | 53 | ) 54 | ); 55 | -------------------------------------------------------------------------------- /src/view/components/helpText.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Flex, Text, View } from '@adobe/react-spectrum'; 3 | import Alert from '@spectrum-icons/workflow/Alert'; 4 | import './helpText.styl'; 5 | 6 | const colorToClassName = (color) => { 7 | const className = `spectrum-semantic-${color}-color-text-small`; 8 | switch (color) { 9 | case 'negative': 10 | return className; 11 | default: 12 | return undefined; 13 | } 14 | }; 15 | 16 | export default ({ color = 'notice', children, ...containerProps }) => ( 17 | 18 | 22 | 23 | 29 | 33 | {children} 34 | 35 | 36 | 37 | 38 | ); 39 | -------------------------------------------------------------------------------- /src/view/components/helpText.styl: -------------------------------------------------------------------------------- 1 | .spectrum-semantic-negative-color-text-small { 2 | color: var(--spectrum-semantic-negative-color-text-small); 3 | } 4 | 5 | .warning-container-content { 6 | svg { 7 | flex-shrink: 0; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/view/components/infoTip.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ActionButton, Tooltip, TooltipTrigger } from '@adobe/react-spectrum'; 3 | import Info from '@spectrum-icons/workflow/Info'; 4 | 5 | export default ({ placement, children }) => ( 6 | <> 7 | 8 | 9 | 10 | 11 | {children} 12 | 13 | 14 | ); 15 | -------------------------------------------------------------------------------- /src/view/components/noWrapText.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | import { Text } from '@adobe/react-spectrum'; 14 | 15 | export default ({ children, ...rest }) => ( 16 | 21 | {children} 22 | 23 | ); 24 | -------------------------------------------------------------------------------- /src/view/components/regexTestButton.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { ActionButton } from '@adobe/react-spectrum'; 15 | 16 | export default React.forwardRef((props, ref) => { 17 | const { value, onChange, flags = 'i' } = props; 18 | 19 | const options = { 20 | pattern: value, 21 | flags 22 | }; 23 | 24 | return ( 25 | 29 | window.extensionBridge.openRegexTester(options).then(onChange) 30 | } 31 | > 32 | Test 33 | 34 | ); 35 | }); 36 | -------------------------------------------------------------------------------- /src/view/components/regexToggle.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { Switch, Flex } from '@adobe/react-spectrum'; 15 | import WrappedField from './wrappedField'; 16 | import RegexTestButton from './regexTestButton'; 17 | 18 | export default React.forwardRef((props, ref) => { 19 | const { value: valueIsRegex, onChange, valueFieldName } = props; 20 | 21 | return ( 22 | 23 | 28 | Regex 29 | 30 | 34 | 39 | 40 | 41 | ); 42 | }); 43 | -------------------------------------------------------------------------------- /src/view/components/selectorLearnMoreLink.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2020 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 React from 'react'; 14 | import { Link, View } from '@adobe/react-spectrum'; 15 | 16 | // when an input field ends with a "learn more" link, 17 | // we insert padding for the form validation tooltip to display correctly 18 | export default () => ( 19 | 20 | {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} 21 | 22 | 27 | Learn more 28 | 29 | 30 | 31 | ); 32 | -------------------------------------------------------------------------------- /src/view/components/spectrumLabel.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default ({ children }) => ( 4 | {children} 5 | ); 6 | -------------------------------------------------------------------------------- /src/view/components/warningContainer.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | import { Flex, Well } from '@adobe/react-spectrum'; 14 | import HelpText from './helpText'; 15 | 16 | export default ({ color = 'notice', children, ...containerPositioning }) => ( 17 | 18 | 19 | {children} 20 | 21 | 22 | ); 23 | -------------------------------------------------------------------------------- /src/view/conditions/comparisonOperatorOptions.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 | export default [ 14 | { 15 | name: 'greater than', 16 | id: '>' 17 | }, 18 | { 19 | name: 'equal to', 20 | id: '=' 21 | }, 22 | { 23 | name: 'less than', 24 | id: '<' 25 | } 26 | ]; 27 | -------------------------------------------------------------------------------- /src/view/conditions/dateRange.styl: -------------------------------------------------------------------------------- 1 | // Setting width on Datepicker doesn't work so we have to hack it. :( 2 | .DateRange-datePicker.coral-Datepicker .coral-InputGroup { 3 | width: 6rem; 4 | } 5 | -------------------------------------------------------------------------------- /src/view/conditions/newReturningVisitor.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { Radio, RadioGroup } from '@adobe/react-spectrum'; 15 | import WrappedField from '../components/wrappedField'; 16 | 17 | const NewReturningVisitor = () => ( 18 | 23 | new visitor 24 | returning visitor 25 | 26 | ); 27 | 28 | export default NewReturningVisitor; 29 | 30 | export const formConfig = { 31 | settingsToFormValues(values, settings, state) { 32 | return { 33 | ...values, 34 | visitorType: 35 | state.meta.isNew || settings.isNewVisitor ? 'new' : 'returning' 36 | }; 37 | }, 38 | formValuesToSettings(settings, values) { 39 | return { 40 | ...settings, 41 | isNewVisitor: values.visitorType === 'new' 42 | }; 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /src/view/conditions/protocol.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { RadioGroup, Radio } from '@adobe/react-spectrum'; 15 | import WrappedField from '../components/wrappedField'; 16 | 17 | const Protocol = () => ( 18 | 19 | HTTP 20 | HTTPS 21 | 22 | ); 23 | 24 | export default Protocol; 25 | 26 | export const formConfig = { 27 | settingsToFormValues(values, settings) { 28 | return { 29 | ...values, 30 | protocol: settings.protocol || 'http:' 31 | }; 32 | }, 33 | formValuesToSettings(settings, values) { 34 | return { 35 | ...settings, 36 | ...values 37 | }; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/view/dataElements/components/javascriptTools/regexReplace.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | 14 | import ReplacementValue, { 15 | formConfig as replacementValueFormConfig 16 | } from './replacementValue'; 17 | import RegexMatch, { formConfig as regexMatchFormConfig } from './regexMatch'; 18 | import mergeFormConfigs from '../../../utils/mergeFormConfigs'; 19 | 20 | export default ({ caseInsensitive }) => { 21 | return ( 22 | <> 23 | 24 | 25 | 26 | ); 27 | }; 28 | 29 | export const formConfig = mergeFormConfigs( 30 | regexMatchFormConfig, 31 | replacementValueFormConfig 32 | ); 33 | -------------------------------------------------------------------------------- /src/view/dataElements/components/javascriptTools/simpleReplace.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | 14 | import ReplacementValue, { 15 | formConfig as replacementValueFormConfig 16 | } from './replacementValue'; 17 | import SearchValue, { 18 | formConfig as searchValueFormConfig 19 | } from './searchValue'; 20 | import mergeFormConfigs from '../../../utils/mergeFormConfigs'; 21 | 22 | export default () => ( 23 | <> 24 | 25 | 26 | 27 | ); 28 | 29 | export const formConfig = mergeFormConfigs( 30 | searchValueFormConfig, 31 | replacementValueFormConfig 32 | ); 33 | -------------------------------------------------------------------------------- /src/view/dataElements/components/javascriptTools/valueSeparator.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | import { TextField } from '@adobe/react-spectrum'; 14 | import WrappedField from '../../../components/wrappedField'; 15 | import operators from '../../utils/javascriptTools/operators'; 16 | 17 | export default () => ( 18 | 25 | ); 26 | 27 | export const formConfig = { 28 | settingsToFormValues(values, { delimiter }) { 29 | values.delimiter = delimiter || ''; 30 | 31 | return values; 32 | }, 33 | formValuesToSettings(settings, { delimiter }) { 34 | if ([operators.SPLIT, operators.JOIN].includes(settings.operator)) { 35 | settings.delimiter = delimiter; 36 | } 37 | 38 | return settings; 39 | }, 40 | validate(errors, { delimiter, operator }) { 41 | if ([operators.SPLIT, operators.JOIN].includes(operator)) { 42 | if (!delimiter) { 43 | errors.delimiter = 'Please specify a delimiter'; 44 | } 45 | } 46 | 47 | return errors; 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /src/view/dataElements/constant.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import FullWidthField from '../components/fullWidthField'; 15 | 16 | const ConstantValue = () => ( 17 | 23 | ); 24 | 25 | export default ConstantValue; 26 | 27 | export const formConfig = { 28 | settingsToFormValues(values, settings) { 29 | return { 30 | ...values, 31 | ...settings 32 | }; 33 | }, 34 | formValuesToSettings(settings, values) { 35 | return { 36 | ...settings, 37 | ...values 38 | }; 39 | }, 40 | validate(errors, values) { 41 | errors = { 42 | ...errors 43 | }; 44 | 45 | if (!values.value) { 46 | errors.value = 'Please specify a value.'; 47 | } 48 | 49 | return errors; 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /src/view/dataElements/customCode.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import WrappedField from '../components/wrappedField'; 15 | import EditorButton from '../components/editorButton'; 16 | 17 | const CustomCode = () => ( 18 | 19 | ); 20 | 21 | export default CustomCode; 22 | 23 | export const formConfig = { 24 | settingsToFormValues(values, settings) { 25 | return { 26 | ...values, 27 | ...settings 28 | }; 29 | }, 30 | formValuesToSettings(settings, values) { 31 | return { 32 | ...settings, 33 | ...values 34 | }; 35 | }, 36 | validate(errors, values) { 37 | errors = { 38 | ...errors 39 | }; 40 | 41 | if (!values.source) { 42 | errors.source = 'Please provide custom script.'; 43 | } 44 | 45 | return errors; 46 | } 47 | }; 48 | -------------------------------------------------------------------------------- /src/view/dataElements/deviceAttributes.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | import React from 'react'; 13 | import { Picker, Item } from '@adobe/react-spectrum'; 14 | import FullWidthField from '../components/fullWidthField'; 15 | 16 | const options = [ 17 | { 18 | id: 'windowSize', 19 | name: 'Browser Window Size' 20 | }, 21 | 22 | { 23 | id: 'screenSize', 24 | name: 'Screen Size' 25 | } 26 | ]; 27 | 28 | const DeviceAttributes = () => ( 29 | 38 | {(item) => {item.name}} 39 | 40 | ); 41 | 42 | export default DeviceAttributes; 43 | 44 | export const formConfig = { 45 | settingsToFormValues(values, settings) { 46 | return { 47 | ...values, 48 | attribute: settings.attribute || 'windowSize' 49 | }; 50 | }, 51 | formValuesToSettings(settings, values) { 52 | return { 53 | ...settings, 54 | ...values 55 | }; 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /src/view/dataElements/javascriptVariable.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import FullWidthField from '../components/fullWidthField'; 15 | 16 | const JavaScriptVariable = () => ( 17 | 23 | ); 24 | 25 | export default JavaScriptVariable; 26 | 27 | export const formConfig = { 28 | settingsToFormValues(values, settings) { 29 | return { 30 | ...values, 31 | ...settings 32 | }; 33 | }, 34 | formValuesToSettings(settings, values) { 35 | return { 36 | ...settings, 37 | ...values 38 | }; 39 | }, 40 | validate(errors, values) { 41 | errors = { 42 | ...errors 43 | }; 44 | 45 | if (!values.path) { 46 | errors.path = 'Please specify a variable path.'; 47 | } 48 | 49 | return errors; 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /src/view/dataElements/localStorage.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import FullWidthField from '../components/fullWidthField'; 15 | 16 | const LocalStorage = () => ( 17 | 23 | ); 24 | 25 | export default LocalStorage; 26 | 27 | export const formConfig = { 28 | settingsToFormValues(values, settings) { 29 | return { 30 | ...values, 31 | ...settings 32 | }; 33 | }, 34 | formValuesToSettings(settings, values) { 35 | return { 36 | ...settings, 37 | ...values 38 | }; 39 | }, 40 | validate(errors, values) { 41 | errors = { 42 | ...errors 43 | }; 44 | 45 | if (!values.name) { 46 | errors.name = 'Please specify a local storage item name.'; 47 | } 48 | 49 | return errors; 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /src/view/dataElements/sessionStorage.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import FullWidthField from '../components/fullWidthField'; 15 | 16 | const SessionStorage = () => ( 17 | 23 | ); 24 | 25 | export default SessionStorage; 26 | 27 | export const formConfig = { 28 | settingsToFormValues(values, settings) { 29 | return { 30 | ...values, 31 | ...settings 32 | }; 33 | }, 34 | formValuesToSettings(settings, values) { 35 | return { 36 | ...settings, 37 | ...values 38 | }; 39 | }, 40 | validate(errors, values) { 41 | errors = { 42 | ...errors 43 | }; 44 | 45 | if (!values.name) { 46 | errors.name = 'Please specify a session storage item name.'; 47 | } 48 | 49 | return errors; 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /src/view/dataElements/utils/javascriptTools/operators.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 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 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | export default { 13 | SUBSTRING: 'substring', 14 | REGEX_REPLACE: 'regexReplace', 15 | SIMPLE_REPLACE: 'simpleReplace', 16 | REGEX_MATCH: 'regexMatch', 17 | LENGTH: 'length', 18 | INDEX_OF: 'indexOf', 19 | LAST_INDEX_OF: 'lastIndexOf', 20 | JOIN: 'join', 21 | SPLIT: 'split', 22 | ARRAY_POP: 'arrayPop', 23 | ARRAY_SHIFT: 'arrayShift', 24 | SLICE: 'slice' 25 | }; 26 | -------------------------------------------------------------------------------- /src/view/events/blur.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/change.styl: -------------------------------------------------------------------------------- 1 | .value-changed-to-options { 2 | margin-bottom: 20px; 3 | } 4 | -------------------------------------------------------------------------------- /src/view/events/components/standardEvent.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import ElementFilter, { 15 | formConfig as elementFilterFormConfig 16 | } from './elementFilter'; 17 | import AdvancedEventOptions, { 18 | formConfig as advancedEventOptionsFormConfig 19 | } from './advancedEventOptions'; 20 | import mergeFormConfigs from '../../utils/mergeFormConfigs'; 21 | 22 | const StandardEvent = ({ elementSpecificityLabel }) => ( 23 | <> 24 | 25 | 26 | 27 | ); 28 | 29 | export default StandardEvent; 30 | 31 | export const formConfig = mergeFormConfigs( 32 | elementFilterFormConfig, 33 | advancedEventOptionsFormConfig 34 | ); 35 | -------------------------------------------------------------------------------- /src/view/events/elementExists.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 SpecificElements, { 14 | formConfig as specificElementsFormConfig 15 | } from './components/specificElements'; 16 | 17 | export default SpecificElements; 18 | export const formConfig = specificElementsFormConfig; 19 | -------------------------------------------------------------------------------- /src/view/events/focus.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/hover.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import { Flex } from '@adobe/react-spectrum'; 15 | import DelayType, { 16 | formConfig as delayTypeFormConfig 17 | } from './components/delayType'; 18 | import AdvancedEventOptions, { 19 | formConfig as advancedEventOptionsFormConfig 20 | } from './components/advancedEventOptions'; 21 | import SpecificElements, { 22 | formConfig as specificElementsFormConfig 23 | } from './components/specificElements'; 24 | import mergeFormConfigs from '../utils/mergeFormConfigs'; 25 | 26 | const Hover = () => ( 27 | 28 | 29 | 30 | 31 | 32 | ); 33 | 34 | export default Hover; 35 | 36 | export const formConfig = mergeFormConfigs( 37 | delayTypeFormConfig, 38 | specificElementsFormConfig, 39 | advancedEventOptionsFormConfig 40 | ); 41 | -------------------------------------------------------------------------------- /src/view/events/keyDown.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2022 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/keyPress.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/keyUp.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2022 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mediaEnded.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mediaLoadedData.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | const label = 'When the first frame of the media has finished loading on'; 19 | 20 | export default () => ; 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mediaPause.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mediaPlay.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | const label = 'When the playback state is no longer paused on'; 19 | 20 | export default () => ; 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mediaStalled.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | const label = 19 | 'When the user agent is trying to fetch media data, but data is unexpectedly not forthcoming on'; 20 | 21 | export default () => ; 22 | export const formConfig = standardEventFormConfig; 23 | -------------------------------------------------------------------------------- /src/view/events/mediaVolumeChange.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/mousedown.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/events/submit.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 React from 'react'; 14 | import StandardEvent, { 15 | formConfig as standardEventFormConfig 16 | } from './components/standardEvent'; 17 | 18 | export default () => ( 19 | 20 | ); 21 | export const formConfig = standardEventFormConfig; 22 | -------------------------------------------------------------------------------- /src/view/reduxActions/bridgeAdapterActions.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 { createAction, handleActions } from 'redux-actions'; 14 | 15 | const POPULATE_META = 'bridgeAdapter/POPULATE_META'; 16 | const MARK_INIT_COMPLETE = 'bridgeAdapter/MARK_INIT_COMPLETE'; 17 | 18 | export const actionCreators = { 19 | populateMeta: createAction(POPULATE_META), 20 | markInitComplete: createAction(MARK_INIT_COMPLETE) 21 | }; 22 | 23 | export default handleActions( 24 | { 25 | [POPULATE_META]: (state, action) => ({ 26 | ...state, 27 | meta: { 28 | ...action.payload 29 | } 30 | }), 31 | [MARK_INIT_COMPLETE]: (state) => ({ 32 | ...state, 33 | initializedByBridge: true 34 | }) 35 | }, 36 | { 37 | initializedByBridge: false, 38 | meta: {} 39 | } 40 | ); 41 | -------------------------------------------------------------------------------- /src/view/reduxActions/reducer.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 reduceReducers from 'reduce-reducers'; 14 | import { reducer as formReducer } from 'redux-form'; 15 | import bridgeAdapterActions from './bridgeAdapterActions'; 16 | 17 | export default reduceReducers( 18 | bridgeAdapterActions, 19 | 20 | // Setup for redux-form. 21 | (state, action) => ({ 22 | ...state, 23 | form: formReducer(state.form, action) 24 | }) 25 | ); 26 | -------------------------------------------------------------------------------- /src/view/renderView.jsx: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 ReactDOM from 'react-dom'; 14 | 15 | import bootstrap from './bootstrap'; 16 | 17 | import './global.styl'; 18 | 19 | export default (View, formConfig) => { 20 | ReactDOM.render( 21 | bootstrap(View, formConfig), 22 | document.getElementById('content') 23 | ); 24 | }; 25 | -------------------------------------------------------------------------------- /src/view/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= htmlWebpackPlugin.options.title %> 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/view/utils/validators.js: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Copyright 2019 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 no-restricted-globals: 0*/ 14 | /*eslint object-curly-newline: 0*/ 15 | /*eslint implicit-arrow-linebreak: 0*/ 16 | export const isNumberLike = (value) => 17 | !isNaN(value) && (typeof value !== 'string' || value.trim().length > 0); 18 | 19 | export const isNumberLikeInRange = (value, options) => { 20 | const { min, minInclusive = true, max, maxInclusive = true } = options; 21 | 22 | return ( 23 | isNumberLike(value) && 24 | (min === undefined || 25 | (minInclusive ? Number(value) >= min : Number(value) > min)) && 26 | (max === undefined || 27 | (maxInclusive ? Number(value) <= max : Number(value) < max)) 28 | ); 29 | }; 30 | 31 | export const isInteger = 32 | Number.isInteger || 33 | ((value) => 34 | typeof value === 'number' && 35 | isFinite(value) && 36 | Math.floor(value) === value); 37 | 38 | export const isDataElementToken = (value) => /^%([^%]+)%$/.test(value); 39 | -------------------------------------------------------------------------------- /testIndex.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // TEST_BASE_PATH is defined inside karma.conf.js. 4 | var testsContext = require.context( 5 | TEST_BASE_PATH, 6 | true, 7 | /__tests__\/.*\.test\.jsx?$/ 8 | ); 9 | testsContext.keys().forEach(testsContext); 10 | 11 | // This is necessary for the coverage report to show all source files even when they're not 12 | // included by tests. However, the source files will throw errors if they have require() statements 13 | // in them since they're expecting Turbine's injected require function which is why we must 14 | // wrap in a try-catch. When the source files are required by tests, the tests inject everything 15 | // necessary for them to work properly. 16 | var srcContext = require.context( 17 | TEST_BASE_PATH, 18 | true, 19 | /^((?!__tests__).)*\.jsx?$/ 20 | ); 21 | srcContext.keys().forEach(function (src) { 22 | try { 23 | srcContext(src); 24 | } catch (e) { 25 | // Do nothing. 26 | } 27 | }); 28 | 29 | // Some tests will try to install a jasmine clock. In order to effectively install a clock, 30 | // the tests need to install it before a setTimeout or setInterval is used in the module they 31 | // are testing. Since we just required() all modules, the modules have typically already started 32 | // their setTimeouts or setIntervals making installing an effective clock from tests difficult. By 33 | // clearing the cache here, it allows the tests to effectively install the clock before 34 | // requiring the module anew. 35 | Object.keys(require.cache).forEach(function (key) { 36 | delete require.cache[key]; 37 | }); 38 | --------------------------------------------------------------------------------