1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 | var PluginManager = (function () {
|
7 | function PluginManager(less) {
|
8 | this.less = less;
|
9 | this.visitors = [];
|
10 | this.preProcessors = [];
|
11 | this.postProcessors = [];
|
12 | this.installedPlugins = [];
|
13 | this.fileManagers = [];
|
14 | this.iterator = -1;
|
15 | this.pluginCache = {};
|
16 | this.Loader = new less.PluginLoader(less);
|
17 | }
|
18 | |
19 |
|
20 |
|
21 |
|
22 | PluginManager.prototype.addPlugins = function (plugins) {
|
23 | if (plugins) {
|
24 | for (var i = 0; i < plugins.length; i++) {
|
25 | this.addPlugin(plugins[i]);
|
26 | }
|
27 | }
|
28 | };
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | PluginManager.prototype.addPlugin = function (plugin, filename, functionRegistry) {
|
35 | this.installedPlugins.push(plugin);
|
36 | if (filename) {
|
37 | this.pluginCache[filename] = plugin;
|
38 | }
|
39 | if (plugin.install) {
|
40 | plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
|
41 | }
|
42 | };
|
43 | |
44 |
|
45 |
|
46 |
|
47 | PluginManager.prototype.get = function (filename) {
|
48 | return this.pluginCache[filename];
|
49 | };
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 | PluginManager.prototype.addVisitor = function (visitor) {
|
56 | this.visitors.push(visitor);
|
57 | };
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 | PluginManager.prototype.addPreProcessor = function (preProcessor, priority) {
|
64 | var indexToInsertAt;
|
65 | for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
|
66 | if (this.preProcessors[indexToInsertAt].priority >= priority) {
|
67 | break;
|
68 | }
|
69 | }
|
70 | this.preProcessors.splice(indexToInsertAt, 0, { preProcessor: preProcessor, priority: priority });
|
71 | };
|
72 | |
73 |
|
74 |
|
75 |
|
76 |
|
77 | PluginManager.prototype.addPostProcessor = function (postProcessor, priority) {
|
78 | var indexToInsertAt;
|
79 | for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
|
80 | if (this.postProcessors[indexToInsertAt].priority >= priority) {
|
81 | break;
|
82 | }
|
83 | }
|
84 | this.postProcessors.splice(indexToInsertAt, 0, { postProcessor: postProcessor, priority: priority });
|
85 | };
|
86 | |
87 |
|
88 |
|
89 |
|
90 | PluginManager.prototype.addFileManager = function (manager) {
|
91 | this.fileManagers.push(manager);
|
92 | };
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 | PluginManager.prototype.getPreProcessors = function () {
|
99 | var preProcessors = [];
|
100 | for (var i = 0; i < this.preProcessors.length; i++) {
|
101 | preProcessors.push(this.preProcessors[i].preProcessor);
|
102 | }
|
103 | return preProcessors;
|
104 | };
|
105 | |
106 |
|
107 |
|
108 |
|
109 |
|
110 | PluginManager.prototype.getPostProcessors = function () {
|
111 | var postProcessors = [];
|
112 | for (var i = 0; i < this.postProcessors.length; i++) {
|
113 | postProcessors.push(this.postProcessors[i].postProcessor);
|
114 | }
|
115 | return postProcessors;
|
116 | };
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 | PluginManager.prototype.getVisitors = function () {
|
123 | return this.visitors;
|
124 | };
|
125 | PluginManager.prototype.visitor = function () {
|
126 | var self = this;
|
127 | return {
|
128 | first: function () {
|
129 | self.iterator = -1;
|
130 | return self.visitors[self.iterator];
|
131 | },
|
132 | get: function () {
|
133 | self.iterator += 1;
|
134 | return self.visitors[self.iterator];
|
135 | }
|
136 | };
|
137 | };
|
138 | |
139 |
|
140 |
|
141 |
|
142 |
|
143 | PluginManager.prototype.getFileManagers = function () {
|
144 | return this.fileManagers;
|
145 | };
|
146 | return PluginManager;
|
147 | }());
|
148 | var pm;
|
149 | var PluginManagerFactory = function (less, newFactory) {
|
150 | if (newFactory || !pm) {
|
151 | pm = new PluginManager(less);
|
152 | }
|
153 | return pm;
|
154 | };
|
155 |
|
156 | exports.default = PluginManagerFactory;
|
157 |
|
\ | No newline at end of file |