Commit 75f4dc43 authored by Akari Labs's avatar Akari Labs

replace declarative api with an imperative one

parent 3e81c266
{
"friendly_name": "cascade",
"modules": {
"webpack.abstraction": {
"filename": "modules/webpack.abstraction.js"
},
"webpack": {
"filename": "modules/webpack.js",
"doCallbacks": true
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ const style = createSymbols(['func', 'array', 'unknown']);
module.exports = {
hookWebpack(pushHook, mod) {
hookWebpack(pushHook, mod, name) {
var _webpack, _push;
var _style = style.unknown;
......@@ -30,7 +30,7 @@ module.exports = {
}
}
Object.defineProperty(window, 'webpackJsonp', {
Object.defineProperty(window, name, {
get: () => _webpack,
set(webpack) {
switch (typeof webpack) {
......
......@@ -105,9 +105,9 @@ function pushHook(mod) {
return mod;
}
function hookWebpack() {
function hookWebpack(name) {
console.debug('hooking webpackJsonp');
abstraction.hookWebpack(pushHook, cascadeModule);
abstraction.hookWebpack(pushHook, cascadeModule, name || 'webpackJsonp');
}
module.exports = {
......@@ -115,27 +115,16 @@ module.exports = {
search, hookWebpack,
replacements, preCtor, postCtor,
preload() {
hookWebpack();
installReplacement({search, replace}) {
replacements.push({search, replace});
},
callbacks: {
cascade(j) {
const defines = j.cascade;
if (defines.replacements) defines.replacements.forEach(replacement =>
replacements.push(replacement)
);
if (defines.preCtor) defines.preCtor.forEach(callback => {
callback.condition = ctorSearchToFunc(callback.condition);
preCtor.push(callback);
});
if (defines.postCtor) defines.postCtor.forEach(callback => {
callback.condition = callbackSearchToFunc(callback.condition);
postCtor.push(callback);
});
}
installPreCtor({condition, callback}) {
preCtor.push(callbackSearchToFunc(condition), callback);
},
installPostCtor({condition, callback}) {
postCtor.push(callbackSearchToFunc(condition), callback);
}
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment