From 350e89bca01bd14fbf5d55a676c82961c9d41865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ciesielski?= Date: Mon, 27 Nov 2023 14:43:27 +0100 Subject: [PATCH] Add origin option to ICE config Also changed Node version from 12 to 16.20.2. --- .github/workflows/main.yml | 4 ++-- .tool-versions | 1 + dist/angular-phrase.js | 3 ++- dist/angular-phrase.js.map | 2 +- dist/angular-phrase.min.js | 2 +- dist/angular-phrase.min.js.map | 2 +- src/angular-phrase.ts | 1 + test/unit/directives/phrase_javascript.spec.ts | 3 +++ 8 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .tool-versions diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef30662..25c8891 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,10 +5,10 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - - name: Use Node.js 12.8 + - name: Use Node.js 16.20.2 uses: actions/setup-node@v1 with: - node-version: 12.8 + node-version: 16.20.2 - name: Install dependencies run: npm install - name: Lint diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..638e5c1 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 16.20.2 \ No newline at end of file diff --git a/dist/angular-phrase.js b/dist/angular-phrase.js index 69f9b54..adeba20 100644 --- a/dist/angular-phrase.js +++ b/dist/angular-phrase.js @@ -158,10 +158,11 @@ phrase.directive("phraseJavascript", ["phraseEnabled", "phraseProjectId", "phras replace: true, link: function () { if (phraseEnabled) { - var url = "https://phraseapp.com/assets/in-context-editor/2.0/app.js?" + new Date().getTime(); + var url = "https://phrase.com/assets/in-context-editor/2.0/app.js?" + new Date().getTime(); $window.PHRASEAPP_CONFIG = { projectId: phraseProjectId, autoLowercase: phraseAutoLowercase, + origin: "angular-phrase" }; _data_utils__WEBPACK_IMPORTED_MODULE_0__["default"].getScript(url); } diff --git a/dist/angular-phrase.js.map b/dist/angular-phrase.js.map index af37448..4f529b8 100644 --- a/dist/angular-phrase.js.map +++ b/dist/angular-phrase.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/angular-phrase.ts","webpack:///./src/data-utils.ts"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AC/EA;AAAA;AAAqC;AACrC,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC;AAO1E,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AACpC,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAC9C,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAC9C,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAC,QAAsC;QAC9D,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,EAA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,CAAC,CAAC;QAChD,IAAM,KAAK,GAAG,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;QAEpB,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;QACpB,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IACL,gBAAC;AAAD,CAAC","file":"angular-phrase.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/angular-phrase.ts\");\n","declare global {\n const angular: ng.IAngularStatic;\n}\nimport DataUtils from \"./data-utils\";\nconst phrase = angular.module(\"phrase\", ['pascalprecht.translate', 'ng']);\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\ninterface ITranslateServiceExtend extends angular.translate.ITranslateService {\n _instant: angular.translate.ITranslateService['instant']\n}\n\nphrase.value(\"phraseProjectId\", \"\");\nphrase.value(\"phraseEnabled\", true);\nphrase.value(\"phraseDecoratorPrefix\", \"{{__\");\nphrase.value(\"phraseDecoratorSuffix\", \"__}}\");\nphrase.value(\"phraseAutoLowercase\", true);\n\nphrase.config([\"$provide\", ($provide: angular.auto.IProvideService) => {\n return $provide.decorator(\"$translate\", [\"$delegate\", \"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n ($translate: ITranslateServiceExtend, phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (phraseEnabled) {\n $translate._instant = $translate.instant;\n $translate.instant = (translationId) => {\n if (typeof translationId === \"object\") {\n return translationId.reduce((prev: Record, curr: string) => {\n prev[curr] = `${phraseDecoratorPrefix}phrase_${curr as string}${phraseDecoratorSuffix}`;\n return prev;\n }, {});\n }\n\n return `${phraseDecoratorPrefix}phrase_${translationId as string}${phraseDecoratorSuffix}`\n };\n }\n return $translate;\n }]);\n}]);\n\nphrase.config([\"$compileProvider\", ($compileProvider: angular.ICompileProvider) => {\n return $compileProvider.directive('translate', [\"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n (phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (!phraseEnabled) {\n return {};\n }\n return {\n priority: 1001,\n terminal: true,\n restrict: 'AE',\n scope: true,\n compile: (elem, attr) => {\n let translationId: string;\n if (elem.attr(\"translate\") != undefined) {\n if (elem.attr(\"translate\") !== \"\") {\n translationId = elem.attr(\"translate\");\n } else {\n translationId = elem.text();\n }\n }\n\n if (translationId) {\n let decoratedTranslationId = `${phraseDecoratorPrefix}phrase_${translationId + phraseDecoratorSuffix}`;\n if (attr.translateValues) {\n decoratedTranslationId = `${decoratedTranslationId} (${(attr.translateValues as string)})`;\n }\n elem.html(decoratedTranslationId);\n elem.removeAttr(\"translate\");\n }\n }\n };\n }]);\n}]);\n\nphrase.directive(\"phraseJavascript\", [\"phraseEnabled\", \"phraseProjectId\", \"phraseAutoLowercase\", \"$window\",\n (phraseEnabled: boolean, phraseProjectId: string, phraseAutoLowercase: boolean, $window: Window) => {\n return {\n restrict: \"EA\",\n replace: true,\n link: (): void => {\n if (phraseEnabled) {\n const url = `https://phraseapp.com/assets/in-context-editor/2.0/app.js?${new Date().getTime()}`;\n $window.PHRASEAPP_CONFIG = {\n projectId: phraseProjectId,\n autoLowercase: phraseAutoLowercase,\n };\n DataUtils.getScript(url);\n }\n }\n };\n }]);\n","export default class DataUtils {\n static getScript(source: string): void {\n const script = document.createElement('script');\n const prior = document.getElementsByTagName('script')[0];\n script.async = true;\n\n script.src = source;\n prior.parentNode.insertBefore(script, prior);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/angular-phrase.ts","webpack:///./src/data-utils.ts"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AC/EA;AAAA;AAAqC;AACrC,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC;AAO1E,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AACpC,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAC9C,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAC9C,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,CAAC,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;;;;;;;ACxFR;AAAA;IAAA;IASA,CAAC;IARU,mBAAS,GAAhB,UAAiB,MAAc;QAC3B,IAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAM,KAAK,GAAG,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;QAEpB,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;QACpB,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IACL,gBAAC;AAAD,CAAC","file":"angular-phrase.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/angular-phrase.ts\");\n","declare global {\n const angular: ng.IAngularStatic;\n}\nimport DataUtils from \"./data-utils\";\nconst phrase = angular.module(\"phrase\", ['pascalprecht.translate', 'ng']);\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\ninterface ITranslateServiceExtend extends angular.translate.ITranslateService {\n _instant: angular.translate.ITranslateService['instant']\n}\n\nphrase.value(\"phraseProjectId\", \"\");\nphrase.value(\"phraseEnabled\", true);\nphrase.value(\"phraseDecoratorPrefix\", \"{{__\");\nphrase.value(\"phraseDecoratorSuffix\", \"__}}\");\nphrase.value(\"phraseAutoLowercase\", true);\n\nphrase.config([\"$provide\", ($provide: angular.auto.IProvideService) => {\n return $provide.decorator(\"$translate\", [\"$delegate\", \"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n ($translate: ITranslateServiceExtend, phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (phraseEnabled) {\n $translate._instant = $translate.instant;\n $translate.instant = (translationId: string | string[]): any => {\n if (typeof translationId === \"object\") {\n return translationId.reduce>((prev, curr: string) => {\n prev[curr] = `${phraseDecoratorPrefix}phrase_${curr as string}${phraseDecoratorSuffix}`;\n return prev;\n }, {});\n }\n\n return `${phraseDecoratorPrefix}phrase_${translationId as string}${phraseDecoratorSuffix}`;\n };\n }\n return $translate;\n }]);\n}]);\n\nphrase.config([\"$compileProvider\", ($compileProvider: angular.ICompileProvider) => {\n return $compileProvider.directive('translate', [\"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n (phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (!phraseEnabled) {\n return {};\n }\n return {\n priority: 1001,\n terminal: true,\n restrict: 'AE',\n scope: true,\n compile: (elem, attr) => {\n let translationId: string;\n if (elem.attr(\"translate\") != undefined) {\n if (elem.attr(\"translate\") !== \"\") {\n translationId = elem.attr(\"translate\");\n } else {\n translationId = elem.text();\n }\n }\n\n if (translationId) {\n let decoratedTranslationId = `${phraseDecoratorPrefix}phrase_${translationId + phraseDecoratorSuffix}`;\n if (attr.translateValues) {\n decoratedTranslationId = `${decoratedTranslationId} (${(attr.translateValues as string)})`;\n }\n elem.html(decoratedTranslationId);\n elem.removeAttr(\"translate\");\n }\n }\n };\n }]);\n}]);\n\nphrase.directive(\"phraseJavascript\", [\"phraseEnabled\", \"phraseProjectId\", \"phraseAutoLowercase\", \"$window\",\n (phraseEnabled: boolean, phraseProjectId: string, phraseAutoLowercase: boolean, $window: Window) => {\n return {\n restrict: \"EA\",\n replace: true,\n link: (): void => {\n if (phraseEnabled) {\n const url = `https://phrase.com/assets/in-context-editor/2.0/app.js?${new Date().getTime()}`;\n $window.PHRASEAPP_CONFIG = {\n projectId: phraseProjectId,\n autoLowercase: phraseAutoLowercase,\n origin: \"angular-phrase\"\n };\n DataUtils.getScript(url);\n }\n }\n };\n }]);\n","export default class DataUtils {\n static getScript(source: string): void {\n const script = document.createElement('script');\n const prior = document.getElementsByTagName('script')[0];\n script.async = true;\n\n script.src = source;\n prior.parentNode.insertBefore(script, prior);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/angular-phrase.min.js b/dist/angular-phrase.min.js index 6e0172d..f34849d 100644 --- a/dist/angular-phrase.min.js +++ b/dist/angular-phrase.min.js @@ -1,2 +1,2 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t);var n=function(){function e(){}return e.getScript=function(e){var t=document.createElement("script"),r=document.getElementsByTagName("script")[0];t.async=!0,t.src=e,r.parentNode.insertBefore(t,r)},e}(),a=angular.module("phrase",["pascalprecht.translate","ng"]);a.value("phraseProjectId",""),a.value("phraseEnabled",!0),a.value("phraseDecoratorPrefix","{{__"),a.value("phraseDecoratorSuffix","__}}"),a.value("phraseAutoLowercase",!0),a.config(["$provide",function(e){return e.decorator("$translate",["$delegate","phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix",function(e,t,r,n){return t&&(e._instant=e.instant,e.instant=function(e){return"object"==typeof e?e.reduce((function(e,t){return e[t]=r+"phrase_"+t+n,e}),{}):r+"phrase_"+e+n}),e}])}]),a.config(["$compileProvider",function(e){return e.directive("translate",["phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix",function(e,t,r){return e?{priority:1001,terminal:!0,restrict:"AE",scope:!0,compile:function(e,n){var a;if(null!=e.attr("translate")&&(a=""!==e.attr("translate")?e.attr("translate"):e.text()),a){var o=t+"phrase_"+(a+r);n.translateValues&&(o=o+" ("+n.translateValues+")"),e.html(o),e.removeAttr("translate")}}}:{}}])}]),a.directive("phraseJavascript",["phraseEnabled","phraseProjectId","phraseAutoLowercase","$window",function(e,t,r,a){return{restrict:"EA",replace:!0,link:function(){if(e){var o="https://phraseapp.com/assets/in-context-editor/2.0/app.js?"+(new Date).getTime();a.PHRASEAPP_CONFIG={projectId:t,autoLowercase:r},n.getScript(o)}}}}])}]); +!function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(r){return e[r]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";t.r(r);var n=function(){function e(){}return e.getScript=function(e){var r=document.createElement("script"),t=document.getElementsByTagName("script")[0];r.async=!0,r.src=e,t.parentNode.insertBefore(r,t)},e}(),a=angular.module("phrase",["pascalprecht.translate","ng"]);a.value("phraseProjectId",""),a.value("phraseEnabled",!0),a.value("phraseDecoratorPrefix","{{__"),a.value("phraseDecoratorSuffix","__}}"),a.value("phraseAutoLowercase",!0),a.config(["$provide",function(e){return e.decorator("$translate",["$delegate","phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix",function(e,r,t,n){return r&&(e._instant=e.instant,e.instant=function(e){return"object"==typeof e?e.reduce((function(e,r){return e[r]=t+"phrase_"+r+n,e}),{}):t+"phrase_"+e+n}),e}])}]),a.config(["$compileProvider",function(e){return e.directive("translate",["phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix",function(e,r,t){return e?{priority:1001,terminal:!0,restrict:"AE",scope:!0,compile:function(e,n){var a;if(null!=e.attr("translate")&&(a=""!==e.attr("translate")?e.attr("translate"):e.text()),a){var o=r+"phrase_"+(a+t);n.translateValues&&(o=o+" ("+n.translateValues+")"),e.html(o),e.removeAttr("translate")}}}:{}}])}]),a.directive("phraseJavascript",["phraseEnabled","phraseProjectId","phraseAutoLowercase","$window",function(e,r,t,a){return{restrict:"EA",replace:!0,link:function(){if(e){var o="https://phrase.com/assets/in-context-editor/2.0/app.js?"+(new Date).getTime();a.PHRASEAPP_CONFIG={projectId:r,autoLowercase:t,origin:"angular-phrase"},n.getScript(o)}}}}])}]); //# sourceMappingURL=angular-phrase.min.js.map \ No newline at end of file diff --git a/dist/angular-phrase.min.js.map b/dist/angular-phrase.min.js.map index dd97aae..52d2d17 100644 --- a/dist/angular-phrase.min.js.map +++ b/dist/angular-phrase.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/data-utils.ts","webpack:///./src/angular-phrase.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getScript","source","script","document","createElement","prior","getElementsByTagName","async","src","parentNode","insertBefore","phrase","angular","config","$provide","decorator","$translate","phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix","_instant","instant","translationId","reduce","prev","curr","$compileProvider","directive","priority","terminal","restrict","scope","compile","elem","attr","undefined","text","decoratedTranslationId","translateValues","html","removeAttr","phraseProjectId","phraseAutoLowercase","$window","replace","link","url","Date","getTime","PHRASEAPP_CONFIG","projectId","autoLowercase"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,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A+BC,GAczF,OAbIF,IACAD,EAAWI,SAAWJ,EAAWK,QACjCL,EAAWK,QAAU,SAACC,GAClB,MAA6B,iBAAlBA,EACAA,EAAcC,QAAO,SAACC,EAA8BC,GAEvD,OADAD,EAAKC,GAAWP,EAAqB,UAAUO,EAAiBN,EACzDK,IACR,IAGGN,EAAqB,UAAUI,EAA0BH,IAGpEH,QAInBL,EAAOE,OAAO,CAAC,mBAAoB,SAACa,GAChC,OAAOA,EAAiBC,UAAU,YAAa,CAAC,gBAAiB,wBAAyB,wBACtF,SAACV,EAAwBC,EAA+BC,GACpD,OAAKF,EAGE,CACHW,SAAU,KACVC,UAAU,EACVC,SAAU,KACVC,OAAO,EACPC,QAAS,SAACC,EAAMC,GACZ,IAAIZ,EASJ,GAR8Ba,MAA1BF,EAAKC,KAAK,eAENZ,EAD2B,KAA3BW,EAAKC,KAAK,aACMD,EAAKC,KAAK,aAEVD,EAAKG,QAIzBd,EAAe,CACf,IAAIe,EAA4BnB,EAAqB,WAAUI,EAAgBH,GAC3Ee,EAAKI,kBACLD,EAA4BA,EAAsB,KAAMH,EAAKI,gBAA0B,KAE3FL,EAAKM,KAAKF,GACVJ,EAAKO,WAAW,gBAvBjB,SA8BvB7B,EAAOgB,UAAU,mBAAoB,CAAC,gBAAiB,kBAAmB,sBAAuB,UAC7F,SAACV,EAAwBwB,EAAyBC,EAA8BC,GAC5E,MAAO,CACHb,SAAU,KACVc,SAAS,EACTC,KAAM,WACF,GAAI5B,EAAe,CACf,IAAM6B,EAAM,8DAA6D,IAAIC,MAAOC,UACpFL,EAAQM,iBAAmB,CACvBC,UAAWT,EACXU,cAAeT,GAEnB,EAAU1C,UAAU8C","file":"angular-phrase.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","export default class DataUtils {\n static getScript(source: string): void {\n const script = document.createElement('script');\n const prior = document.getElementsByTagName('script')[0];\n script.async = true;\n\n script.src = source;\n prior.parentNode.insertBefore(script, prior);\n }\n}\n","declare global {\n const angular: ng.IAngularStatic;\n}\nimport DataUtils from \"./data-utils\";\nconst phrase = angular.module(\"phrase\", ['pascalprecht.translate', 'ng']);\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\ninterface ITranslateServiceExtend extends angular.translate.ITranslateService {\n _instant: angular.translate.ITranslateService['instant']\n}\n\nphrase.value(\"phraseProjectId\", \"\");\nphrase.value(\"phraseEnabled\", true);\nphrase.value(\"phraseDecoratorPrefix\", \"{{__\");\nphrase.value(\"phraseDecoratorSuffix\", \"__}}\");\nphrase.value(\"phraseAutoLowercase\", true);\n\nphrase.config([\"$provide\", ($provide: angular.auto.IProvideService) => {\n return $provide.decorator(\"$translate\", [\"$delegate\", \"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n ($translate: ITranslateServiceExtend, phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (phraseEnabled) {\n $translate._instant = $translate.instant;\n $translate.instant = (translationId) => {\n if (typeof translationId === \"object\") {\n return translationId.reduce((prev: Record, curr: string) => {\n prev[curr] = `${phraseDecoratorPrefix}phrase_${curr as string}${phraseDecoratorSuffix}`;\n return prev;\n }, {});\n }\n\n return `${phraseDecoratorPrefix}phrase_${translationId as string}${phraseDecoratorSuffix}`\n };\n }\n return $translate;\n }]);\n}]);\n\nphrase.config([\"$compileProvider\", ($compileProvider: angular.ICompileProvider) => {\n return $compileProvider.directive('translate', [\"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n (phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (!phraseEnabled) {\n return {};\n }\n return {\n priority: 1001,\n terminal: true,\n restrict: 'AE',\n scope: true,\n compile: (elem, attr) => {\n let translationId: string;\n if (elem.attr(\"translate\") != undefined) {\n if (elem.attr(\"translate\") !== \"\") {\n translationId = elem.attr(\"translate\");\n } else {\n translationId = elem.text();\n }\n }\n\n if (translationId) {\n let decoratedTranslationId = `${phraseDecoratorPrefix}phrase_${translationId + phraseDecoratorSuffix}`;\n if (attr.translateValues) {\n decoratedTranslationId = `${decoratedTranslationId} (${(attr.translateValues as string)})`;\n }\n elem.html(decoratedTranslationId);\n elem.removeAttr(\"translate\");\n }\n }\n };\n }]);\n}]);\n\nphrase.directive(\"phraseJavascript\", [\"phraseEnabled\", \"phraseProjectId\", \"phraseAutoLowercase\", \"$window\",\n (phraseEnabled: boolean, phraseProjectId: string, phraseAutoLowercase: boolean, $window: Window) => {\n return {\n restrict: \"EA\",\n replace: true,\n link: (): void => {\n if (phraseEnabled) {\n const url = `https://phraseapp.com/assets/in-context-editor/2.0/app.js?${new Date().getTime()}`;\n $window.PHRASEAPP_CONFIG = {\n projectId: phraseProjectId,\n autoLowercase: phraseAutoLowercase,\n };\n DataUtils.getScript(url);\n }\n }\n };\n }]);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/data-utils.ts","webpack:///./src/angular-phrase.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getScript","source","script","document","createElement","prior","getElementsByTagName","async","src","parentNode","insertBefore","phrase","angular","config","$provide","decorator","$translate","phraseEnabled","phraseDecoratorPrefix","phraseDecoratorSuffix","_instant","instant","translationId","reduce","prev","curr","$compileProvider","directive","priority","terminal","restrict","scope","compile","elem","attr","undefined","text","decoratedTranslationId","translateValues","html","removeAttr","phraseProjectId","phraseAutoLowercase","$window","replace","link","url","Date","getTime","PHRASEAPP_CONFIG","projectId","autoLowercase","origin"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KA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F,SAACV,EAAwBC,EAA+BC,GACpD,OAAKF,EAGE,CACHW,SAAU,KACVC,UAAU,EACVC,SAAU,KACVC,OAAO,EACPC,QAAS,SAACC,EAAMC,GACZ,IAAIZ,EASJ,GAR8Ba,MAA1BF,EAAKC,KAAK,eAENZ,EAD2B,KAA3BW,EAAKC,KAAK,aACMD,EAAKC,KAAK,aAEVD,EAAKG,QAIzBd,EAAe,CACf,IAAIe,EAA4BnB,EAAqB,WAAUI,EAAgBH,GAC3Ee,EAAKI,kBACLD,EAA4BA,EAAsB,KAAMH,EAAKI,gBAA0B,KAE3FL,EAAKM,KAAKF,GACVJ,EAAKO,WAAW,gBAvBjB,SA8BvB7B,EAAOgB,UAAU,mBAAoB,CAAC,gBAAiB,kBAAmB,sBAAuB,UAC7F,SAACV,EAAwBwB,EAAyBC,EAA8BC,GAC5E,MAAO,CACHb,SAAU,KACVc,SAAS,EACTC,KAAM,WACF,GAAI5B,EAAe,CACf,IAAM6B,EAAM,2DAA0D,IAAIC,MAAOC,UACjFL,EAAQM,iBAAmB,CACvBC,UAAWT,EACXU,cAAeT,EACfU,OAAQ,kBAEZ,EAAUpD,UAAU8C","file":"angular-phrase.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","export default class DataUtils {\n static getScript(source: string): void {\n const script = document.createElement('script');\n const prior = document.getElementsByTagName('script')[0];\n script.async = true;\n\n script.src = source;\n prior.parentNode.insertBefore(script, prior);\n }\n}\n","declare global {\n const angular: ng.IAngularStatic;\n}\nimport DataUtils from \"./data-utils\";\nconst phrase = angular.module(\"phrase\", ['pascalprecht.translate', 'ng']);\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\ninterface ITranslateServiceExtend extends angular.translate.ITranslateService {\n _instant: angular.translate.ITranslateService['instant']\n}\n\nphrase.value(\"phraseProjectId\", \"\");\nphrase.value(\"phraseEnabled\", true);\nphrase.value(\"phraseDecoratorPrefix\", \"{{__\");\nphrase.value(\"phraseDecoratorSuffix\", \"__}}\");\nphrase.value(\"phraseAutoLowercase\", true);\n\nphrase.config([\"$provide\", ($provide: angular.auto.IProvideService) => {\n return $provide.decorator(\"$translate\", [\"$delegate\", \"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n ($translate: ITranslateServiceExtend, phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (phraseEnabled) {\n $translate._instant = $translate.instant;\n $translate.instant = (translationId: string | string[]): any => {\n if (typeof translationId === \"object\") {\n return translationId.reduce>((prev, curr: string) => {\n prev[curr] = `${phraseDecoratorPrefix}phrase_${curr as string}${phraseDecoratorSuffix}`;\n return prev;\n }, {});\n }\n\n return `${phraseDecoratorPrefix}phrase_${translationId as string}${phraseDecoratorSuffix}`;\n };\n }\n return $translate;\n }]);\n}]);\n\nphrase.config([\"$compileProvider\", ($compileProvider: angular.ICompileProvider) => {\n return $compileProvider.directive('translate', [\"phraseEnabled\", \"phraseDecoratorPrefix\", \"phraseDecoratorSuffix\",\n (phraseEnabled: boolean, phraseDecoratorPrefix: string, phraseDecoratorSuffix: string) => {\n if (!phraseEnabled) {\n return {};\n }\n return {\n priority: 1001,\n terminal: true,\n restrict: 'AE',\n scope: true,\n compile: (elem, attr) => {\n let translationId: string;\n if (elem.attr(\"translate\") != undefined) {\n if (elem.attr(\"translate\") !== \"\") {\n translationId = elem.attr(\"translate\");\n } else {\n translationId = elem.text();\n }\n }\n\n if (translationId) {\n let decoratedTranslationId = `${phraseDecoratorPrefix}phrase_${translationId + phraseDecoratorSuffix}`;\n if (attr.translateValues) {\n decoratedTranslationId = `${decoratedTranslationId} (${(attr.translateValues as string)})`;\n }\n elem.html(decoratedTranslationId);\n elem.removeAttr(\"translate\");\n }\n }\n };\n }]);\n}]);\n\nphrase.directive(\"phraseJavascript\", [\"phraseEnabled\", \"phraseProjectId\", \"phraseAutoLowercase\", \"$window\",\n (phraseEnabled: boolean, phraseProjectId: string, phraseAutoLowercase: boolean, $window: Window) => {\n return {\n restrict: \"EA\",\n replace: true,\n link: (): void => {\n if (phraseEnabled) {\n const url = `https://phrase.com/assets/in-context-editor/2.0/app.js?${new Date().getTime()}`;\n $window.PHRASEAPP_CONFIG = {\n projectId: phraseProjectId,\n autoLowercase: phraseAutoLowercase,\n origin: \"angular-phrase\"\n };\n DataUtils.getScript(url);\n }\n }\n };\n }]);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/angular-phrase.ts b/src/angular-phrase.ts index 8be7835..b84fb11 100644 --- a/src/angular-phrase.ts +++ b/src/angular-phrase.ts @@ -80,6 +80,7 @@ phrase.directive("phraseJavascript", ["phraseEnabled", "phraseProjectId", "phras $window.PHRASEAPP_CONFIG = { projectId: phraseProjectId, autoLowercase: phraseAutoLowercase, + origin: "angular-phrase" }; DataUtils.getScript(url); } diff --git a/test/unit/directives/phrase_javascript.spec.ts b/test/unit/directives/phrase_javascript.spec.ts index 3075270..3b5d4df 100644 --- a/test/unit/directives/phrase_javascript.spec.ts +++ b/test/unit/directives/phrase_javascript.spec.ts @@ -69,6 +69,9 @@ describe('phraseJavascript', () => { it("should attach the autoLowercase setting to the config object", () => { expect((window as any).PHRASEAPP_CONFIG.autoLowercase).toBeFalsy(); }); + it("should attach the origin to the config object", () => { + expect((window as any).PHRASEAPP_CONFIG.origin).toBe("angular-phrase"); + }); }); }); });