-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
78 lines (63 loc) · 1.88 KB
/
Copy pathindex.js
File metadata and controls
78 lines (63 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const defaultOptions = {
enableFlashFallback: true,
flashFallbackDir: 'assets'
};
const map = require('broccoli-stew').map;
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
// For ember-cli < 2.7 findHost doesnt exist so we backport from that version
// for earlier version of ember-cli.
// https://github.com/ember-cli/ember-cli/blame/16e4492c9ebf3348eb0f31df17215810674dbdf6/lib/models/addon.js#L533
const findHostShim = function () {
let current = this;
let app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
module.exports = {
name: require('./package').name,
options: {
nodeAssets: {
webcamjs() {
const config = {
vendor: ['webcam.js']
};
if (this.addonOptions.enableFlashFallback) {
config.public = {
destDir: this.addonOptions.flashFallbackDir,
include: ['webcam.swf']
};
}
return config;
}
}
},
treeForVendor(defaultTree) {
let browserVendorLib = new Funnel('node_modules/webcamjs/');
browserVendorLib = map(browserVendorLib, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
if (defaultTree) {
return new mergeTrees([defaultTree, browserVendorLib]);
} else {
return browserVendorLib;
}
},
included() {
const findHost = this._findHost || findHostShim;
const app = findHost.call(this);
const userOptions = app.options && app.options[this.name] || {};
this.addonOptions = Object.assign({}, defaultOptions, userOptions);
this._super.included.apply(this, arguments);
app.import('vendor/webcam.js', {
using: [{
transformation: 'amd',
as: 'webcamjs'
}]
});
},
config() {
return { 'ember-webcam': this.addonOptions };
}
};