|
1 | | -// https://lib.presenta.cc v1.0.22 - BSD-3-Clause License - Copyright 2022 Fabio Franchino |
| 1 | +// https://lib.presenta.cc v1.0.23 - BSD-3-Clause License - Copyright 2022 Fabio Franchino |
2 | 2 | (function (global, factory) { |
3 | 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
4 | 4 | typeof define === 'function' && define.amd ? define(factory) : |
5 | 5 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Presenta = factory()); |
6 | 6 | })(this, (function () { 'use strict'; |
7 | 7 |
|
8 | | - var version = "1.0.22"; |
| 8 | + var version = "1.0.23"; |
9 | 9 |
|
10 | 10 | function styleInject(css, ref) { |
11 | 11 | if ( ref === void 0 ) ref = {}; |
|
1079 | 1079 | } |
1080 | 1080 | }; |
1081 | 1081 |
|
1082 | | - const appendScriptTag = (url, code, id) => { |
1083 | | - const ns = document.createElement('script'); |
1084 | | - ns.setAttribute('class', 'sdpmodulescriptcontainer' + id); |
1085 | | - ns.setAttribute('type', 'module'); |
1086 | | - ns.setAttribute('async', ''); |
1087 | | - ns.innerHTML = code; |
1088 | | - ns.src = url; |
1089 | | - document.body.appendChild(ns); |
1090 | | - }; |
1091 | | - |
1092 | | - const script = function (element, mod, config) { |
1093 | | - if (!mod.forceRun && config._mode === 'preview') return; |
1094 | | - if (!mod.code) return; |
1095 | | - if (config.contextType !== 'scene') return; |
1096 | | - const id = '_JSMOD_' + parseInt(Math.random() * 10000); |
1097 | | - const that = this; |
1098 | | - |
1099 | | - this.destroy = () => { |
1100 | | - const prev = [...document.querySelectorAll('.sdpmodulescriptcontainer' + id)]; |
1101 | | - prev.forEach(d => document.body.removeChild(d)); |
1102 | | - }; |
1103 | | - |
1104 | | - return new Promise((resolve, reject) => { |
1105 | | - const blink = {}; |
1106 | | - config.blocks.forEach(b => { |
1107 | | - blink[b.ukey] = b; |
1108 | | - }); |
1109 | | - blink._otherParams = config.otherParams; |
1110 | | - window['_sdpconfigobject' + id] = blink; // window['_sdpscriptexportedresult' + id] = {} |
1111 | | - |
1112 | | - window['_sdpcallbackfunc' + id] = () => { |
1113 | | - console.log('_sdpcallbackfunc' + id); |
1114 | | - window['_sdpcallbackfunc' + id] = null; |
1115 | | - window['_sdpconfigobject' + id] = null; |
1116 | | - resolve(that); |
1117 | | - }; |
1118 | | - |
1119 | | - let code = ` |
1120 | | -const index = ${config.index} |
1121 | | -//const exportedResult = window._sdpscriptexportedresult${id} |
1122 | | -
|
1123 | | -const params = window._sdpconfigobject${id}._otherParams |
1124 | | - `; |
1125 | | - config.blocks.forEach(b => { |
1126 | | - if (b.ukey) { |
1127 | | - code += ` |
1128 | | -const ${b.ukey} = window._sdpconfigobject${id}.${b.ukey} |
1129 | | -`; |
1130 | | - } |
1131 | | - }); |
1132 | | - code += ` |
1133 | | -
|
1134 | | -${mod.header} |
1135 | | -
|
1136 | | -try{ |
1137 | | -
|
1138 | | -${mod.code} |
1139 | | -
|
1140 | | -}catch(err){ |
1141 | | - console.log('error in module', err) |
1142 | | -} |
1143 | | -export default {}`; // add the code module |
1144 | | - |
1145 | | - let url = URL.createObjectURL(new Blob([code], { |
1146 | | - type: 'application/javascript' |
1147 | | - })); |
1148 | | - appendScriptTag(url, code, id); // add the last module for callback |
1149 | | - |
1150 | | - const lastModule = ` |
1151 | | -import _sdpPrivateInput from '${url}' |
1152 | | -window._sdpcallbackfunc${id}() |
1153 | | -`; |
1154 | | - url = URL.createObjectURL(new Blob([lastModule], { |
1155 | | - type: 'application/javascript' |
1156 | | - })); |
1157 | | - appendScriptTag(url, lastModule, id); |
1158 | | - }); |
1159 | | - }; |
1160 | | - |
1161 | | - script.runBefore = true; |
1162 | | - |
1163 | 1082 | const showif = function (element, mod, config) { |
1164 | 1083 | const { |
1165 | 1084 | key, |
@@ -1204,7 +1123,6 @@ window._sdpcallbackfunc${id}() |
1204 | 1123 | autoplay, |
1205 | 1124 | reveal, |
1206 | 1125 | enters, |
1207 | | - script, |
1208 | 1126 | link, |
1209 | 1127 | showif, |
1210 | 1128 | hidden |
@@ -2506,14 +2424,13 @@ window._sdpcallbackfunc${id}() |
2506 | 2424 | config._root = root; |
2507 | 2425 | const splash = new Splash(root, config); |
2508 | 2426 | return new Promise((resolve, reject) => { |
2509 | | - // new ScriptRun(config).then(() => { |
2510 | 2427 | new Install(config.plugins).then(() => { |
2511 | 2428 | const all = pluginsInit(config); |
2512 | 2429 | Promise.all(all).then(values => { |
2513 | 2430 | resolve(new Container(root, config)); |
2514 | 2431 | splash.destroy(); |
2515 | 2432 | }); |
2516 | | - }); // }) |
| 2433 | + }); |
2517 | 2434 | }); |
2518 | 2435 | }; |
2519 | 2436 |
|
|
0 commit comments