Skip to content

Commit

Permalink
prep for 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed May 3, 2017
1 parent 4fb1e95 commit 3425a59
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 252 deletions.
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "ui-router-sticky-states",
"name": "@uirouter/sticky-states",
"description": "UI-Router Sticky States: Keep states and their components alive while a different state is activated",
"version": "1.3.0",
"scripts": {
"clean": "shx rm -rf lib lib-esm",
"build": "npm run clean && tsc && tsc -m es6 -outDir lib-esm",
"build": "npm run clean && tsc && tsc -m es6 -outDir lib-esm && npm run bundle",
"bundle": "rollup -c",
"test": "karma start",
"watch": "run-p watch:*",
"watch:buildjs": "tsc -w",
Expand All @@ -27,10 +28,10 @@
],
"repository": {
"type": "git",
"url": "https://github.com/ui-router/dsr.git"
"url": "https://github.com/ui-router/sticky-states.git"
},
"bugs": {
"url": "https://github.com/ui-router/dsr/issues"
"url": "https://github.com/ui-router/sticky-states/issues"
},
"engines": {
"node": ">=4.0.0"
Expand All @@ -40,14 +41,15 @@
"typings": "lib/index.d.ts",
"license": "MIT",
"peerDependencies": {
"ui-router-core": "^5.0.0"
"@uirouter/core": "^5.0.1"
},
"devDependencies": {
"@types/angular": "^1.5.20",
"@types/angular-mocks": "^1.5.6",
"@types/jasmine": "^2.2.34",
"@types/jquery": "^1.10.31",
"@types/lodash": "^4.14.38",
"@uirouter/core": "^5.0.1",
"angular": "^1.5.8",
"angular-mocks": "^1.5.8",
"awesome-typescript-loader": "3.0.0-beta.18",
Expand All @@ -72,8 +74,14 @@
"ts-loader": "^2.0.0",
"tslint": "=2.5.0",
"typescript": "^2.1.1",
"ui-router-core": "^5.0.0",
"webpack": "^1.13.3",
"webpack-beep-plugin": "0.0.1"
},
"dependencies": {
"rollup": "^0.41.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-progress": "^0.2.1",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-uglify": "^1.0.2"
}
}
47 changes: 47 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';

var MINIFY = process.env.MINIFY;

var pkg = require('./package.json');
var banner =
`/**
* ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;

var uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) =>
comment.type === 'comment2' && /@license/i.test(comment.value);

var plugins = [
nodeResolve({jsnext: true}),
progress(),
sourcemaps(),
];

if (MINIFY) plugins.push(uglify(uglifyOpts));

var extension = MINIFY ? ".min.js" : ".js";

const CONFIG = {
moduleName: pkg.name,
entry: 'lib-esm/stickyStates.js',
dest: 'bundles/ui-router-sticky-states' + extension,
external: '@uirouter/core',
globals: { '@uirouter/core': '@uirouter/core' },


sourceMap: true,
format: 'umd',
exports: 'named',
plugins: plugins,
banner: banner,
};

export default CONFIG;
16 changes: 8 additions & 8 deletions src/stickyStates.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import {
UIRouter, PathFactory, StateOrName, StateObject, StateDeclaration, PathNode, TreeChanges, Transition, UIRouterPluginBase,
UIRouter, PathUtils, StateOrName, StateObject, StateDeclaration, PathNode, TreeChanges, Transition, UIRouterPluginBase,
TransitionHookPhase, TransitionHookScope, TransitionServicePluginAPI, HookMatchCriteria, TransitionStateHookFn,
HookRegOptions, PathType, find, tail, isString, isArray, inArray, removeFrom, pushTo, identity, anyTrueR, assertMap,
uniqR, defaultTransOpts, HookMatchCriterion
} from "ui-router-core";
} from "@uirouter/core";

declare module "ui-router-core/lib/state/interface" {
declare module "@uirouter/core/lib/state/interface" {
interface StateDeclaration {
sticky?: boolean;
onInactivate?: TransitionStateHookFn;
onReactivate?: TransitionStateHookFn;
}
}

declare module "ui-router-core/lib/state/stateObject" {
declare module "@uirouter/core/lib/state/stateObject" {
interface StateObject {
sticky?: boolean;
onInactivate?: TransitionStateHookFn;
onReactivate?: TransitionStateHookFn;
}
}

declare module "ui-router-core/lib/transition/transitionService" {
declare module "@uirouter/core/lib/transition/transitionService" {
interface TransitionService {
onInactivate: (criteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions) => Function;
onReactivate: (criteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions) => Function;
}
}

declare module "ui-router-core/lib/transition/interface" {
declare module "@uirouter/core/lib/transition/interface" {
interface TransitionOptions {
exitSticky: StateOrName[]|StateOrName;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ function nodeDepthThenInactivateOrder(inactives: PathNode[]) {
};
}
export class StickyStatesPlugin extends UIRouterPluginBase {
name = "stickystates";
name = "sticky-states";
private _inactives: PathNode[] = [];
private pluginAPI: TransitionServicePluginAPI;

Expand Down Expand Up @@ -194,7 +194,7 @@ export class StickyStatesPlugin extends UIRouterPluginBase {
// Simulate a transition where the fromPath is a clone of the toPath, but use the inactivated nodes
// This will calculate which inactive nodes that need to be exited/entered due to param changes
let inactiveFromPath = tc.retained.concat(tc.entering.map(node => this._getInactive(node) || null)).filter(identity);
let simulatedTC = PathFactory.treeChanges(inactiveFromPath, tc.to, trans.options().reloadState);
let simulatedTC = PathUtils.treeChanges(inactiveFromPath, tc.to, trans.options().reloadState);

let shouldRewritePaths = ['retained', 'entering', 'exiting'].some(path => !!simulatedTC[path].length);

Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// current directory and all subdirectories

require('core-js');
require('ui-router-core');
require('@uirouter/core');
require('../src/stickyStates');

var testsContext = require.context(".", true, /Spec$/);
Expand Down
4 changes: 2 additions & 2 deletions test/stickySpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { getTestGoFn, addCallbacks, resetTransitionLog, pathFrom, equalityTester
import {
UIRouter, StateService, StateRegistry, StateDeclaration, ViewService, TransitionService, PathNode, _ViewDeclaration,
isObject, ViewConfigFactory, ViewConfig
} from "ui-router-core";
} from "@uirouter/core";
import "../src/stickyStates";
import { StickyStatesPlugin } from "../src/stickyStates";
import { memoryLocationPlugin, servicesPlugin } from 'ui-router-core/lib/vanilla';
import { memoryLocationPlugin, servicesPlugin } from '@uirouter/core/lib/vanilla';

let router: UIRouter;
let $state: StateService;
Expand Down
Loading

0 comments on commit 3425a59

Please sign in to comment.