-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
39 lines (33 loc) · 1.18 KB
/
index.js
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
'use strict';
const delegate = require('delegates');
const Tag = require('nunjucks-tag');
const Resource = require('./lib/Resource');
const symbol = require('./lib/symbol');
const TagNames = [ 'body', 'head', 'html', 'pagelet', 'require', 'script', 'uri', 'title', 'datalet', 'ATF' ];
const tags = TagNames.map(tagName => {
const Tag = require('./lib/tags/' + tagName);
return new Tag();
});
exports.Tag = Tag;
exports.Resource = Resource;
exports.setServiceWorkerRegistrationJS = Resource.setServiceWorkerRegistrationJS;
exports.symbol = symbol;
exports.TagNames = TagNames;
exports.tags = tags;
exports.register = function(env) {
this.tags.forEach(tag => {
env.addExtension(tag.tagName, tag);
});
};
delegate(exports, 'Resource').getter('manifest');
/**
* 初始化 pagelet tags
* @method Pagelet#configure
* @param {Object} opt 配置对象
* @param {String|Object|Function} opt.manifest 资源映射表, 可以是文件路径/映射表对象/读取函数
* @param {String} opt.root 静态文件的根目录
* @param {Boolean} [opt.cache] 是否缓存资源映射表
* @param {Object} [opt.logger] 日志对象
* @return {void}
*/
delegate(exports, 'Resource').method('configure');