-
Notifications
You must be signed in to change notification settings - Fork 138
Standalone applications support #994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
df25acb
Updated uiSref directive to be an standalone directive
lindolo25 e89800e
Updated uiSrefActive directive to be a standalone directive
lindolo25 ec0f518
Updated uiSrefStatus directive to be a standalone directive
lindolo25 97cc602
Updated uiView component to be a standalone component
lindolo25 4a8d1bb
Imported directives instead of declaring them in UIRouterModule
lindolo25 45d4103
Created a root provider function for UIRouter.
lindolo25 5e3de9b
Fixed bug in uiView component not loading the CommonModule.
lindolo25 2955b86
Updated downstream sample app for the tests.
lindolo25 11fb548
Updated UISrefActive to use hostDirectives to implement the UISrefSta…
lindolo25 f3e91c2
Added provideUiRouter to global exports.
lindolo25 22a86b1
added a standalone v18 test project.
lindolo25 6942ca9
Added standalone version for downstream projects.
lindolo25 810ea5b
Updated package minor version
lindolo25 749a695
Add documentation for provideUIRouter() function.
lindolo25 6318576
Revert "Updated downstream sample app for the tests."
lindolo25 e765688
updated package version from 14.1.0 to 15.0.0. This change is introdu…
lindolo25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { EnvironmentProviders, makeEnvironmentProviders } from "@angular/core"; | ||
import { locationStrategy, makeRootProviders, RootModule } from "./uiRouterNgModule"; | ||
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from "./providers"; | ||
|
||
/** | ||
* Sets up providers necessary to enable UI-Router for the application. Intended as a replacement | ||
* for [[UIRouterModule.forRoot]] in newer standalone based applications. | ||
* | ||
* Example: | ||
* ```js | ||
* const routerConfig = { | ||
* otherwise: '/home', | ||
* states: [homeState, aboutState] | ||
* }; | ||
* | ||
* const appConfig: ApplicationConfig = { | ||
* providers: [ | ||
* provideZoneChangeDetection({ eventCoalescing: true }), | ||
* provideUIRouter(routerConfig) | ||
* ] | ||
* }; | ||
* | ||
* bootstrapApplication(AppComponent, appConfig) | ||
* .catch((err) => console.error(err)); | ||
* ``` | ||
* | ||
* @param config declarative UI-Router configuration | ||
* @returns an `EnvironmentProviders` which provides the [[UIRouter]] singleton instance | ||
*/ | ||
export function provideUIRouter(config: RootModule = {}): EnvironmentProviders { | ||
return makeEnvironmentProviders([ | ||
_UIROUTER_INSTANCE_PROVIDERS, | ||
_UIROUTER_SERVICE_PROVIDERS, | ||
locationStrategy(config.useHash), | ||
...makeRootProviders(config), | ||
]); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# V18 | ||
|
||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.0.7. | ||
|
||
## Development server | ||
|
||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. | ||
|
||
## Code scaffolding | ||
|
||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. | ||
|
||
## Build | ||
|
||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
|
||
## Running unit tests | ||
|
||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
|
||
## Running end-to-end tests | ||
|
||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. | ||
|
||
## Further help | ||
|
||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"cli": { | ||
"packageManager": "yarn" | ||
}, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"v18": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:class": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:component": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:directive": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:guard": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:interceptor": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:pipe": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:resolver": { | ||
"skipTests": true | ||
}, | ||
"@schematics/angular:service": { | ||
"skipTests": true | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:application", | ||
"options": { | ||
"outputPath": "dist/v18", | ||
"index": "src/index.html", | ||
"browser": "src/main.ts", | ||
"polyfills": [ | ||
"zone.js" | ||
], | ||
"tsConfig": "tsconfig.app.json", | ||
"assets": [ | ||
{ | ||
"glob": "**/*", | ||
"input": "public" | ||
} | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kB", | ||
"maximumError": "1MB" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kB", | ||
"maximumError": "4kB" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"development": { | ||
"optimization": false, | ||
"extractLicenses": false, | ||
"sourceMap": true | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"configurations": { | ||
"production": { | ||
"buildTarget": "v18:build:production" | ||
}, | ||
"development": { | ||
"buildTarget": "v18:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"extract-i18n": { | ||
"builder": "@angular-devkit/build-angular:extract-i18n" | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"polyfills": [ | ||
"zone.js", | ||
"zone.js/testing" | ||
], | ||
"tsConfig": "tsconfig.spec.json", | ||
"assets": [ | ||
{ | ||
"glob": "**/*", | ||
"input": "public" | ||
} | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
export default defineConfig({ | ||
video: false, | ||
e2e: { | ||
setupNodeEvents(on, config) {}, | ||
baseUrl: 'http://localhost:4000', | ||
supportFile: false | ||
}, | ||
}) |
69 changes: 69 additions & 0 deletions
69
test-angular-versions/v18-standalone/cypress/e2e/sample_app.cy.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
describe('Angular app', () => { | ||
beforeEach(() => { | ||
window.sessionStorage.clear(); | ||
}); | ||
|
||
it('loads', () => { | ||
cy.visit(''); | ||
}); | ||
|
||
it('loads home state by default', () => { | ||
cy.visit(''); | ||
cy.url().should('include', '/home'); | ||
}); | ||
|
||
it('renders uisref as links', () => { | ||
cy.visit(''); | ||
cy.get('a').contains('home'); | ||
cy.get('a').contains('about'); | ||
cy.get('a').contains('lazy'); | ||
cy.get('a').contains('lazy.child'); | ||
cy.get('a').contains('lazy.child.viewtarget'); | ||
}); | ||
|
||
it('renders home', () => { | ||
cy.visit('/home'); | ||
cy.get('a').contains('home').should('have.class', 'active'); | ||
cy.get('a').contains('about').should('not.have.class', 'active'); | ||
cy.get('#default').contains('home works'); | ||
}); | ||
|
||
it('renders about', () => { | ||
cy.visit('/home'); | ||
cy.visit('/about'); | ||
cy.get('a').contains('home').should('not.have.class', 'active'); | ||
cy.get('a').contains('about').should('have.class', 'active'); | ||
cy.get('#default').contains('about works'); | ||
}); | ||
|
||
it('loads lazy routes', () => { | ||
cy.visit('/home'); | ||
cy.visit('/lazy'); | ||
cy.get('a').contains('home').should('not.have.class', 'active'); | ||
cy.get('a').contains('lazy').should('have.class', 'active'); | ||
cy.get('#default').contains('lazy works'); | ||
}); | ||
|
||
it('routes to lazy routes', () => { | ||
cy.visit('/lazy'); | ||
cy.get('a').contains('home').should('not.have.class', 'active'); | ||
cy.get('a').contains('lazy').should('have.class', 'active'); | ||
cy.get('#default').contains('lazy works'); | ||
}); | ||
|
||
it('routes to lazy child routes', () => { | ||
cy.visit('/lazy/child'); | ||
cy.get('a').contains('home').should('not.have.class', 'active'); | ||
cy.get('a').contains('lazy.child').should('have.class', 'active'); | ||
cy.get('#default').contains('lazy.child works'); | ||
}); | ||
|
||
it('targets named views', () => { | ||
cy.visit('/lazy/child/viewtarget'); | ||
cy.get('a').contains('home').should('not.have.class', 'active'); | ||
cy.get('a').contains('lazy.child').should('have.class', 'active'); | ||
cy.get('#default').contains('lazy.child works'); | ||
cy.get('#header').contains('lazy.child.viewtarget works'); | ||
cy.get('#footer').contains('lazy.child.viewtarget works'); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.