Skip to content

Commit 4549d65

Browse files
author
abusedmedia
committed
bump release
1 parent 2be55b2 commit 4549d65

File tree

2 files changed

+49
-24
lines changed

2 files changed

+49
-24
lines changed

dist/presenta.js

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// https://lib.presenta.cc v0.1.3 - BSD-3-Clause License - Copyright 2020 Fabio Franchino
1+
// https://lib.presenta.cc v0.1.4 - BSD-3-Clause License - Copyright 2020 Fabio Franchino
22
(function (global, factory) {
33
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
44
typeof define === 'function' && define.amd ? define(factory) :
55
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Presenta = factory());
66
}(this, (function () { 'use strict';
77

8-
var version = "0.1.3";
8+
var version = "0.1.4";
99

1010
function styleInject(css, ref) {
1111
if ( ref === void 0 ) ref = {};
@@ -709,32 +709,47 @@
709709

710710
const caches = [];
711711

712-
const cache = function (rootElement, router, ctrlConfig, projectConfig) {
713-
projectConfig.scenes.forEach(s => {
714-
s.blocks.forEach(b => {
715-
const blk = caches.find(d => d.type === b.type);
716-
717-
if (blk && b.url) {
718-
const f = blk => {
719-
fetch(b.url).then(data => {
720-
data.text().then(data => {
721-
b._cache = data;
722-
});
723-
});
724-
};
725-
726-
f();
727-
}
728-
});
729-
});
730-
};
712+
const cache = function (rootElement, router, ctrlConfig, projectConfig) {};
731713

732714
const addCache = ob => {
733715
caches.push(ob);
734716
};
735717

736718
utils.io.addCache = addCache;
737719

720+
cache.run = config => {
721+
return new Promise((resolve, reject) => {
722+
let len = 0;
723+
let cnt = 0;
724+
const blocks = config.scenes.reduce((a, s) => {
725+
s.blocks.reduce((a2, b) => {
726+
const blk = caches.find(d => d.type === b.type);
727+
if (blk && b.url) a.push(b);
728+
}, []);
729+
return a;
730+
}, []);
731+
if (blocks.length === 0) resolve();
732+
blocks.forEach(block => {
733+
const f = block => {
734+
fetch(block.url).then(data => {
735+
data.text().then(data => {
736+
block._cache = data;
737+
cnt++;
738+
if (cnt === len) resolve();
739+
});
740+
}).catch(err => {
741+
cnt++;
742+
block._cache = err + ': ' + block.url;
743+
if (cnt === len) resolve();
744+
});
745+
};
746+
747+
len++;
748+
f(block);
749+
});
750+
});
751+
};
752+
738753
const controllers = {
739754
autoplay,
740755
keyboard,
@@ -1829,9 +1844,19 @@
18291844

18301845
for (const k in plugins) if (plugins[k].init) plugins[k].init();
18311846

1832-
for (const k in plugins) if (plugins[k].run) plugins[k].run(config);
1847+
const all = [];
18331848

1834-
return new Container(utils.select(el), config);
1849+
for (const k in plugins) {
1850+
if (plugins[k].run) {
1851+
all.push(plugins[k].run(config));
1852+
}
1853+
}
1854+
1855+
return new Promise((resolve, reject) => {
1856+
Promise.all(all).then(values => {
1857+
resolve(new Container(utils.select(el), config));
1858+
});
1859+
});
18351860
};
18361861

18371862
add$2('group', group); // this to avoid circular dependencies warning, since removed implicit inclusion in block types

0 commit comments

Comments
 (0)