@angular-wave/angular.ts 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/package.json +1 -1
  4. package/src/exts/messages.md +30 -30
  5. package/src/router/adapter/directives/stateDirectives.js +14 -23
  6. package/src/router/adapter/directives/viewDirective.js +34 -44
  7. package/src/router/adapter/locationServices.js +3 -5
  8. package/src/router/adapter/services.js +9 -16
  9. package/src/router/adapter/stateFilters.js +2 -7
  10. package/src/router/adapter/templateFactory.js +1 -1
  11. package/src/router/adapter/viewScroll.js +1 -8
  12. package/src/router/core/common/common.js +1 -11
  13. package/src/router/core/hooks/coreResolvables.js +2 -2
  14. package/src/router/core/path/pathUtils.js +1 -2
  15. package/src/router/core/router.js +4 -2
  16. package/src/router/core/state/stateBuilder.js +2 -3
  17. package/src/router/core/state/stateMatcher.js +1 -2
  18. package/src/router/core/state/stateObject.js +7 -6
  19. package/src/router/core/state/stateQueueManager.js +1 -1
  20. package/src/router/core/transition/hookRegistry.js +3 -10
  21. package/src/router/core/transition/transitionService.js +2 -2
  22. package/src/router/router.js +43 -19
  23. package/test/module-test.html +18 -11
  24. package/test/module-test.js +0 -0
  25. package/test/ng/directive/if.spec.js +0 -1
  26. package/test/original-test.html +27 -15
  27. package/src/router/adapter/urlRouterProvider.js +0 -196
  28. package/src/router/core/vanilla/baseLocationService.js +0 -31
  29. package/src/router/core/vanilla/browserLocationConfig.js +0 -42
  30. package/src/router/core/vanilla/hashLocationService.js +0 -19
  31. package/src/router/core/vanilla/injector.js +0 -98
  32. package/src/router/core/vanilla/interface.js +0 -1
  33. package/src/router/core/vanilla/memoryLocationConfig.js +0 -20
  34. package/src/router/core/vanilla/memoryLocationService.js +0 -13
  35. package/src/router/core/vanilla/plugins.js +0 -35
  36. package/src/router/core/vanilla/pushStateLocationService.js +0 -69
  37. package/src/router/core/vanilla/q.js +0 -54
  38. package/src/router/core/vanilla/utils.js +0 -63
@@ -1,35 +0,0 @@
1
- import { BrowserLocationConfig } from "./browserLocationConfig";
2
- import { HashLocationService } from "./hashLocationService";
3
- import { locationPluginFactory } from "./utils";
4
- import { PushStateLocationService } from "./pushStateLocationService";
5
- import { MemoryLocationService } from "./memoryLocationService";
6
- import { MemoryLocationConfig } from "./memoryLocationConfig";
7
- import { $injector } from "./injector";
8
- import { $q } from "./q";
9
- import { services } from "../common/coreservices";
10
- export function servicesPlugin(router) {
11
- services.$injector = $injector;
12
- services.$q = $q;
13
- return { name: "vanilla.services", $q, $injector, dispose: () => null };
14
- }
15
- /** A `UIRouterPlugin` uses the browser hash to get/set the current location */
16
- export const hashLocationPlugin = locationPluginFactory(
17
- "vanilla.hashBangLocation",
18
- false,
19
- HashLocationService,
20
- BrowserLocationConfig,
21
- );
22
- /** A `UIRouterPlugin` that gets/sets the current location using the browser's `location` and `history` apis */
23
- export const pushStateLocationPlugin = locationPluginFactory(
24
- "vanilla.pushStateLocation",
25
- true,
26
- PushStateLocationService,
27
- BrowserLocationConfig,
28
- );
29
- /** A `UIRouterPlugin` that gets/sets the current location from an in-memory object */
30
- export const memoryLocationPlugin = locationPluginFactory(
31
- "vanilla.memoryLocation",
32
- false,
33
- MemoryLocationService,
34
- MemoryLocationConfig,
35
- );
@@ -1,69 +0,0 @@
1
- import { BaseLocationServices } from "./baseLocationService";
2
- import {
3
- root,
4
- splitHash,
5
- splitQuery,
6
- stripLastPathElement,
7
- } from "../common/index";
8
- /**
9
- * A `LocationServices` that gets/sets the current location using the browser's `location` and `history` apis
10
- *
11
- * Uses `history.pushState` and `history.replaceState`
12
- */
13
- export class PushStateLocationService extends BaseLocationServices {
14
- constructor(router) {
15
- super(router, true);
16
- this._config = router.urlService.config;
17
- root.addEventListener("popstate", this._listener, false);
18
- }
19
- /**
20
- * Gets the base prefix without:
21
- * - trailing slash
22
- * - trailing filename
23
- * - protocol and hostname
24
- *
25
- * If <base href='/base/'>, this returns '/base'.
26
- * If <base href='/foo/base/'>, this returns '/foo/base'.
27
- * If <base href='/base/index.html'>, this returns '/base'.
28
- * If <base href='http://localhost:8080/base/index.html'>, this returns '/base'.
29
- * If <base href='/base'>, this returns ''.
30
- * If <base href='http://localhost:8080'>, this returns ''.
31
- * If <base href='http://localhost:8080/'>, this returns ''.
32
- *
33
- * See: https://html.spec.whatwg.org/dev/semantics.html#the-base-element
34
- */
35
- _getBasePrefix() {
36
- return stripLastPathElement(this._config.baseHref());
37
- }
38
- _get() {
39
- let { pathname, hash, search } = this._location;
40
- search = splitQuery(search)[1]; // strip ? if found
41
- hash = splitHash(hash)[1]; // strip # if found
42
- const basePrefix = this._getBasePrefix();
43
- const exactBaseHrefMatch = pathname === this._config.baseHref();
44
- const startsWithBase = pathname.substr(0, basePrefix.length) === basePrefix;
45
- pathname = exactBaseHrefMatch
46
- ? "/"
47
- : startsWithBase
48
- ? pathname.substring(basePrefix.length)
49
- : pathname;
50
- return pathname + (search ? "?" + search : "") + (hash ? "#" + hash : "");
51
- }
52
- _set(state, title, url, replace) {
53
- const basePrefix = this._getBasePrefix();
54
- const slash = url && url[0] !== "/" ? "/" : "";
55
- const fullUrl =
56
- url === "" || url === "/"
57
- ? this._config.baseHref()
58
- : basePrefix + slash + url;
59
- if (replace) {
60
- this._history.replaceState(state, title, fullUrl);
61
- } else {
62
- this._history.pushState(state, title, fullUrl);
63
- }
64
- }
65
- dispose(router) {
66
- super.dispose(router);
67
- root.removeEventListener("popstate", this._listener);
68
- }
69
- }
@@ -1,54 +0,0 @@
1
- import { isArray, isObject } from "../common/index";
2
- /**
3
- * An angular1-like promise api
4
- *
5
- * This object implements four methods similar to the
6
- * [angular 1 promise api](https://docs.angularjs.org/api/ng/service/$q)
7
- *
8
- * UI-Router evolved from an angular 1 library to a framework agnostic library.
9
- * However, some of the `@uirouter/core` code uses these ng1 style APIs to support ng1 style dependency injection.
10
- *
11
- * This API provides native ES6 promise support wrapped as a $q-like API.
12
- * Internally, UI-Router uses this $q object to perform promise operations.
13
- * The `angular-ui-router` (ui-router for angular 1) uses the $q API provided by angular.
14
- *
15
- * $q-like promise api
16
- */
17
- export const $q = {
18
- /** Normalizes a value as a promise */
19
- when: (val) => new Promise((resolve, reject) => resolve(val)),
20
- /** Normalizes a value as a promise rejection */
21
- reject: (val) =>
22
- new Promise((resolve, reject) => {
23
- reject(val);
24
- }),
25
- /** @returns a deferred object, which has `resolve` and `reject` functions */
26
- defer: () => {
27
- const deferred = {};
28
- deferred.promise = new Promise((resolve, reject) => {
29
- deferred.resolve = resolve;
30
- deferred.reject = reject;
31
- });
32
- return deferred;
33
- },
34
- /** Like Promise.all(), but also supports object key/promise notation like $q */
35
- all: (promises) => {
36
- if (isArray(promises)) {
37
- return Promise.all(promises);
38
- }
39
- if (isObject(promises)) {
40
- // Convert promises map to promises array.
41
- // When each promise resolves, map it to a tuple { key: key, val: val }
42
- const chain = Object.keys(promises).map((key) =>
43
- promises[key].then((val) => ({ key, val })),
44
- );
45
- // Then wait for all promises to resolve, and convert them back to an object
46
- return $q.all(chain).then((values) =>
47
- values.reduce((acc, tuple) => {
48
- acc[tuple.key] = tuple.val;
49
- return acc;
50
- }, {}),
51
- );
52
- }
53
- },
54
- };
@@ -1,63 +0,0 @@
1
- import {
2
- identity,
3
- unnestR,
4
- isArray,
5
- splitEqual,
6
- splitHash,
7
- splitQuery,
8
- } from "../common/index";
9
- export const keyValsToObjectR = (accum, [key, val]) => {
10
- if (!accum.hasOwnProperty(key)) {
11
- accum[key] = val;
12
- } else if (isArray(accum[key])) {
13
- accum[key].push(val);
14
- } else {
15
- accum[key] = [accum[key], val];
16
- }
17
- return accum;
18
- };
19
- export const getParams = (queryString) =>
20
- queryString
21
- .split("&")
22
- .filter(identity)
23
- .map(splitEqual)
24
- .reduce(keyValsToObjectR, {});
25
- export function parseUrl(url) {
26
- const orEmptyString = (x) => x || "";
27
- const [beforehash, hash] = splitHash(url).map(orEmptyString);
28
- const [path, search] = splitQuery(beforehash).map(orEmptyString);
29
- return { path, search, hash, url };
30
- }
31
- export const buildUrl = (loc) => {
32
- const path = loc.path();
33
- const searchObject = loc.search();
34
- const hash = loc.hash();
35
- const search = Object.keys(searchObject)
36
- .map((key) => {
37
- const param = searchObject[key];
38
- const vals = isArray(param) ? param : [param];
39
- return vals.map((val) => key + "=" + val);
40
- })
41
- .reduce(unnestR, [])
42
- .join("&");
43
- return path + (search ? "?" + search : "") + (hash ? "#" + hash : "");
44
- };
45
- export function locationPluginFactory(
46
- name,
47
- isHtml5,
48
- serviceClass,
49
- configurationClass,
50
- ) {
51
- return function (uiRouter) {
52
- const service = (uiRouter.locationService = new serviceClass(uiRouter));
53
- const configuration = (uiRouter.locationConfig = new configurationClass(
54
- uiRouter,
55
- isHtml5,
56
- ));
57
- function dispose(router) {
58
- router.dispose(service);
59
- router.dispose(configuration);
60
- }
61
- return { name, service, configuration, dispose };
62
- };
63
- }