Socket
Socket
Sign inDemoInstall

ember-cli-htmlbars

Package Overview
Dependencies
1
Maintainers
4
Versions
112
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.1.0

addDependencyTracker.js

14

ember-addon-main.js

@@ -5,6 +5,7 @@ 'use strict';

const utils = require('./utils');
const addDependencyTracker = require("./addDependencyTracker");
const hashForDep = require('hash-for-dep');
module.exports = {
name: 'ember-cli-htmlbars',
name: require('./package').name,

@@ -110,2 +111,4 @@ parentRegistry: null,

dependencyInvalidation: pluginInfo.dependencyInvalidation,
pluginCacheKey: pluginInfo.cacheKeys

@@ -126,7 +129,9 @@ };

let cacheKeys = [];
let dependencyInvalidation = false;
for (let i = 0; i < pluginWrappers.length; i++) {
let wrapper = pluginWrappers[i];
dependencyInvalidation = dependencyInvalidation || wrapper.dependencyInvalidation;
plugins.push(addDependencyTracker(wrapper.plugin, wrapper.dependencyInvalidation));
plugins.push(wrapper.plugin);

@@ -136,3 +141,3 @@ let providesBaseDir = typeof wrapper.baseDir === 'function';

if (providesBaseDir || augmentsCacheKey) {
if (providesBaseDir || augmentsCacheKey || wrapper.dependencyInvalidation) {
if (providesBaseDir) {

@@ -154,5 +159,6 @@ let pluginHashForDep = hashForDep(wrapper.baseDir());

plugins: plugins,
cacheKeys: cacheKeys
cacheKeys: cacheKeys,
dependencyInvalidation: dependencyInvalidation,
};
}
};
'use strict';
const fs = require('fs');
const path = require('path');
const utils = require('./utils');

@@ -39,2 +40,3 @@ const Filter = require('broccoli-persistent-filter');

this.registerPlugin = this.options.templateCompiler.registerPlugin;
this.unregisterPlugin = this.options.templateCompiler.unregisterPlugin;

@@ -49,2 +51,9 @@ this.registerPlugins();

registeredASTPlugins() {
// This is a super obtuse way to get access to the plugins we've registered
// it also returns other plugins that are registered by ember itself.
let options = this.options.templateCompiler.compileOptions();
return options.plugins && options.plugins.ast || [];
}
registerPlugins() {

@@ -61,3 +70,14 @@ let plugins = this.options.plugins;

}
unregisterPlugins() {
let plugins = this.options.plugins;
if (plugins) {
for (let type in plugins) {
for (let i = 0, l = plugins[type].length; i < l; i++) {
this.unregisterPlugin(type, plugins[type][i]);
}
}
}
}
initializeFeatures() {

@@ -79,7 +99,22 @@ let EmberENV = this.options.EmberENV;

processString(string, relativePath) {
let srcDir = this.inputPaths[0];
let srcName = path.join(srcDir, relativePath);
try {
return 'export default ' + utils.template(this.options.templateCompiler, stripBom(string), {
let result = 'export default ' + utils.template(this.options.templateCompiler, stripBom(string), {
contents: string,
moduleName: relativePath
moduleName: relativePath,
parseOptions: {
srcName: srcName
}
}) + ';';
if (this.options.dependencyInvalidation) {
let plugins = pluginsWithDependencies(this.registeredASTPlugins());
let dependencies = [];
for (let i = 0; i < plugins.length; i++) {
let pluginDeps = plugins[i].getDependencies(relativePath);
dependencies = dependencies.concat(pluginDeps);
}
this.dependencies.setDependencies(relativePath, dependencies);
}
return result;
} catch(error) {

@@ -129,2 +164,12 @@ rethrowBuildError(error);

function pluginsWithDependencies(registeredPlugins) {
let found = [];
for (let i = 0; i < registeredPlugins.length; i++) {
if (registeredPlugins[i].getDependencies) {
found.push(registeredPlugins[i]);
}
}
return found;
}
module.exports = TemplateCompiler;
{
"name": "ember-cli-htmlbars",
"version": "3.0.1",
"version": "3.1.0",
"description": "A library for adding htmlbars to ember CLI",
"main": "index.js",
"keywords": [
"ember-addon",
"ember-cli"
],
"homepage": "https://github.com/ember-cli/ember-cli-htmlbars",
"bugs": {
"url": "https://github.com/ember-cli/ember-cli-htmlbars/issues"
},
"repository": {
"type": "git",
"url": "git@github.com:ember-cli/ember-cli-htmlbars.git"
},
"license": "MIT",
"author": "Jonathan Jackson & Chase McCarthy",
"files": [
"index.js",
"addDependencyTracker.js",
"ember-addon-main.js",
"utils.js"
],
"engines": {
"node": "6.* || 8.* || >= 10.*"
},
"main": "index.js",
"scripts": {
"build": "ember build",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",

@@ -23,53 +36,43 @@ "start": "ember serve",

},
"repository": {
"type": "git",
"url": "git@github.com:ember-cli/ember-cli-htmlbars.git"
"dependencies": {
"broccoli-persistent-filter": "^2.3.1",
"hash-for-dep": "^1.5.1",
"json-stable-stringify": "^1.0.1",
"strip-bom": "^3.0.0"
},
"keywords": [
"ember-cli",
"ember-addon"
],
"ember-addon": {
"main": "ember-addon-main.js",
"configPath": "tests/dummy/config"
},
"author": "Jonathan Jackson & Chase McCarthy",
"license": "MIT",
"bugs": {
"url": "https://github.com/ember-cli/ember-cli-htmlbars/issues"
},
"homepage": "https://github.com/ember-cli/ember-cli-htmlbars",
"devDependencies": {
"broccoli": "^2.0.0-beta.4",
"broccoli-concat": "^3.5.1",
"@ember/optional-features": "^0.7.0",
"broccoli-test-helper": "^2.0.0",
"chai": "^4.2.0",
"co": "^4.6.0",
"ember-cli": "~3.3.0",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.6.0",
"ember-cli-dependency-checker": "^3.0.0",
"ember-cli-eslint": "^4.2.1",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.3.2",
"ember-cli-shims": "^1.2.0",
"ember-cli": "~3.9.0",
"ember-cli-app-version": "^3.2.0",
"ember-cli-babel": "^7.8.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-eslint": "^5.1.0",
"ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-template-lint": "^1.0.0-beta.3",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-load-initializers": "^2.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-resolver": "^5.0.0",
"ember-source": "~3.3.1",
"ember-qunit": "^4.4.1",
"ember-resolver": "^5.1.3",
"ember-source": "~3.11.1",
"ember-source-channel-url": "^1.1.0",
"ember-try": "^0.2.23",
"eslint-plugin-ember": "^5.0.0",
"eslint-plugin-mocha": "^5.1.0",
"eslint-plugin-node": "^7.0.1",
"loader.js": "^4.2.3",
"mocha": "^5.2.0",
"qunit-dom": "^0.7.1"
"ember-try": "^1.2.1",
"eslint-plugin-ember": "^6.7.0",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-node": "^8.0.0",
"fixturify": "^1.2.0",
"loader.js": "^4.7.0",
"mocha": "^6.1.4",
"qunit-dom": "^0.8.5"
},
"dependencies": {
"broccoli-persistent-filter": "^1.4.3",
"hash-for-dep": "^1.2.3",
"json-stable-stringify": "^1.0.0",
"strip-bom": "^3.0.0"
"engines": {
"node": "6.* || 8.* || >= 10.*"
},
"ember-addon": {
"main": "ember-addon-main.js",
"configPath": "tests/dummy/config"
}
}

@@ -44,2 +44,51 @@ # Ember CLI HTMLBars

#### Options for registering a `htmlbars-ast-plugin`
* `name` - String. The name of the AST transform for debugging purposes.
* `plugin` - A function of type [`ASTPluginBuilder`](https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/parser/tokenizer-event-handlers.ts#L329-L341).
* `dependencyInvalidation` - Boolean. A flag that indicates the AST Plugin may, on a per-template basis, depend on other files that affect its output.
* `cacheKey` - function that returns any JSON-compatible value - The value returned is used to invalidate the persistent cache across restarts, usually in the case of a dependency or configuration change.
* `baseDir` - `() => string`. A function that returns the directory on disk of the npm module for the plugin. If provided, a basic cache invalidation is performed if any of the dependencies change (e.g. due to a npm install/upgrade).
#### Implementing Dependency Invalidation in an AST Plugin
Plugins that set the `dependencyInvalidation` option to `true` can provide function for the `plugin` of type `ASTDependencyPlugin` as given below.
Note: the `plugin` function is invoked without a value for `this` in context.
```ts
import {ASTPluginBuilder, ASTPlugin} from "@glimmer/syntax/dist/types/lib/parser/tokenizer-event-handlers";
export type ASTDependencyPlugin = ASTPluginWithDepsBuilder | ASTPluginBuilderWithDeps;
export interface ASTPluginWithDepsBuilder {
(env: ASTPluginEnvironment): ASTPluginWithDeps;
}
export interface ASTPluginBuilderWithDeps extends ASTPluginBuilder {
/**
* @see {ASTPluginWithDeps.dependencies} below.
**/
dependencies(relativePath): string[];
}
export interface ASTPluginWithDeps extends ASTPlugin {
/**
* If this method exists, it is called with the relative path to the current
* file just before processing starts. Use this method to reset the
* dependency tracking state associated with the file.
*/
resetDependencies?(relativePath: string): void;
/**
* This method is called just as the template finishes being processed.
*
* @param relativePath {string} A relative path to the file that may have dependencies.
* @return {string[]} paths to files that are a dependency for the given
* file. Any relative paths returned by this method are taken to be relative
* to the file that was processed.
*/
dependencies(relativePath: string): string[];
}
```
### Precompile HTMLBars template strings within other addons

@@ -46,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc