| @@ -0,0 +1,5 @@ | ||
| Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | ||
| This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
| The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
| Code distributed by Google as part of the polymer project is also | ||
| subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
| @@ -0,0 +1,38 @@ | ||
| [](https://npmjs.org/package/hydrolysis) | ||
| [](https://travis-ci.org/Polymer/hydrolysis) | ||
| # hydrolysis | ||
|
|
||
| Static analysis utilities for polymer. | ||
|
|
||
| ## Install | ||
| ``` | ||
| npm install hydrolysis | ||
| ``` | ||
|
|
||
| ## Usage | ||
| ```js | ||
| var hyd = require('hydrolysis'); | ||
| hyd.Analyzer.analyze('path-to-polymer-element.html') | ||
| .then(function(analyzer) { | ||
| console.log(analyzer.elementsByTagName['my-element']) | ||
| }); | ||
| ``` | ||
|
|
||
| For more detail, see the [API Docs](API.md). | ||
|
|
||
|
|
||
| ## Developing | ||
| You need [wct](https://github.com/Polymer/web-component-tester) to run the tests. | ||
|
|
||
| Run a one-off build of the project: | ||
|
|
||
| ```sh | ||
| npm run build | ||
| ``` | ||
|
|
||
| Or watch the source for changes, and rebuild each time a file is modified: | ||
|
|
||
| ```sh | ||
| npm run watch | ||
| ``` |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "name": "hydrolysis", | ||
| "main": "hydrolysis.js", | ||
| "ignore": [ | ||
| "lib/", | ||
| "examples/", | ||
| "demo/", | ||
| "test/", | ||
| ".gitignore", | ||
| "gulpfile.js", | ||
| "package.json" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git://github.com/Polymer/hydrolysis.git" | ||
| }, | ||
| "devDependencies": { | ||
| "polymer": "Polymer/polymer#^0.9.0", | ||
| "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", | ||
| "web-component-tester": "*" | ||
| }, | ||
| "version": "1.21.4" | ||
| } |
| @@ -0,0 +1,114 @@ | ||
| <!-- | ||
| @license | ||
| Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | ||
| This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
| The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
| The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
| Code distributed by Google as part of the polymer project is also | ||
| subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
| --> | ||
| <link rel="import" href="../polymer/polymer.html"> | ||
| <link rel="import" href="hydrolysis.html"> | ||
|
|
||
| <script> | ||
| (function() { | ||
| var hydrolysis = require('hydrolysis'); | ||
|
|
||
| Polymer({ | ||
|
|
||
| is: 'hydrolysis-analyzer', | ||
|
|
||
| properties: { | ||
|
|
||
| /** | ||
| * The URL to an import that declares (or transitively imports) the | ||
| * elements that you wish to see analyzed. | ||
| * | ||
| * If the URL is relative, it will be resolved relative to the master | ||
| * document. | ||
| * | ||
| * If you change this value after the `<hydrolysis-analyzer>` has been | ||
| * instantiated, you must call `analyze()`. | ||
| */ | ||
| src: { | ||
| type: String, | ||
| }, | ||
|
|
||
| /** | ||
| * Whether _all_ dependencies should be loaded and analyzed. | ||
| * | ||
| * Turning this on will probably slow down the load process dramatically. | ||
| */ | ||
| transitive: { | ||
| type: Boolean, | ||
| }, | ||
|
|
||
| /** | ||
| * Whether the hydrolysis descriptors should be cleaned of redundant | ||
| * properties. | ||
| */ | ||
| clean: { | ||
| type: Boolean, | ||
| }, | ||
|
|
||
| /** The resultant `Analyzer` object from Hydrolysis. */ | ||
| analyzer: { | ||
| type: Object, | ||
| readOnly: true, | ||
| notify: true, | ||
| }, | ||
|
|
||
| /** Whether the analyzer is loading/analyzing resources. */ | ||
| loading: { | ||
| type: Boolean, | ||
| readOnly: true, | ||
| notify: true, | ||
| }, | ||
|
|
||
| }, | ||
|
|
||
| ready: function() { | ||
| this.analyze(); | ||
| }, | ||
|
|
||
| /** | ||
| * Begins loading the imports referenced by `src`. | ||
| * | ||
| * If you make changes to this element's configuration, you must call this | ||
| * function to kick off another analysis pass. | ||
| */ | ||
| analyze: function() { | ||
| if (!this.src) { | ||
| return; | ||
| } | ||
| // We can implement request cancellation when someone needs it. | ||
| if (this.loading) { | ||
| console.error('Analyzer is already loading a document:', this); | ||
| return; | ||
| } | ||
| this._setLoading(true); | ||
|
|
||
| var options = { | ||
| clean: this.clean, | ||
| filter: this.transitive ? function() { return false; } : null, | ||
| attachAst: true, | ||
| }; | ||
|
|
||
| var baseUri = this.ownerDocument.baseURI; | ||
| var srcUrl = new URL(this.src, baseUri).toString(); | ||
| hydrolysis.Analyzer.analyze(srcUrl, options).then(function(analyzer) { | ||
| this._setLoading(false); | ||
| this._setAnalyzer(analyzer); | ||
| }.bind(this)) | ||
| .catch(function(error) { | ||
| console.error('Failed to load source at:', this.src, error); | ||
| console.error(error.stack); | ||
| this._setLoading(false); | ||
| this._setAnalyzer(null); | ||
| }.bind(this)); | ||
| }, | ||
|
|
||
| }); | ||
|
|
||
| })(); | ||
| </script> |
| @@ -0,0 +1,10 @@ | ||
| <!-- | ||
| @license | ||
| Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | ||
| This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
| The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
| The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
| Code distributed by Google as part of the polymer project is also | ||
| subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
| --> | ||
| <script src="hydrolysis.js"></script> |
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * @license | ||
| * Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | ||
| * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
| * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
| * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
| * Code distributed by Google as part of the polymer project is also | ||
| * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
| */ | ||
| /*jslint node: true */ | ||
| 'use strict'; | ||
|
|
||
| /** | ||
| * Static analysis for Polymer. | ||
| * @namespace hydrolysis | ||
| */ | ||
| module.exports = { | ||
| Analyzer: require('./lib/analyzer'), | ||
| docs: require('./lib/ast-utils/docs'), | ||
| FSResolver: require('./lib/loader/fs-resolver'), | ||
| jsdoc: require('./lib/ast-utils/jsdoc'), | ||
| Loader: require('./lib/loader/file-loader'), | ||
| NoopResolver: require('./lib/loader/noop-resolver'), | ||
| RedirectResolver: require('./lib/loader/redirect-resolver'), | ||
| XHRResolver: require('./lib/loader/xhr-resolver'), | ||
| StringResolver: require('./lib/loader/string-resolver'), | ||
| _jsParse: require('./lib/ast-utils/js-parse'), | ||
| _importParse: require('./lib/ast-utils/import-parse'), | ||
| }; |