laxar-angular-adapter
Advanced tools
Comparing version
@@ -5,2 +5,9 @@ # Changelog | ||
## v2.0.0-rc.0 | ||
- [#43](https://github.com/LaxarJS/laxar-angular-adapter/issues/43): use laxar-infrastructure | ||
- [#42](https://github.com/LaxarJS/laxar-angular-adapter/issues/42): removed remnants of promise-patching | ||
## v2.0.0-beta.1 | ||
@@ -7,0 +14,0 @@ |
@@ -1,1316 +0,2 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("angular"), require("laxar")); | ||
else if(typeof define === 'function' && define.amd) | ||
define("laxar-angular-adapter", ["angular", "laxar"], factory); | ||
else if(typeof exports === 'object') | ||
exports["laxar-angular-adapter"] = factory(require("angular"), require("laxar")); | ||
else | ||
root["laxar-angular-adapter"] = factory(root["angular"], root["laxar"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_2__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // identity function for calling harmony imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 8); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_0__; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function(originalModule) { | ||
if(!originalModule.webpackPolyfill) { | ||
var module = Object.create(originalModule); | ||
// module.parent = undefined by default | ||
if(!module.children) module.children = []; | ||
Object.defineProperty(module, "loaded", { | ||
enumerable: true, | ||
get: function() { | ||
return module.l; | ||
} | ||
}); | ||
Object.defineProperty(module, "id", { | ||
enumerable: true, | ||
get: function() { | ||
return module.i; | ||
} | ||
}); | ||
Object.defineProperty(module, "exports", { | ||
enumerable: true, | ||
}); | ||
module.webpackPolyfill = 1; | ||
} | ||
return module; | ||
}; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_laxar__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return name; }); | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
/** | ||
* A module for the `axId` and `axFor` directives. | ||
* | ||
* @module axId | ||
*/ | ||
var module = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('axId', []); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var ID_DIRECTIVE_NAME = 'axId'; | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* This directive should be used within a widget whenever a unique id for a DOM element should be created. | ||
* It's value is evaluated as AngularJS expression and used as a local identifier to generate a distinct, | ||
* unique document wide id. | ||
* | ||
* A common use case is in combination with {@link axFor} for input fields having a label. | ||
* | ||
* Example: | ||
* ```html | ||
* <label ax-for="'userName'">Please enter your name:</label> | ||
* <input ax-id="'userName'" type="text" ng-model="username"> | ||
* ``` | ||
* | ||
* @name axId | ||
* @directive | ||
*/ | ||
module.directive(ID_DIRECTIVE_NAME, [function () { | ||
return { | ||
restrict: 'A', | ||
link: function link(scope, element, attrs) { | ||
var localId = scope.$eval(attrs[ID_DIRECTIVE_NAME]); | ||
__WEBPACK_IMPORTED_MODULE_1_laxar__["assert"].state(localId, 'directive axId needs a non-empty local id, e.g. ax-id="\'myLocalId\'".'); | ||
element.attr('id', scope.id(localId)); | ||
} | ||
}; | ||
}]); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var FOR_DIRECTIVE_NAME = 'axFor'; | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* This directive should be used within a widget whenever an id, generated using the {@link axId} directive, | ||
* should be referenced at a `label` element. | ||
* | ||
* Example: | ||
* ```html | ||
* <label ax-for="'userName'">Please enter your name:</label> | ||
* <input ax-id="'userName'" type="text" ng-model="username"> | ||
* ``` | ||
* | ||
* @name axFor | ||
* @directive | ||
*/ | ||
module.directive(FOR_DIRECTIVE_NAME, [function () { | ||
return { | ||
restrict: 'A', | ||
link: function link(scope, element, attrs) { | ||
var localId = scope.$eval(attrs[FOR_DIRECTIVE_NAME]); | ||
__WEBPACK_IMPORTED_MODULE_1_laxar__["assert"].state(localId, 'directive axFor needs a non-empty local id, e.g. ax-for="\'myLocalId\'".'); | ||
element.attr('for', scope.id(localId)); | ||
} | ||
}; | ||
}]); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var name = module.name; | ||
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(1)(module))) | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return name; }); | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
/** | ||
* A module for the `axWidgetArea` directive. | ||
* | ||
* @module axWidgetArea | ||
*/ | ||
var module = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('axWidgetArea', []); | ||
var DIRECTIVE_NAME = 'axWidgetArea'; | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* The *axWidgetArea* directive is used to mark DOM elements as possible containers for widgets. They're | ||
* most commonly used in layouts using static names. These areas can then be referenced from within page | ||
* definitions in order to add widgets to them. Additionally it is possible that widgets expose widget | ||
* areas themselves. In that case the name given within the widget template is prefixed with the id of the | ||
* widget instance, separated by a dot. If, within a widget, a name is dynamic (i.e. can be configured via | ||
* feature configuration), the corresponding `ax-widget-area-binding` attribute can be set to bind a name. | ||
* | ||
* Example: | ||
* ```html | ||
* <div ax-widget-area="myArea"><!-- Here will be widgets --></div> | ||
* ``` | ||
* | ||
* Example with binding: | ||
* ```html | ||
* <div ax-widget-area | ||
* ax-widget-area-binding="features.content.areaName"> | ||
* <!-- Here will be widgets --> | ||
* </div> | ||
* ``` | ||
* | ||
* @name axWidgetArea | ||
* @directive | ||
*/ | ||
module.directive(DIRECTIVE_NAME, ['axWidgetServices', function (widgetServices) { | ||
return { | ||
restrict: 'A', | ||
link: function link(scope, element, attrs) { | ||
var areaName = attrs[DIRECTIVE_NAME]; | ||
if (!areaName) { | ||
var bindingAttribute = DIRECTIVE_NAME + 'Binding'; | ||
if (attrs[bindingAttribute]) { | ||
areaName = scope.$eval(attrs[bindingAttribute]); | ||
} else { | ||
var widgetId = scope.widget && scope.widget.id; | ||
var message = 'axWidgetArea: area at ' + (widgetId || scope.layoutClass) + ' has neither a name ' + 'nor a binding assigned.'; | ||
throw new Error(message); | ||
} | ||
} | ||
widgetServices(scope).axAreaHelper.register(areaName, element[0]); | ||
} | ||
}; | ||
}]); | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var name = module.name; | ||
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(1)(module))) | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_laxar__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return name; }); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
/** | ||
* Copyright 2017 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
/** | ||
* A module for the `axLocalize` filter | ||
* | ||
* @module axId | ||
*/ | ||
var axLocalizeFactory = ['axGlobalLog', function (log) { | ||
/** | ||
* Localize the given value, based on the given i18n state. | ||
* | ||
* Primitive values will be left as they are, independent of the presence of any language tag. | ||
* Using this filter is less efficient than precomputing the localization in the controller because | ||
* the `i18n` instance has to be an object (not efficient to watch). | ||
* | ||
* @param {*} i18nValue | ||
* a value to localize | ||
* @param {axI18n} [i18n] | ||
* an AxI18n instance to use for localization | ||
* | ||
* @return {*} value | ||
* the localized value | ||
*/ | ||
return function (i18nValue, i18n) { | ||
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
if ((typeof i18nValue === 'undefined' ? 'undefined' : _typeof(i18nValue)) !== 'object') { | ||
return args.length ? __WEBPACK_IMPORTED_MODULE_1_laxar__["string"].format.apply(__WEBPACK_IMPORTED_MODULE_1_laxar__["string"], [i18nValue].concat(args)) : i18nValue; | ||
} | ||
if (!i18n || !i18n.localize) { | ||
log.warn('axLocalize:i18n cannot localize [0:anonymize]. Pass an AxI18n instance as `i18n`, not [1]', i18nValue, i18n); | ||
return undefined; | ||
} | ||
return args.length ? i18n.format.apply(i18n, [i18nValue].concat(args)) : i18n.localize(i18nValue); | ||
}; | ||
}]; | ||
var name = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('axLocalize', []).filter('axLocalize', axLocalizeFactory).name; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__output__ = __webpack_require__(9); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return name; }); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
var module = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('axProfiling', ['axAngularGlobalServices']); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var axProfiling = void 0; | ||
var origWatch = void 0; | ||
var win = void 0; | ||
var out = void 0; | ||
module.run(['$rootScope', '$window', 'axConfiguration', function ($rootScope, $window, configuration) { | ||
if (!configuration.get('profiling.enabled', false)) { | ||
return; | ||
} | ||
win = $window; | ||
out = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__output__["a" /* create */])($window); | ||
if (!win.performance || !win.performance.now) { | ||
out.log('Performance API is not available. Profiling is disabled.'); | ||
return; | ||
} | ||
out.log('%c!!! Profiling enabled. Application performance will suffer !!!', 'font-weight: bold; font-size: 1.2em'); | ||
out.log('Type "axProfiling.help()" to get a list of available methods'); | ||
var scopePrototype = $rootScope.constructor.prototype; | ||
axProfiling = $window.axProfiling = { | ||
items: {}, | ||
widgetIdToScopeId: {}, | ||
logWatchers: function logWatchers(id) { | ||
if (id && typeof id === 'string') { | ||
out.logForId(axProfiling, 'watchFn', id); | ||
} else { | ||
out.logAll(axProfiling, 'watchFn'); | ||
} | ||
}, | ||
logListeners: function logListeners(id) { | ||
if (id && typeof id === 'string') { | ||
out.logForId(axProfiling, 'listener', id); | ||
} else { | ||
out.logAll(axProfiling, 'listener'); | ||
} | ||
}, | ||
log: function log(id) { | ||
if (id && typeof id === 'string') { | ||
out.logForId(axProfiling, null, id); | ||
} else { | ||
out.log('All listeners:'); | ||
out.logAll(axProfiling, 'listener'); | ||
out.log('All watchers:'); | ||
out.logAll(axProfiling, 'watchFn'); | ||
} | ||
}, | ||
reset: function reset() { | ||
Object.keys(axProfiling.items).forEach(function (key) { | ||
axProfiling.items[key].watchers.forEach(function (watcher) { | ||
watcher.watchFn.time = 0; | ||
watcher.watchFn.count = 0; | ||
watcher.listener.time = 0; | ||
watcher.listener.count = 0; | ||
}); | ||
}); | ||
}, | ||
help: printHelp | ||
}; | ||
origWatch = scopePrototype.$watch; | ||
scopePrototype.$watch = function (watchExp, listener, objectEquality) { | ||
// Don't change to arrow notation, since we need access to `this` for the correct scope instance. | ||
return attachProfiling(this, watchExp, listener, objectEquality || false); | ||
}; | ||
}]); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function attachProfiling(scope, watchExp, listener, objectEquality) { | ||
var watcherIsFunction = typeof watchExp === 'function'; | ||
var listenerIsFunction = typeof listener === 'function'; | ||
var items = axProfiling.items; | ||
var context = determineContext(scope); | ||
if (!(scope.$id in items)) { | ||
items[scope.$id] = { | ||
context: context, | ||
watchers: [] | ||
}; | ||
scope.$on('$destroy', function () { | ||
detachProfiling(scope); | ||
delete items[scope.$id]; | ||
}); | ||
} | ||
if (context.widgetScopeId) { | ||
if (!(context.widgetId in axProfiling.widgetIdToScopeId)) { | ||
axProfiling.widgetIdToScopeId[context.widgetId] = context.widgetScopeId; | ||
} | ||
} | ||
var profilingEntry = { | ||
watchFn: { | ||
type: watcherIsFunction ? 'f' : 's', | ||
name: watcherIsFunction ? functionName(watchExp) + '()' : watchExp, | ||
time: 0, | ||
count: 0 | ||
}, | ||
listener: { | ||
type: listenerIsFunction ? 'f' : 's', | ||
name: listenerIsFunction ? functionName(listener) + '()' : listener, | ||
time: 0, | ||
count: 0 | ||
} | ||
}; | ||
items[scope.$id].watchers.push(profilingEntry); | ||
var stopWatching = origWatch.call(scope, watchExp, listener, objectEquality); | ||
var watchEntry = scope.$$watchers[0]; | ||
watchEntry.get = instrumentFunction(watchEntry.get, profilingEntry.watchFn); | ||
watchEntry.fn = instrumentFunction(watchEntry.fn, profilingEntry.listener); | ||
return function () { | ||
stopWatching(); | ||
detachProfiling(scope); | ||
}; | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function detachProfiling(scope) { | ||
delete axProfiling.items[scope.$id]; | ||
Object.keys(axProfiling.widgetIdToScopeId).forEach(function (widgetId) { | ||
if (axProfiling.widgetIdToScopeId[widgetId] === scope.$id) { | ||
delete axProfiling.widgetIdToScopeId[widgetId]; | ||
} | ||
}); | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function instrumentFunction(func, entry) { | ||
return function () { | ||
var start = win.performance.now(); | ||
var result = func.apply(undefined, arguments); | ||
var time = win.performance.now() - start; | ||
++entry.count; | ||
entry.time += time; | ||
return result; | ||
}; | ||
} | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function determineContext(scope) { | ||
var current = scope; | ||
while (!current.hasOwnProperty('widget') && current !== current.$root) { | ||
current = current.$parent; | ||
} | ||
var isInWidget = !!current.widget; | ||
return { | ||
widgetName: isInWidget ? current.widget.path : '', | ||
widgetId: isInWidget ? current.widget.id : '', | ||
widgetScopeId: isInWidget ? current.$id : null, | ||
scopeId: scope.$id | ||
}; | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var FUNCTION_NAME_REGEXP = /^[ ]*function([^(]*?)\(/; | ||
function functionName(func) { | ||
if (func.name && typeof func.name === 'string') { | ||
return func.name; | ||
} | ||
var _ref = FUNCTION_NAME_REGEXP.exec(func.toString()) || [], | ||
_ref2 = _slicedToArray(_ref, 2), | ||
functionName = _ref2[1]; | ||
return functionName ? functionName.trim() : '[anonymous]'; | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function printHelp() { | ||
out.log('Available commands:\n\n' + ' - help():\n' + ' prints this help\n\n' + ' - log( [scopeOrWidgetId] ):\n' + ' If the argument is omitted this is the same as calling\n' + ' logWatchers() first and logListeners() afterwards.\n' + ' Otherwise all listeners and watchers of the widget or scope\n' + ' with the given id are logged in one table\n\n' + ' - logWatchers( [scopeOrWidgetId] ):\n' + ' If the argument is omitted the watchers of all scopes belonging to\n' + ' a specific widget or of global scopes are logged.\n' + ' Otherwise more detailed data for the watchers of the given scope\n' + ' or widget are logged.\n\n' + ' - logListeners( [scopeOrWidgetId] ):\n' + ' If the argument is omitted the listeners of all scopes belonging to\n' + ' a specific widget or of global scopes are logged.\n' + ' Otherwise more detailed data for the listeners of the given scope\n' + ' or widget are logged.\n\n' + ' - reset():\n' + ' Resets all "# of executions" and millisecond data to zero.'); | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var name = module.name; | ||
/* unused harmony default export */ var _unused_webpack_default_export = (module); | ||
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(1)(module))) | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return name; }); | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
var module = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('axVisibilityService', []); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* Directives should use this service to stay informed about visibility changes to their widget. | ||
* They should not attempt to determine their visibility from the event bus (no DOM information), | ||
* nor poll it from the browser (too expensive). | ||
* | ||
* In contrast to the visibility events received over the event bus, these handlers will fire _after_ the | ||
* visibility change has been implemented in the DOM, at which point in time the actual browser rendering | ||
* state should correspond to the information conveyed in the event. | ||
* | ||
* The visibility service allows to register for onShow/onHide/onChange. When cleared, all handlers for | ||
* the given scope will be cleared. Handlers are automatically cleared as soon as the given scope is | ||
* destroyed. Handlers will be called whenever the given scope's visibility changes due to the widget | ||
* becoming visible/invisible. Handlers will _not_ be called on state changes originating _from within_ the | ||
* widget such as those caused by `ngShow`. | ||
* | ||
* If a widget becomes visible at all, the corresponding handlers for onChange and onShow are guaranteed | ||
* to be called at least once. | ||
* | ||
* @name axVisibilityService | ||
* @injection | ||
*/ | ||
module.factory('axVisibilityService', ['axWidgetServices', 'axHeartbeat', function (widgetServices, heartbeat) { | ||
return { | ||
handlerFor: handlerFor | ||
}; | ||
/** | ||
* Create a DOM visibility handler for the given scope. | ||
* | ||
* @param {Object} scope | ||
* the scope from which to infer visibility. Must be a widget scope or nested in a widget scope | ||
* | ||
* @return {axVisibilityServiceHandler} | ||
* a visibility handler for the given scope | ||
* | ||
* @memberOf axVisibilityService | ||
*/ | ||
function handlerFor(scope) { | ||
var _widgetServices = widgetServices(scope), | ||
axVisibility = _widgetServices.axVisibility; | ||
axVisibility.onChange(updateState); | ||
scope.$on('$destroy', function () { | ||
axVisibility.unsubscribe(updateState); | ||
}); | ||
var lastState = axVisibility.isVisible(); | ||
/** | ||
* A scope bound visibility handler. | ||
* | ||
* @name axVisibilityServiceHandler | ||
*/ | ||
var api = { | ||
/** | ||
* Determine if the governing widget scope's DOM is visible right now. | ||
* | ||
* @return {Boolean} | ||
* `true` if the widget associated with this handler is visible right now, else `false` | ||
* | ||
* @memberOf axVisibilityServiceHandler | ||
*/ | ||
isVisible: function isVisible() { | ||
return axVisibility.isVisible(); | ||
}, | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Schedule a handler to be called with the new DOM visibility on any DOM visibility change. | ||
* | ||
* @param {Function<Boolean>} handler | ||
* the callback to process visibility changes | ||
* | ||
* @return {axVisibilityServiceHandler} | ||
* this visibility handler (for chaining) | ||
* | ||
* @memberOf axVisibilityServiceHandler | ||
*/ | ||
onChange: function onChange(handler) { | ||
addHandler(handler, true); | ||
addHandler(handler, false); | ||
return api; | ||
}, | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Schedule a handler to be called with the new DOM visibility when it has changed to `true`. | ||
* | ||
* @param {Function<Boolean>} handler | ||
* the callback to process visibility changes | ||
* | ||
* @return {axVisibilityServiceHandler} | ||
* this visibility handler (for chaining) | ||
* | ||
* @memberOf axVisibilityServiceHandler | ||
*/ | ||
onShow: function onShow(handler) { | ||
addHandler(handler, true); | ||
return api; | ||
}, | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Schedule a handler to be called with the new DOM visibility when it has changed to `false`. | ||
* | ||
* @param {Function<Boolean>} handler | ||
* the callback to process visibility changes | ||
* | ||
* @return {axVisibilityServiceHandler} | ||
* this visibility handler (for chaining) | ||
* | ||
* @memberOf axVisibilityServiceHandler | ||
*/ | ||
onHide: function onHide(handler) { | ||
addHandler(handler, false); | ||
return api; | ||
}, | ||
////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Removes all visibility handlers. | ||
* | ||
* @return {axVisibilityServiceHandler} | ||
* this visibility handler (for chaining) | ||
* | ||
* @memberOf axVisibilityServiceHandler | ||
*/ | ||
clear: clear | ||
}; | ||
var showHandlers = []; | ||
var hideHandlers = []; | ||
return api; | ||
///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function clear() { | ||
showHandlers.splice(0, showHandlers.length); | ||
hideHandlers.splice(0, hideHandlers.length); | ||
return api; | ||
} | ||
///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* Run all handlers registered for the given area and target state after the next heartbeat. | ||
* Also remove any handlers that have been cleared since the last run. | ||
* @private | ||
*/ | ||
function updateState(targetState) { | ||
var state = axVisibility.isVisible(); | ||
if (state === lastState) { | ||
return; | ||
} | ||
lastState = state; | ||
heartbeat.onAfterNext(function () { | ||
var handlers = targetState ? showHandlers : hideHandlers; | ||
handlers.forEach(function (f) { | ||
return f(targetState); | ||
}); | ||
}); | ||
} | ||
///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* Add a show/hide-handler for a given area and visibility state. Execute the handler right away if | ||
* the state is already known, and `true` (since all widgets start as invisible). | ||
* @private | ||
*/ | ||
function addHandler(handler, targetState) { | ||
(targetState ? showHandlers : hideHandlers).push(handler); | ||
// State already known to be true? In that case, initialize: | ||
if (targetState && axVisibility.isVisible() === targetState) { | ||
handler(targetState); | ||
} | ||
} | ||
} | ||
}]); | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
var name = module.name; | ||
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(1)(module))) | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_laxar___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_laxar__); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__lib_directives_id__ = __webpack_require__(3); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__lib_directives_widget_area__ = __webpack_require__(4); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__lib_profiling_profiling__ = __webpack_require__(6); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__lib_services_visibility_service__ = __webpack_require__(7); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__lib_filters_localize__ = __webpack_require__(5); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ANGULAR_SERVICES_MODULE_NAME", function() { return ANGULAR_SERVICES_MODULE_NAME; }); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ANGULAR_MODULE_NAME", function() { return ANGULAR_MODULE_NAME; }); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "technology", function() { return technology; }); | ||
/* harmony export (immutable) */ __webpack_exports__["bootstrap"] = bootstrap; | ||
/* harmony export (immutable) */ __webpack_exports__["reset"] = reset; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
/** | ||
* Provides an AngularJS v1.x adapter factory for a laxarjs bootstrapping context. | ||
* https://github.com/LaxarJS/laxar/blob/master/docs/manuals/adapters.md | ||
* | ||
* Because in AngularJS v1.x module registry and injector are global, there are certain restrictions when | ||
* bootstrapping multiple LaxarJS applications in the same Browser window: | ||
* - Currently, all AngularJS modules must be available when bootstrapping the first instance, and the | ||
* widget modules for all bootstrapping instances must be passed to the first invocation. | ||
* - Multiple bootstrapping instances share each other's AngularJS modules (e.g. controls). | ||
* | ||
* @module laxar-angular-adapter | ||
*/ | ||
// exported for unit tests | ||
var ANGULAR_SERVICES_MODULE_NAME = 'axAngularGlobalServices'; | ||
var ANGULAR_MODULE_NAME = 'axAngularWidgetAdapter'; | ||
var technology = 'angular'; | ||
// Due to the nature of AngularJS v1.x, we can only create the AngularJS modules once, | ||
// so we keep certain injections global. | ||
var injectorCreated = false; | ||
var $rootScope = void 0; | ||
var $controller = void 0; | ||
var $compile = void 0; | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function bootstrap(_ref, laxarServices) { | ||
var widgets = _ref.widgets, | ||
controls = _ref.controls; | ||
var api = { | ||
create: create, | ||
serviceDecorators: serviceDecorators | ||
}; | ||
// register controllers under normalized module names that can also be derived from the widget.json name: | ||
var controllerNames = {}; | ||
widgets.forEach(function (_ref2) { | ||
var descriptor = _ref2.descriptor, | ||
module = _ref2.module; | ||
controllerNames[descriptor.name] = capitalize(module.name) + 'Controller'; | ||
}); | ||
var activeWidgetServices = {}; | ||
// Instantiate the AngularJS modules and bootstrap angular, but only the first time! | ||
if (!injectorCreated) { | ||
injectorCreated = true; | ||
createAngularServicesModule(); | ||
createAngularAdapterModule(); | ||
} | ||
if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.mock) { | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.mock.module(ANGULAR_SERVICES_MODULE_NAME); | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.mock.module(ANGULAR_MODULE_NAME); | ||
widgets.concat(controls).forEach(function (_) { | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.mock.module(_.module.name); | ||
}); | ||
} | ||
// LaxarJS EventBus works with native promise. | ||
// To be notified of eventBus ticks, install a listener. | ||
laxarServices.heartbeat.registerHeartbeatListener(function () { | ||
$rootScope.$digest(); | ||
}); | ||
var anchorElement = document.createElement('DIV'); | ||
anchorElement.style.display = 'none'; | ||
document.body.appendChild(anchorElement); | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.bootstrap(anchorElement, [ANGULAR_MODULE_NAME]); | ||
return api; | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function serviceDecorators() { | ||
return { | ||
axGlobalEventBus: decorateEventBusForDigest, | ||
axEventBus: decorateEventBusForDigest, | ||
axContext: function axContext(context) { | ||
return __WEBPACK_IMPORTED_MODULE_0_angular___default.a.extend($rootScope.$new(), context); | ||
} | ||
}; | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// eslint-disable-next-line valid-jsdoc | ||
function create(_ref3) { | ||
var widgetName = _ref3.widgetName, | ||
anchorElement = _ref3.anchorElement, | ||
services = _ref3.services, | ||
provideServices = _ref3.provideServices; | ||
var widgetScope = services.axContext; | ||
var id = widgetScope.widget.id; | ||
activeWidgetServices[id] = services; | ||
createController(); | ||
return { | ||
domAttachTo: domAttachTo, | ||
domDetach: domDetach, | ||
destroy: destroy | ||
}; | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function createController() { | ||
var controllerName = controllerNames[widgetName]; | ||
services.$scope = widgetScope; | ||
provideServices(services); | ||
$controller(controllerName, services); | ||
} | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Synchronously attach the widget DOM to the given area. | ||
* | ||
* @param {HTMLElement} areaElement | ||
* The widget area to attach this widget to. | ||
* @param {String} templateHtml | ||
* The AngularJS HTML template to compile and link to this widget | ||
*/ | ||
function domAttachTo(areaElement, templateHtml) { | ||
if (templateHtml === null) { | ||
return; | ||
} | ||
var element = __WEBPACK_IMPORTED_MODULE_0_angular___default.a.element(anchorElement); | ||
element.html(templateHtml); | ||
areaElement.appendChild(anchorElement); | ||
$compile(anchorElement)(widgetScope); | ||
if (!$rootScope.$$phase) { | ||
widgetScope.$digest(); | ||
} | ||
} | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function domDetach() { | ||
var parent = anchorElement.parentNode; | ||
if (parent) { | ||
parent.removeChild(anchorElement); | ||
} | ||
} | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function destroy() { | ||
widgetScope.$destroy(); | ||
delete activeWidgetServices[id]; | ||
} | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function decorateEventBusForDigest(eventBus) { | ||
var result = Object.create(eventBus); | ||
result.publish = function () { | ||
return tap(eventBus.publish.apply(eventBus, arguments)); | ||
}; | ||
result.publishAndGatherReplies = function () { | ||
return tap(eventBus.publishAndGatherReplies.apply(eventBus, arguments)); | ||
}; | ||
return result; | ||
function tap(promise) { | ||
promise.then = function (onFulfilled, onRejected) { | ||
return Promise.prototype.then.call(promise, intercept(onFulfilled), intercept(onRejected)); | ||
}; | ||
return promise; | ||
} | ||
function intercept(callback) { | ||
return typeof callback !== 'function' ? callback : function () { | ||
try { | ||
return callback.apply(undefined, arguments); | ||
} finally { | ||
$rootScope.$evalAsync(function () {}); | ||
} | ||
}; | ||
} | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function createAngularServicesModule() { | ||
// Here we ensure availability of globally public laxar services for directives and other services | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module(ANGULAR_SERVICES_MODULE_NAME, []).factory('axConfiguration', function () { | ||
return laxarServices.configuration; | ||
}).factory('axGlobalEventBus', function () { | ||
return decorateEventBusForDigest(laxarServices.globalEventBus); | ||
}).factory('axGlobalLog', function () { | ||
return laxarServices.log; | ||
}).factory('axGlobalStorage', function () { | ||
return laxarServices.storage; | ||
}).factory('axHeartbeat', function () { | ||
return laxarServices.heartbeat; | ||
}).factory('axTooling', function () { | ||
return laxarServices.tooling; | ||
}).factory('axWidgetServices', function () { | ||
return createWidgetServiceProvider(); | ||
}); | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function createWidgetServiceProvider() { | ||
return function (scope) { | ||
var currentScope = scope; | ||
var widgetId = null; | ||
while (!widgetId && currentScope) { | ||
if (currentScope.widget && typeof currentScope.widget.id === 'string') { | ||
widgetId = currentScope.widget.id; | ||
break; | ||
} | ||
currentScope = currentScope.$parent; | ||
} | ||
__WEBPACK_IMPORTED_MODULE_1_laxar__["assert"].state(widgetId, 'No widget context found in given scope or one of its parents.'); | ||
var services = activeWidgetServices[widgetId]; | ||
__WEBPACK_IMPORTED_MODULE_1_laxar__["assert"].state(services, 'No services found for widget with id ' + widgetId + '.'); | ||
return services; | ||
}; | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function createAngularAdapterModule() { | ||
var internalDependencies = [ANGULAR_SERVICES_MODULE_NAME, __WEBPACK_IMPORTED_MODULE_2__lib_directives_id__["a" /* name */], __WEBPACK_IMPORTED_MODULE_3__lib_directives_widget_area__["a" /* name */], __WEBPACK_IMPORTED_MODULE_6__lib_filters_localize__["a" /* name */], __WEBPACK_IMPORTED_MODULE_4__lib_profiling_profiling__["a" /* name */], __WEBPACK_IMPORTED_MODULE_5__lib_services_visibility_service__["a" /* name */]]; | ||
var externalDependencies = widgets.concat(controls).map(function (_) { | ||
return _.module.name; | ||
}); | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module(ANGULAR_MODULE_NAME, [].concat(internalDependencies, _toConsumableArray(externalDependencies))).run(['$compile', '$controller', '$rootScope', function (_$compile_, _$controller_, _$rootScope_) { | ||
$controller = _$controller_; | ||
$compile = _$compile_; | ||
$rootScope = _$rootScope_; | ||
}]).factory('$exceptionHandler', function () { | ||
return function (exception, cause) { | ||
var msg = exception.message || exception; | ||
laxarServices.log.error('There was an exception: ' + msg + ', \nstack: ' + exception.stack + ', \n, Cause: ' + cause); | ||
}; | ||
}); | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// For testing, to reset the global AngularJS module state: | ||
function reset() { | ||
injectorCreated = false; | ||
if (typeof window.Promise._reset === 'function') { | ||
window.Promise._reset(); | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function capitalize(_) { | ||
return _.replace(/^./, function (_) { | ||
return _.toUpperCase(); | ||
}); | ||
} | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); | ||
/* harmony export (immutable) */ __webpack_exports__["a"] = create; | ||
/** | ||
* Copyright 2016 aixigo AG | ||
* Released under the MIT license. | ||
* http://laxarjs.org/license | ||
*/ | ||
function create(windowObject) { | ||
var win = windowObject; | ||
return { | ||
log: consoleLog, | ||
logForId: logForId, | ||
logAll: logAll | ||
}; | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function logForId(axProfiling, wlKey, id) { | ||
var profilingData = axProfiling.items; | ||
var isScopeId = !!id.match(/^[A-Za-z0-9]{3}$/) && id in profilingData; | ||
var scopeId = id; | ||
var watchers = []; | ||
if (isScopeId) { | ||
watchers = profilingData[id].watchers; | ||
} else { | ||
scopeId = axProfiling.widgetIdToScopeId[id]; | ||
watchers = flatMap(Object.keys(profilingData).map(function (id) { | ||
return profilingData[id]; | ||
}).filter(function (item) { | ||
return item.context.widgetId === id; | ||
}), function (item) { | ||
return item.watchers; | ||
}); | ||
} | ||
var ngContext = [].slice.call(win.document.getElementsByClassName('ng-scope'), 0).concat([win.document]).map(function (element) { | ||
return { | ||
element: element, | ||
scope: __WEBPACK_IMPORTED_MODULE_0_angular___default.a.element(element).scope() | ||
}; | ||
}).filter(function (item) { | ||
return item.scope.$id === scopeId; | ||
})[0] || null; | ||
consoleLog('Showing details for %s with id "%s"', isScopeId ? 'scope' : 'widget', id); | ||
if (ngContext) { | ||
consoleLog('Context: Scope: %o, Element %o', ngContext.scope, ngContext.element); | ||
} | ||
var data = watchers.map(function (entry) { | ||
var result = {}; | ||
if (!wlKey || wlKey === 'watchFn') { | ||
var w = entry.watchFn; | ||
result['Watcher'] = w.name; | ||
result['Watcher ms total'] = toPrecision(w.time, 3); | ||
result['Watcher ms average'] = toPrecision(average(w.time, w.count), 3); | ||
result['Watcher # executions'] = w.count; | ||
} | ||
if (!wlKey || wlKey === 'listener') { | ||
var l = entry.listener; | ||
result['Listener'] = l.name; | ||
result['Listener ms total'] = toPrecision(l.time, 3); | ||
result['Listener ms average'] = toPrecision(average(l.time, l.count), 3); | ||
result['Listener # executions'] = l.count; | ||
} | ||
return result; | ||
}); | ||
logTabularData(data); | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function logAll(axProfiling, wlKey) { | ||
var profilingData = axProfiling.items; | ||
var data = []; | ||
var totalWatchFunctions = 0; | ||
var totalWatchExpressions = 0; | ||
var totalTime = 0; | ||
var totalExecutions = 0; | ||
var dataByWidgetId = {}; | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.forEach(profilingData, function (item, key) { | ||
var widgetId = item.context.widgetId; | ||
if (!widgetId) { | ||
dataByWidgetId[key] = item; | ||
return; | ||
} | ||
if (!(widgetId in dataByWidgetId)) { | ||
dataByWidgetId[widgetId] = { | ||
context: item.context, | ||
watchers: [] | ||
}; | ||
} | ||
[].push.apply(dataByWidgetId[widgetId].watchers, item.watchers); | ||
}); | ||
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.forEach(dataByWidgetId, function (item) { | ||
var time = 0; | ||
var executions = 0; | ||
var noOfFunctions = 0; | ||
var noOfStrings = 0; | ||
item.watchers.forEach(function (entry) { | ||
time += entry[wlKey].time; | ||
executions += entry[wlKey].count; | ||
noOfFunctions += entry[wlKey].type === 'f' ? 1 : 0; | ||
noOfStrings += entry[wlKey].type === 's' ? 1 : 0; | ||
}, 0); | ||
data.push({ | ||
'Widget name': item.context.widgetName || '?', | ||
'Widget id': item.context.widgetId || '?', | ||
'Scope id': item.context.widgetScopeId || item.context.scopeId, | ||
'# functions': noOfFunctions, | ||
'# strings': noOfStrings, | ||
'# total:': noOfFunctions + noOfStrings, | ||
'ms total': toPrecision(time, 3), | ||
'ms average': toPrecision(average(time, executions), 3), | ||
'# of executions': executions | ||
}); | ||
totalWatchFunctions += noOfFunctions; | ||
totalWatchExpressions += noOfStrings; | ||
totalTime += time; | ||
totalExecutions += executions; | ||
}); | ||
data.push({ | ||
'Widget name': '', | ||
'Widget id': '', | ||
'Scope id': 'Total:', | ||
'# functions': totalWatchFunctions, | ||
'# strings': totalWatchExpressions, | ||
'# total:': totalWatchFunctions + totalWatchExpressions, | ||
'ms total': toPrecision(totalTime, 3), | ||
'ms average': toPrecision(average(totalTime, totalExecutions), 3), | ||
'# of executions': totalExecutions | ||
}); | ||
logTabularData(data); | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function consoleLog() { | ||
if (!win.console || !win.console.log) { | ||
return; | ||
} | ||
// MSIE8 does not support console.log.apply( ... ) | ||
// The following call is equivalent to: console.log.apply( console, args ); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
Function.apply.apply(win.console.log, [win.console, args]); | ||
} | ||
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function logTabularData(data) { | ||
if (win.console.table) { | ||
win.console.table(data); | ||
} else { | ||
consoleLog(JSON.stringify(data, null, 2)); | ||
} | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function average(time, count) { | ||
return count > 0 ? time / count : 0; | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function toPrecision(number, precision) { | ||
var factor = precision === 0 ? 1 : Math.pow(10, precision); | ||
return Math.round(number * factor) / factor; | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function flatMap(arr, func) { | ||
return Array.prototype.concat.apply([], arr.map(func)); | ||
} | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular"),require("laxar")):"function"==typeof define&&define.amd?define(["angular","laxar"],t):"object"==typeof exports?exports["laxar-angular-adapter"]=t(require("angular"),require("laxar")):e["laxar-angular-adapter"]=t(e.angular,e.laxar)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist",t(t.s=7)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";var r=n(0),o=n.n(r),i=n(1);n.n(i);n.d(t,"a",function(){return a});var e=o.a.module("axId",[]);e.directive("axId",[function(){return{restrict:"A",link:function(e,t,n){var r=e.$eval(n.axId);i.assert.state(r,"directive axId needs a non-empty local id, e.g. ax-id=\"'myLocalId'\"."),t.attr("id",e.id(r))}}}]);e.directive("axFor",[function(){return{restrict:"A",link:function(e,t,n){var r=e.$eval(n.axFor);i.assert.state(r,"directive axFor needs a non-empty local id, e.g. ax-for=\"'myLocalId'\"."),t.attr("for",e.id(r))}}}]);var a=e.name},function(e,t,n){"use strict";var r=n(0),o=n.n(r);n.d(t,"a",function(){return i});var e=o.a.module("axWidgetArea",[]);e.directive("axWidgetArea",["axWidgetServices",function(e){return{restrict:"A",link:function(t,n,r){var o=r.axWidgetArea;if(!o){if(!r.axWidgetAreaBinding){var i=t.widget&&t.widget.id,a="axWidgetArea: area at "+(i||t.layoutClass)+" has neither a name nor a binding assigned.";throw new Error(a)}o=t.$eval(r.axWidgetAreaBinding)}e(t).axAreaHelper.register(o,n[0])}}}]);var i=e.name},function(e,t,n){"use strict";var r=n(0),o=n.n(r),i=n(1);n.n(i);n.d(t,"a",function(){return u});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=["axGlobalLog",function(e){return function(t,n){for(var r=arguments.length,o=Array(r>2?r-2:0),c=2;c<r;c++)o[c-2]=arguments[c];return"object"!==(void 0===t?"undefined":a(t))?o.length?i.string.format.apply(i.string,[t].concat(o)):t:n&&n.localize?o.length?n.format.apply(n,[t].concat(o)):n.localize(t):void e.warn("axLocalize:i18n cannot localize [0:anonymize]. Pass an AxI18n instance as `i18n`, not [1]",t,n)}}],u=o.a.module("axLocalize",[]).filter("axLocalize",c).name},function(e,t,n){"use strict";function r(e,t,n,r){var u="function"==typeof t,l="function"==typeof n,s=g.items,f=a(e);e.$id in s||(s[e.$id]={context:f,watchers:[]},e.$on("$destroy",function(){o(e),delete s[e.$id]})),f.widgetScopeId&&(f.widgetId in g.widgetIdToScopeId||(g.widgetIdToScopeId[f.widgetId]=f.widgetScopeId));var d={watchFn:{type:u?"f":"s",name:u?c(t)+"()":t,time:0,count:0},listener:{type:l?"f":"s",name:l?c(n)+"()":n,time:0,count:0}};s[e.$id].watchers.push(d);var m=p.call(e,t,n,r),h=e.$$watchers[0];return h.get=i(h.get,d.watchFn),h.fn=i(h.fn,d.listener),function(){m(),o(e)}}function o(e){delete g.items[e.$id],Object.keys(g.widgetIdToScopeId).forEach(function(t){g.widgetIdToScopeId[t]===e.$id&&delete g.widgetIdToScopeId[t]})}function i(e,t){return function(){var n=m.performance.now(),r=e.apply(void 0,arguments),o=m.performance.now()-n;return++t.count,t.time+=o,r}}function a(e){for(var t=e;!t.hasOwnProperty("widget")&&t!==t.$root;)t=t.$parent;var n=!!t.widget;return{widgetName:n?t.widget.path:"",widgetId:n?t.widget.id:"",widgetScopeId:n?t.$id:null,scopeId:e.$id}}function c(e){if(e.name&&"string"==typeof e.name)return e.name;var t=v.exec(e.toString())||[],n=d(t,2),r=n[1];return r?r.trim():"[anonymous]"}function u(){h.log('Available commands:\n\n - help():\n prints this help\n\n - log( [scopeOrWidgetId] ):\n If the argument is omitted this is the same as calling\n logWatchers() first and logListeners() afterwards.\n Otherwise all listeners and watchers of the widget or scope\n with the given id are logged in one table\n\n - logWatchers( [scopeOrWidgetId] ):\n If the argument is omitted the watchers of all scopes belonging to\n a specific widget or of global scopes are logged.\n Otherwise more detailed data for the watchers of the given scope\n or widget are logged.\n\n - logListeners( [scopeOrWidgetId] ):\n If the argument is omitted the listeners of all scopes belonging to\n a specific widget or of global scopes are logged.\n Otherwise more detailed data for the listeners of the given scope\n or widget are logged.\n\n - reset():\n Resets all "# of executions" and millisecond data to zero.')}var l=n(0),s=n.n(l),f=n(8);n.d(t,"a",function(){return y});var d=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),e=s.a.module("axProfiling",["axAngularGlobalServices"]),g=void 0,p=void 0,m=void 0,h=void 0;e.run(["$rootScope","$window","axConfiguration",function(e,t,o){if(o.get("profiling.enabled",!1)){if(m=t,h=n.i(f.a)(t),!m.performance||!m.performance.now)return void h.log("Performance API is not available. Profiling is disabled.");h.log("%c!!! Profiling enabled. Application performance will suffer !!!","font-weight: bold; font-size: 1.2em"),h.log('Type "axProfiling.help()" to get a list of available methods');var i=e.constructor.prototype;g=t.axProfiling={items:{},widgetIdToScopeId:{},logWatchers:function(e){e&&"string"==typeof e?h.logForId(g,"watchFn",e):h.logAll(g,"watchFn")},logListeners:function(e){e&&"string"==typeof e?h.logForId(g,"listener",e):h.logAll(g,"listener")},log:function(e){e&&"string"==typeof e?h.logForId(g,null,e):(h.log("All listeners:"),h.logAll(g,"listener"),h.log("All watchers:"),h.logAll(g,"watchFn"))},reset:function(){Object.keys(g.items).forEach(function(e){g.items[e].watchers.forEach(function(e){e.watchFn.time=0,e.watchFn.count=0,e.listener.time=0,e.listener.count=0})})},help:u},p=i.$watch,i.$watch=function(e,t,n){return r(this,e,t,n||!1)}}}]);var v=/^[ ]*function([^(]*?)\(/,y=e.name},function(e,t,n){"use strict";var r=n(0),o=n.n(r);n.d(t,"a",function(){return i});var e=o.a.module("axVisibilityService",[]);e.factory("axVisibilityService",["axWidgetServices","axHeartbeat",function(e,t){function n(n){function r(){return s.splice(0,s.length),f.splice(0,f.length),l}function o(e){var n=c.isVisible();n!==u&&(u=n,t.onAfterNext(function(){(e?s:f).forEach(function(t){return t(e)})}))}function i(e,t){(t?s:f).push(e),t&&c.isVisible()===t&&e(t)}var a=e(n),c=a.axVisibility;c.onChange(o),n.$on("$destroy",function(){c.unsubscribe(o)});var u=c.isVisible(),l={isVisible:function(){return c.isVisible()},onChange:function(e){return i(e,!0),i(e,!1),l},onShow:function(e){return i(e,!0),l},onHide:function(e){return i(e,!1),l},clear:r},s=[],f=[];return l}return{handlerFor:n}}]);var i=e.name},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){function n(){return{axGlobalEventBus:i,axEventBus:i,axContext:function(e){return u.a.extend(w.$new(),e)}}}function o(e){function t(e,t){if(null!==t){u.a.element(i).html(t),e.appendChild(i),b(i)(l),w.$$phase||l.$digest()}}function n(){var e=i.parentNode;e&&e.removeChild(i)}function r(){l.$destroy(),delete $[s]}var o=e.widgetName,i=e.anchorElement,a=e.services,c=e.provideServices,l=a.axContext,s=l.widget.id;return $[s]=a,function(){var e=S[o];a.$scope=l,c(a),x(e,a)}(),{domAttachTo:t,domDetach:n,destroy:r}}function i(e){function t(e){return e.then=function(t,r){return Promise.prototype.then.call(e,n(t),n(r))},e}function n(e){return"function"!=typeof e?e:function(){try{return e.apply(void 0,arguments)}finally{w.$evalAsync(function(){})}}}var r=Object.create(e);return r.publish=function(){return t(e.publish.apply(e,arguments))},r.publishAndGatherReplies=function(){return t(e.publishAndGatherReplies.apply(e,arguments))},r}function c(){return function(e){for(var t=e,n=null;!n&&t;){if(t.widget&&"string"==typeof t.widget.id){n=t.widget.id;break}t=t.$parent}l.assert.state(n,"No widget context found in given scope or one of its parents.");var r=$[n];return l.assert.state(r,"No services found for widget with id "+n+"."),r}}var v=e.widgets,I=e.controls,A={create:o,serviceDecorators:n},S={};v.forEach(function(e){var t=e.descriptor,n=e.module;S[t.name]=a(n.name)+"Controller"});var $={};y||(y=!0,function(){u.a.module(m,[]).factory("axConfiguration",function(){return t.configuration}).factory("axGlobalEventBus",function(){return i(t.globalEventBus)}).factory("axGlobalLog",function(){return t.log}).factory("axGlobalStorage",function(){return t.storage}).factory("axHeartbeat",function(){return t.heartbeat}).factory("axTooling",function(){return t.tooling}).factory("axWidgetServices",function(){return c()})}(),function(){var e=[m,s.a,f.a,p.a,d.a,g.a],n=v.concat(I).map(function(e){return e.module.name});u.a.module(h,[].concat(e,r(n))).run(["$compile","$controller","$rootScope",function(e,t,n){x=t,b=e,w=n}]).factory("$exceptionHandler",function(){return function(e,n){var r=e.message||e;t.log.error("There was an exception: "+r+", \nstack: "+e.stack+", \n, Cause: "+n)}})}()),u.a.mock&&(u.a.mock.module(m),u.a.mock.module(h),v.concat(I).forEach(function(e){u.a.mock.module(e.module.name)})),t.heartbeat.registerHeartbeatListener(function(){w.$digest()});var E=document.createElement("DIV");return E.style.display="none",document.body.appendChild(E),u.a.bootstrap(E,[h]),A}function i(){y=!1}function a(e){return e.replace(/^./,function(e){return e.toUpperCase()})}Object.defineProperty(t,"__esModule",{value:!0});var c=n(0),u=n.n(c),l=n(1),s=(n.n(l),n(2)),f=n(3),d=n(5),g=n(6),p=n(4);n.d(t,"ANGULAR_SERVICES_MODULE_NAME",function(){return m}),n.d(t,"ANGULAR_MODULE_NAME",function(){return h}),n.d(t,"technology",function(){return v}),t.bootstrap=o,t.reset=i;var m="axAngularGlobalServices",h="axAngularWidgetAdapter",v="angular",y=!1,w=void 0,x=void 0,b=void 0},function(e,t,n){"use strict";function r(e){function t(e,t,n){var s=e.items,f=!!n.match(/^[A-Za-z0-9]{3}$/)&&n in s,d=n,g=[];f?g=s[n].watchers:(d=e.widgetIdToScopeId[n],g=a(Object.keys(s).map(function(e){return s[e]}).filter(function(e){return e.context.widgetId===n}),function(e){return e.watchers}));var p=[].slice.call(l.document.getElementsByClassName("ng-scope"),0).concat([l.document]).map(function(e){return{element:e,scope:u.a.element(e).scope()}}).filter(function(e){return e.scope.$id===d})[0]||null;r('Showing details for %s with id "%s"',f?"scope":"widget",n),p&&r("Context: Scope: %o, Element %o",p.scope,p.element),c(g.map(function(e){var n={};if(!t||"watchFn"===t){var r=e.watchFn;n.Watcher=r.name,n["Watcher ms total"]=i(r.time,3),n["Watcher ms average"]=i(o(r.time,r.count),3),n["Watcher # executions"]=r.count}if(!t||"listener"===t){var a=e.listener;n.Listener=a.name,n["Listener ms total"]=i(a.time,3),n["Listener ms average"]=i(o(a.time,a.count),3),n["Listener # executions"]=a.count}return n}))}function n(e,t){var n=e.items,r=[],a=0,l=0,s=0,f=0,d={};u.a.forEach(n,function(e,t){var n=e.context.widgetId;if(!n)return void(d[t]=e);n in d||(d[n]={context:e.context,watchers:[]}),[].push.apply(d[n].watchers,e.watchers)}),u.a.forEach(d,function(e){var n=0,c=0,u=0,d=0;e.watchers.forEach(function(e){n+=e[t].time,c+=e[t].count,u+="f"===e[t].type?1:0,d+="s"===e[t].type?1:0},0),r.push({"Widget name":e.context.widgetName||"?","Widget id":e.context.widgetId||"?","Scope id":e.context.widgetScopeId||e.context.scopeId,"# functions":u,"# strings":d,"# total:":u+d,"ms total":i(n,3),"ms average":i(o(n,c),3),"# of executions":c}),a+=u,l+=d,s+=n,f+=c}),r.push({"Widget name":"","Widget id":"","Scope id":"Total:","# functions":a,"# strings":l,"# total:":a+l,"ms total":i(s,3),"ms average":i(o(s,f),3),"# of executions":f}),c(r)}function r(){if(l.console&&l.console.log){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];Function.apply.apply(l.console.log,[l.console,t])}}function c(e){l.console.table?l.console.table(e):r(JSON.stringify(e,null,2))}var l=e;return{log:r,logForId:t,logAll:n}}function o(e,t){return t>0?e/t:0}function i(e,t){var n=0===t?1:Math.pow(10,t);return Math.round(e*n)/n}function a(e,t){return Array.prototype.concat.apply([],e.map(t))}var c=n(0),u=n.n(c);t.a=r}])}); | ||
//# sourceMappingURL=laxar-angular-adapter.js.map |
@@ -7,42 +7,17 @@ /** | ||
/* eslint-env node */ | ||
const laxarInfrastructure = require( 'laxar-infrastructure' ); | ||
const webpackConfig = Object.assign( {}, require('./webpack.config' ) ); | ||
delete webpackConfig.entry; | ||
webpackConfig.devtool = 'inline-source-map'; | ||
module.exports = function( config ) { | ||
const specPattern = process.argv.pop(); | ||
// eslint-disable-next-line | ||
console.log( 'Running with karma:', specPattern ); | ||
config.set( karmaConfig( specPattern ) ); | ||
}; | ||
module.exports = function(config) { | ||
const browsers = [ 'PhantomJS', 'Firefox' ].concat( [ | ||
process.env.TRAVIS ? 'ChromeTravisCi' : 'Chrome' | ||
] ); | ||
config.set( { | ||
frameworks: [ 'jasmine' ], | ||
files: [ | ||
// require.resolve( 'laxar/dist/polyfills' ), | ||
'lib/**/spec/spec-runner.js', | ||
'spec/spec-runner.js' | ||
], | ||
preprocessors: { | ||
'lib/**/spec/spec-runner.js': [ 'webpack', 'sourcemap' ], | ||
'spec/spec-runner.js': [ 'webpack', 'sourcemap' ] | ||
}, | ||
webpack: webpackConfig, | ||
reporters: [ 'progress', 'junit' ], | ||
junitReporter: { | ||
outputDir: 'karma-output/' | ||
}, | ||
port: 9876, | ||
browsers, | ||
customLaunchers: { | ||
ChromeTravisCi: { | ||
base: 'Chrome', | ||
flags: [ '--no-sandbox' ] | ||
} | ||
}, | ||
browserNoActivityTimeout: 100000, | ||
singleRun: true, | ||
autoWatch: false, | ||
concurrency: Infinity | ||
function karmaConfig( specPattern ) { | ||
return laxarInfrastructure.karma( [ specPattern ], { | ||
context: __dirname, | ||
module: require( './webpack.config' )[ 0 ].module | ||
} ); | ||
}; | ||
} |
@@ -265,5 +265,2 @@ /** | ||
injectorCreated = false; | ||
if( typeof window.Promise._reset === 'function' ) { | ||
window.Promise._reset(); | ||
} | ||
} | ||
@@ -270,0 +267,0 @@ |
@@ -9,3 +9,3 @@ /** | ||
import 'angular-mocks'; | ||
import { createAxConfigurationMock } from 'laxar-widget-service-mocks'; | ||
import { createAxConfigurationMock } from 'laxar/laxar-widget-service-mocks'; | ||
@@ -12,0 +12,0 @@ const { module, inject } = window; |
@@ -12,3 +12,3 @@ /** | ||
createAxVisibilityMock | ||
} from 'laxar-widget-service-mocks'; | ||
} from 'laxar/laxar-widget-service-mocks'; | ||
@@ -15,0 +15,0 @@ const { module, inject } = window; |
{ | ||
"name": "laxar-angular-adapter", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-rc.0", | ||
"description": "Write LaxarJS widgets and controls with AngularJS", | ||
@@ -9,9 +9,12 @@ "main": "laxar-angular-adapter.js", | ||
"prepublish": "npm run dist", | ||
"test": "grunt test && npm run eslint", | ||
"browser-spec": "npm run browser-spec-build && npm run browser-spec-start", | ||
"dist": "cross-env NODE_ENV=production webpack", | ||
"browser-spec-build": "cross-env NODE_ENV=browser-spec webpack", | ||
"browser-spec-start": "cross-env NODE_ENV=browser-spec webpack-dev-server --port 8085 --inline", | ||
"karma": "karma start karma.config.js", | ||
"eslint": "eslint laxar-angular-adapter.js *.config.js lib spec" | ||
"test": "npm run karma && npm run eslint", | ||
"dist": "webpack -p", | ||
"start": "webpack && webpack-dev-server --inline", | ||
"karma": "npm run karma-main && npm run karma-directives && npm run karma-filters && npm run karma-profiling && npm run karma-services", | ||
"karma-main": "karma start karma.config.js spec/laxar-angular-adapter.spec.js", | ||
"karma-directives": "karma start karma.config.js lib/directives/spec/spec-runner.js", | ||
"karma-filters": "karma start karma.config.js lib/filters/spec/spec-runner.js", | ||
"karma-profiling": "karma start karma.config.js lib/profiling/spec/spec-runner.js", | ||
"karma-services": "karma start karma.config.js lib/services/spec/spec-runner.js", | ||
"eslint": "eslint *.js lib spec" | ||
}, | ||
@@ -22,8 +25,6 @@ "repository": { | ||
}, | ||
"dependencies": { | ||
"page": "^1.7.1" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"angular": "^1.5.7", | ||
"laxar": "^2.0.0-alpha.19" | ||
"laxar": "^2.0.0" | ||
}, | ||
@@ -49,23 +50,14 @@ "keywords": [ | ||
"babel-preset-es2015": "^6.18.0", | ||
"cross-env": "^3.1.4", | ||
"eslint": "^3.13.1", | ||
"eslint-config-laxarjs": "^0.3.0", | ||
"grunt": "^1.0.1", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "~1.0.0", | ||
"grunt-karma": "^2.0.0", | ||
"jasmine-core": "~2.5.2", | ||
"karma": "^1.4.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-junit-reporter": "^1.2.0", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^2.0.1", | ||
"laxar": "^2.0.0-alpha.14", | ||
"webpack": "^2.2.0", | ||
"webpack-dev-server": "^2.2.0", | ||
"eslint": "^3.18.0", | ||
"eslint-config-laxarjs": "^0.4.0", | ||
"karma": "^1.5.0", | ||
"laxar": "^2.0.0-alpha.20", | ||
"laxar-infrastructure": "^2.0.0", | ||
"laxar-loader": "^2.0.0", | ||
"webpack": "^2.4.1", | ||
"webpack-dev-server": "^2.5.0", | ||
"webpack-jasmine-html-runner-plugin": "^0.7.0" | ||
} | ||
} |
@@ -216,1 +216,35 @@ # laxar-angular-adapter [](https://travis-ci.org/LaxarJS/laxar-angular-adapter) | ||
- when `eventBus.flush()` is run to trigger event bus delivery, a `$rootScope.$digest` is automatically initiated afterwards. | ||
## Hacking the Adapter | ||
First, clone the repository and fetch the dependencies: | ||
```console | ||
git clone https://github.com/LaxarJS/laxar-angular-adapter.git | ||
cd laxar-angular-adapter | ||
npm install | ||
``` | ||
To rebuild the _pre-compiled bundle_, use: | ||
```console | ||
npm run dist | ||
``` | ||
Otherwise, you may need to adjust your project to load the adapter with ES2015 support. | ||
To pick up clone from within a LaxarJS application, you may need to modify the project's webpack resolve configuration. | ||
To _test_ the adapter, run: | ||
```console | ||
npm test | ||
``` | ||
For interactive tests that can be inspected in the browser, run: | ||
```console | ||
npm start | ||
``` | ||
Now you can access the spec-tests at http://localhost:8080/dist/spec/laxar-angular-adapter.spec.html |
@@ -12,3 +12,3 @@ /** | ||
createAxLogMock | ||
} from 'laxar-widget-service-mocks'; | ||
} from 'laxar/laxar-widget-service-mocks'; | ||
import { technology, bootstrap, reset, ANGULAR_MODULE_NAME } from '../laxar-angular-adapter'; | ||
@@ -15,0 +15,0 @@ import widgetData from './widget_data'; |
@@ -9,22 +9,6 @@ /** | ||
const path = require( 'path' ); | ||
const webpack = require( 'webpack' ); | ||
const pkg = require( './package.json' ); | ||
const nodeEnv = process.env.NODE_ENV; | ||
const isProduction = nodeEnv === 'production'; | ||
const isBrowserSpec = nodeEnv === 'browser-spec'; | ||
const name = require( './package.json' ).name; | ||
const externals = { | ||
'laxar': 'laxar', | ||
'angular': 'angular' | ||
}; | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
const baseConfig = { | ||
resolve: { | ||
alias: { | ||
'laxar-widget-service-mocks': 'laxar/dist/laxar-widget-service-mocks' | ||
} | ||
}, | ||
const webpack = require( 'laxar-infrastructure' ).webpack( { | ||
context: __dirname, | ||
module: { | ||
@@ -34,3 +18,8 @@ rules: [ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
include: [ | ||
path.resolve( __dirname, pkg.main ), | ||
path.resolve( __dirname, 'lib/' ), | ||
path.resolve( __dirname, 'spec/' ), | ||
path.resolve( __dirname, 'node_modules/laxar/' ) | ||
], | ||
loader: 'babel-loader' | ||
@@ -40,69 +29,13 @@ } | ||
} | ||
}; | ||
} ); | ||
const config = isProduction ? distConfig() : baseConfig; | ||
if( isBrowserSpec ) { | ||
const WebpackJasmineHtmlRunnerPlugin = require( 'webpack-jasmine-html-runner-plugin' ); | ||
config.entry = WebpackJasmineHtmlRunnerPlugin.entry( | ||
'./spec/spec-runner.js', | ||
'./lib/*/spec/spec-runner.js' | ||
); | ||
config.plugins = [ new WebpackJasmineHtmlRunnerPlugin() ]; | ||
config.output = { | ||
path: path.resolve( path.join( process.cwd(), 'spec-output' ) ), | ||
publicPath: '/spec-output/', | ||
filename: '[name].bundle.js' | ||
}; | ||
} | ||
module.exports = config; | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function distConfig() { | ||
return [ | ||
distConfigItem( `./${name}.js`, `./${name}.js` ), | ||
distConfigItem( `./${name}.js`, `./${name}.min.js`, { minify: true } ) | ||
]; | ||
function distConfigItem( entry, output, optionalOptions ) { | ||
const options = Object.assign( { | ||
minify: false, | ||
externals | ||
}, optionalOptions || {} ); | ||
const config = Object.assign( {}, baseConfig ); | ||
config.entry = entry; | ||
config.output = { | ||
path: path.resolve( __dirname ), | ||
filename: `dist/${output}`, | ||
library: name, | ||
libraryTarget: 'umd', | ||
umdNamedDefine: true | ||
}; | ||
config.externals = options.externals; | ||
config.plugins = [ | ||
new webpack.SourceMapDevToolPlugin( { | ||
filename: `dist/${output}.map` | ||
} ) | ||
]; | ||
if( options.minify ) { | ||
config.plugins.push( | ||
new webpack.optimize.UglifyJsPlugin( { | ||
compress: { warnings: false }, | ||
sourceMap: true | ||
} ) | ||
); | ||
} | ||
return config; | ||
} | ||
} | ||
module.exports = [ | ||
webpack.library(), | ||
webpack.browserSpec( [ | ||
`./spec/${pkg.name}.spec.js`, | ||
'lib/directives/spec/spec-runner.js', | ||
'lib/filters/spec/spec-runner.js', | ||
'lib/profiling/spec/spec-runner.js', | ||
'lib/services/spec/spec-runner.js' | ||
] ) | ||
]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
-33.33%15
-42.31%250
15.74%0
-100%375998
-6.98%32
-11.11%2015
-37.94%- Removed
- Removed
- Removed
- Removed