@fluxscape/react-runtime 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{viewer/fluxscape.viewer.js → preview/fluxscape.preview.js} +2 -2
- package/build/{deploy/noodl.index.deploy.js.map → preview/fluxscape.preview.js.map} +1 -1
- package/build/{deploy → preview}/index.html +2 -15
- package/build/preview/index.js.liquid +1 -0
- package/{static/deploy → build/production}/index.html +2 -15
- package/build/production/index.js.liquid +1 -0
- package/build/{deploy/noodl.index.deploy.js → production/noodl.index.production.js} +2 -2
- package/build/production/noodl.index.production.js.map +1 -0
- package/dist/components/visual/Icon/Icon.d.ts +2 -2
- package/dist/components/visual/Icon/Icon.d.ts.map +1 -1
- package/dist/index.es.js +21 -11
- package/dist/index.es.js.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/package.json +5 -6
- package/build/deploy/index.js +0 -10
- package/build/deploy/index.json +0 -10
- package/build/deploy/noodl-app.png +0 -0
- package/build/viewer/fluxscape.viewer.js.map +0 -1
- package/build/viewer/index.html +0 -99
- package/build/viewer/noodl-app.png +0 -0
- package/index.deploy.js +0 -3
- package/index.ssr.js +0 -7
- package/index.viewer.js +0 -4
- package/static/deploy/index.js +0 -10
- package/static/deploy/index.json +0 -10
- package/static/shared/load_terminator.js +0 -1
- package/static/shared/noodl-app.png +0 -0
- package/static/shared/react-dom.production.min.js +0 -219
- package/static/shared/react.production.min.js +0 -32
- package/static/ssr/index.js +0 -194
- package/static/ssr/index.json +0 -5
- package/static/ssr/package.json +0 -25
- package/static/viewer/global.d.ts.keep +0 -721
- package/static/viewer/index.html +0 -99
- package/static/viewer/ndl_assets/OpenSans-Bold.ttf +0 -0
- package/static/viewer/ndl_assets/OpenSans-Regular.ttf +0 -0
- package/static/viewer/ndl_assets/home-icon.svg +0 -3
- package/static/viewer/ndl_assets/make-home-instructions@2x.png +0 -0
- package/static/viewer/ndl_assets/noodl-logo-black.svg +0 -3
- /package/build/{viewer → preview}/global.d.ts.keep +0 -0
- /package/build/{deploy → preview}/load_terminator.js +0 -0
- /package/build/{viewer → preview}/ndl_assets/OpenSans-Bold.ttf +0 -0
- /package/build/{viewer → preview}/ndl_assets/OpenSans-Regular.ttf +0 -0
- /package/build/{viewer → preview}/ndl_assets/home-icon.svg +0 -0
- /package/build/{viewer → preview}/ndl_assets/make-home-instructions@2x.png +0 -0
- /package/build/{viewer → preview}/ndl_assets/noodl-logo-black.svg +0 -0
- /package/build/{deploy → preview}/react-dom.production.min.js +0 -0
- /package/build/{deploy → preview}/react-runtime.css +0 -0
- /package/build/{deploy → preview}/react.production.min.js +0 -0
- /package/build/{viewer → production}/load_terminator.js +0 -0
- /package/build/{viewer → production}/react-dom.production.min.js +0 -0
- /package/build/{viewer → production}/react-runtime.css +0 -0
- /package/build/{viewer → production}/react.production.min.js +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** @license React v16.8.1
|
|
2
|
-
* react.production.min.js
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
'use strict';(function(M,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):M.React=q()})(this,function(){function M(a,b,d,f,p,c,e,h){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var n=[d,f,p,c,e,h],ta=0;a=Error(b.replace(/%s/g,function(){return n[ta++]}));a.name="Invariant Violation"}a.framesToPop=
|
|
10
|
-
1;throw a;}}function q(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=0;f<b;f++)d+="&args[]="+encodeURIComponent(arguments[f+1]);M(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}function t(a,b,d){this.props=a;this.context=b;this.refs=ba;this.updater=d||ca}function da(){}function N(a,b,d){this.props=a;this.context=b;this.refs=ba;this.updater=
|
|
11
|
-
d||ca}function u(){if(!x){var a=c.expirationTime;C?O():C=!0;D(ua,a)}}function P(){var a=c,b=c.next;if(c===b)c=null;else{var d=c.previous;c=d.next=b;b.previous=d}a.next=a.previous=null;d=a.callback;b=a.expirationTime;a=a.priorityLevel;var f=g,p=E;g=a;E=b;try{var n=d()}finally{g=f,E=p}if("function"===typeof n)if(n={callback:n,priorityLevel:a,expirationTime:b,next:null,previous:null},null===c)c=n.next=n.previous=n;else{d=null;a=c;do{if(a.expirationTime>=b){d=a;break}a=a.next}while(a!==c);null===d?d=
|
|
12
|
-
c:d===c&&(c=n,u());b=d.previous;b.next=d.previous=n;n.next=d;n.previous=b}}function Q(){if(-1===l&&null!==c&&1===c.priorityLevel){x=!0;try{do P();while(null!==c&&1===c.priorityLevel)}finally{x=!1,null!==c?u():C=!1}}}function ua(a){x=!0;var b=F;F=a;try{if(a)for(;null!==c;){var d=k();if(c.expirationTime<=d){do P();while(null!==c&&c.expirationTime<=d)}else break}else if(null!==c){do P();while(null!==c&&!G())}}finally{x=!1,F=b,null!==c?u():C=!1,Q()}}function ea(a,b,d){var f=void 0,p={},c=null,e=null;
|
|
13
|
-
if(null!=b)for(f in void 0!==b.ref&&(e=b.ref),void 0!==b.key&&(c=""+b.key),b)fa.call(b,f)&&!ha.hasOwnProperty(f)&&(p[f]=b[f]);var h=arguments.length-2;if(1===h)p.children=d;else if(1<h){for(var g=Array(h),k=0;k<h;k++)g[k]=arguments[k+2];p.children=g}if(a&&a.defaultProps)for(f in h=a.defaultProps,h)void 0===p[f]&&(p[f]=h[f]);return{$$typeof:y,type:a,key:c,ref:e,props:p,_owner:R.current}}function va(a,b){return{$$typeof:y,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function S(a){return"object"===
|
|
14
|
-
typeof a&&null!==a&&a.$$typeof===y}function wa(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}function ia(a,b,d,f){if(H.length){var c=H.pop();c.result=a;c.keyPrefix=b;c.func=d;c.context=f;c.count=0;return c}return{result:a,keyPrefix:b,func:d,context:f,count:0}}function ja(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>H.length&&H.push(a)}function T(a,b,d,f){var c=typeof a;if("undefined"===c||"boolean"===c)a=null;var e=!1;if(null===
|
|
15
|
-
a)e=!0;else switch(c){case "string":case "number":e=!0;break;case "object":switch(a.$$typeof){case y:case xa:e=!0}}if(e)return d(f,a,""===b?"."+U(a,0):b),1;e=0;b=""===b?".":b+":";if(Array.isArray(a))for(var g=0;g<a.length;g++){c=a[g];var h=b+U(c,g);e+=T(c,h,d,f)}else if(null===a||"object"!==typeof a?h=null:(h=ka&&a[ka]||a["@@iterator"],h="function"===typeof h?h:null),"function"===typeof h)for(a=h.call(a),g=0;!(c=a.next()).done;)c=c.value,h=b+U(c,g++),e+=T(c,h,d,f);else"object"===c&&(d=""+a,q("31",
|
|
16
|
-
"[object Object]"===d?"object with keys {"+Object.keys(a).join(", ")+"}":d,""));return e}function V(a,b,d){return null==a?0:T(a,"",b,d)}function U(a,b){return"object"===typeof a&&null!==a&&null!=a.key?wa(a.key):b.toString(36)}function ya(a,b,d){a.func.call(a.context,b,a.count++)}function za(a,b,d){var f=a.result,c=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,f,d,function(a){return a}):null!=a&&(S(a)&&(a=va(a,c+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(la,"$&/")+"/")+
|
|
17
|
-
d)),f.push(a))}function W(a,b,d,f,c){var e="";null!=d&&(e=(""+d).replace(la,"$&/")+"/");b=ia(b,e,f,c);V(a,za,b);ja(b)}function m(){var a=ma.current;null===a?q("307"):void 0;return a}var e="function"===typeof Symbol&&Symbol.for,y=e?Symbol.for("react.element"):60103,xa=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,X=e?Symbol.for("react.strict_mode"):60108,Aa=e?Symbol.for("react.profiler"):60114,Ba=e?Symbol.for("react.provider"):60109,Ca=e?Symbol.for("react.context"):60110,
|
|
18
|
-
Da=e?Symbol.for("react.concurrent_mode"):60111,Ea=e?Symbol.for("react.forward_ref"):60112,Fa=e?Symbol.for("react.suspense"):60113,Ga=e?Symbol.for("react.memo"):60115,Ha=e?Symbol.for("react.lazy"):60116,ka="function"===typeof Symbol&&Symbol.iterator,na=Object.getOwnPropertySymbols,Ia=Object.prototype.hasOwnProperty,Ja=Object.prototype.propertyIsEnumerable,I=function(){try{if(!Object.assign)return!1;var a=new String("abc");a[5]="de";if("5"===Object.getOwnPropertyNames(a)[0])return!1;var b={};for(a=
|
|
19
|
-
0;10>a;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var d={};"abcdefghijklmnopqrst".split("").forEach(function(a){d[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},d)).join("")?!1:!0}catch(f){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");var d=Object(a);for(var c,e=1;e<arguments.length;e++){var g=Object(arguments[e]);
|
|
20
|
-
for(var k in g)Ia.call(g,k)&&(d[k]=g[k]);if(na){c=na(g);for(var h=0;h<c.length;h++)Ja.call(g,c[h])&&(d[c[h]]=g[c[h]])}}return d},ca={isMounted:function(a){return!1},enqueueForceUpdate:function(a,b,d){},enqueueReplaceState:function(a,b,d,c){},enqueueSetState:function(a,b,d,c){}},ba={};t.prototype.isReactComponent={};t.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?q("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};t.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,
|
|
21
|
-
a,"forceUpdate")};da.prototype=t.prototype;e=N.prototype=new da;e.constructor=N;I(e,t.prototype);e.isPureReactComponent=!0;var c=null,F=!1,g=3,l=-1,E=-1,x=!1,C=!1,Ka=Date,La="function"===typeof setTimeout?setTimeout:void 0,Ma="function"===typeof clearTimeout?clearTimeout:void 0,oa="function"===typeof requestAnimationFrame?requestAnimationFrame:void 0,pa="function"===typeof cancelAnimationFrame?cancelAnimationFrame:void 0,qa,ra,Y=function(a){qa=oa(function(b){Ma(ra);a(b)});ra=La(function(){pa(qa);
|
|
22
|
-
a(k())},100)};if("object"===typeof performance&&"function"===typeof performance.now){var Na=performance;var k=function(){return Na.now()}}else k=function(){return Ka.now()};e=null;"undefined"!==typeof window?e=window:"undefined"!==typeof global&&(e=global);if(e&&e._schedMock){e=e._schedMock;var D=e[0];var O=e[1];var G=e[2];k=e[3]}else if("undefined"===typeof window||"function"!==typeof MessageChannel){var v=null,Oa=function(a){if(null!==v)try{v(a)}finally{v=null}};D=function(a,b){null!==v?setTimeout(D,
|
|
23
|
-
0,a):(v=a,setTimeout(Oa,0,!1))};O=function(){v=null};G=function(){return!1}}else{"undefined"!==typeof console&&("function"!==typeof oa&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!==typeof pa&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));var w=null,J=!1,z=-1,A=!1,Z=!1,K=0,
|
|
24
|
-
L=33,B=33;G=function(){return K<=k()};e=new MessageChannel;var sa=e.port2;e.port1.onmessage=function(a){J=!1;a=w;var b=z;w=null;z=-1;var d=k(),c=!1;if(0>=K-d)if(-1!==b&&b<=d)c=!0;else{A||(A=!0,Y(aa));w=a;z=b;return}if(null!==a){Z=!0;try{a(c)}finally{Z=!1}}};var aa=function(a){if(null!==w){Y(aa);var b=a-K+B;b<B&&L<B?(8>b&&(b=8),B=b<L?L:b):L=b;K=a+B;J||(J=!0,sa.postMessage(void 0))}else A=!1};D=function(a,b){w=a;z=b;Z||0>b?sa.postMessage(void 0):A||(A=!0,Y(aa))};O=function(){w=null;J=!1;z=-1}}var Pa=
|
|
25
|
-
0,ma={current:null},R={current:null};e={ReactCurrentDispatcher:ma,ReactCurrentOwner:R,assign:I};I(e,{Scheduler:{unstable_cancelCallback:function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}},unstable_shouldYield:function(){return!F&&(null!==c&&c.expirationTime<E||G())},unstable_now:k,unstable_scheduleCallback:function(a,b){var d=-1!==l?l:k();if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=d+b.timeout;
|
|
26
|
-
else switch(g){case 1:b=d+-1;break;case 2:b=d+250;break;case 5:b=d+1073741823;break;case 4:b=d+1E4;break;default:b=d+5E3}a={callback:a,priorityLevel:g,expirationTime:b,next:null,previous:null};if(null===c)c=a.next=a.previous=a,u();else{d=null;var f=c;do{if(f.expirationTime>b){d=f;break}f=f.next}while(f!==c);null===d?d=c:d===c&&(c=a,u());b=d.previous;b.next=d.previous=a;a.next=d;a.previous=b}return a},unstable_runWithPriority:function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=
|
|
27
|
-
3}var d=g,c=l;g=a;l=k();try{return b()}finally{g=d,l=c,Q()}},unstable_wrapCallback:function(a){var b=g;return function(){var d=g,c=l;g=b;l=k();try{return a.apply(this,arguments)}finally{g=d,l=c,Q()}}},unstable_getFirstCallbackNode:function(){return c},unstable_pauseExecution:function(){},unstable_continueExecution:function(){null!==c&&u()},unstable_getCurrentPriorityLevel:function(){return g}},SchedulerTracing:{__interactionsRef:null,__subscriberRef:null,unstable_clear:function(a){return a()},unstable_getCurrent:function(){return null},
|
|
28
|
-
unstable_getThreadID:function(){return++Pa},unstable_subscribe:function(a){},unstable_trace:function(a,b,d){return d()},unstable_unsubscribe:function(a){},unstable_wrap:function(a){return a}}});var fa=Object.prototype.hasOwnProperty,ha={key:!0,ref:!0,__self:!0,__source:!0},la=/\/+/g,H=[];r={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=ia(null,null,b,d);V(a,ya,b);ja(b)},count:function(a){return V(a,function(){return null},
|
|
29
|
-
null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){S(a)?void 0:q("143");return a}},createRef:function(){return{current:null}},Component:t,PureComponent:N,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:Ca,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:Ba,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:Ea,render:a}},lazy:function(a){return{$$typeof:Ha,
|
|
30
|
-
_ctor:a,_status:-1,_result:null}},memo:function(a,b){return{$$typeof:Ga,type:a,compare:void 0===b?null:b}},useCallback:function(a,b){return m().useCallback(a,b)},useContext:function(a,b){return m().useContext(a,b)},useEffect:function(a,b){return m().useEffect(a,b)},useImperativeHandle:function(a,b,d){return m().useImperativeHandle(a,b,d)},useDebugValue:function(a,b){},useLayoutEffect:function(a,b){return m().useLayoutEffect(a,b)},useMemo:function(a,b){return m().useMemo(a,b)},useReducer:function(a,
|
|
31
|
-
b,d){return m().useReducer(a,b,d)},useRef:function(a){return m().useRef(a)},useState:function(a){return m().useState(a)},Fragment:r,StrictMode:X,Suspense:Fa,createElement:ea,cloneElement:function(a,b,d){null===a||void 0===a?q("267",a):void 0;var c=void 0,e=I({},a.props),g=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=R.current);void 0!==b.key&&(g=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)fa.call(b,c)&&!ha.hasOwnProperty(c)&&(e[c]=void 0===
|
|
32
|
-
b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1<c){l=Array(c);for(var m=0;m<c;m++)l[m]=arguments[m+2];e.children=l}return{$$typeof:y,type:a.type,key:g,ref:k,props:e,_owner:h}},createFactory:function(a){var b=ea.bind(null,a);b.type=a;return b},isValidElement:S,version:"16.8.1",unstable_ConcurrentMode:Da,unstable_Profiler:Aa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:e};r=(X={default:r},r)||X;return r.default||r});
|
package/static/ssr/index.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import express from 'express';
|
|
4
|
-
import fetch from 'node-fetch';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import ReactDOMServer from 'react-dom/server';
|
|
7
|
-
import NodeCache from "node-cache";
|
|
8
|
-
import { XMLHttpRequest } from 'xmlhttprequest';
|
|
9
|
-
|
|
10
|
-
const myCache = new NodeCache();
|
|
11
|
-
async function cacheFetch(args, callback) {
|
|
12
|
-
const cacheKey = typeof args === 'string' ? args : args.key;
|
|
13
|
-
const cached = myCache.get(cacheKey);
|
|
14
|
-
if (cached) return Promise.resolve(cached);
|
|
15
|
-
|
|
16
|
-
const result = await callback();
|
|
17
|
-
myCache.set(cacheKey, result);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// In the DOM, these are global.
|
|
22
|
-
globalThis.React = React;
|
|
23
|
-
globalThis.ReactDOM = ReactDOMServer;
|
|
24
|
-
globalThis.XMLHttpRequest = XMLHttpRequest;
|
|
25
|
-
globalThis.File = class File {};
|
|
26
|
-
|
|
27
|
-
globalThis.__noodl_modules = [];
|
|
28
|
-
globalThis.Noodl = {
|
|
29
|
-
defineModule: function (m) {
|
|
30
|
-
globalThis.__noodl_modules.push(m);
|
|
31
|
-
},
|
|
32
|
-
deployed: true
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
globalThis.projectData = {{#export#}};
|
|
36
|
-
|
|
37
|
-
// Add some ugly polyfill
|
|
38
|
-
globalThis.requestAnimationFrame = (callback) => setImmediate(callback);
|
|
39
|
-
globalThis.fetch = async (args) => {
|
|
40
|
-
if (typeof args === 'string') {
|
|
41
|
-
const relativePath = '.' + args;
|
|
42
|
-
if (args.startsWith('/noodl_bundles') && fs.existsSync(relativePath)) {
|
|
43
|
-
const fileContent = await fs.promises.readFile(relativePath, 'utf-8');
|
|
44
|
-
return Promise.resolve({
|
|
45
|
-
status: 200,
|
|
46
|
-
json() {
|
|
47
|
-
return Promise.resolve(JSON.parse(fileContent));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return await fetch(args);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
class LocalStorageMock {
|
|
56
|
-
constructor() {
|
|
57
|
-
this.store = {};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getItem(key) {
|
|
61
|
-
return this.store[key] || null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setItem(key, value) {
|
|
65
|
-
this.store[key] = value.toString();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
removeItem(key) {
|
|
69
|
-
delete this.store[key];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
clear() {
|
|
73
|
-
this.store = {};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get(key) {
|
|
77
|
-
return this.store[key] || null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set(key, value) {
|
|
81
|
-
this.store[key] = value.toString();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
delete(key) {
|
|
85
|
-
delete this.store[key];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Allow direct access like localStorageMock['key']
|
|
89
|
-
get store() {
|
|
90
|
-
return this._store;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
set store(data) {
|
|
94
|
-
this._store = data;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
globalThis.localStorage = new LocalStorageMock();
|
|
99
|
-
|
|
100
|
-
// Import the Noodl runtime
|
|
101
|
-
require('./noodl.deploy');
|
|
102
|
-
|
|
103
|
-
// From that file we get some runtime stuff defined on "NoodlSSR"
|
|
104
|
-
const { createElement, ssrSetupRuntime } = globalThis.NoodlSSR;
|
|
105
|
-
|
|
106
|
-
const PORT = process.env.PORT || 3000;
|
|
107
|
-
const app = express();
|
|
108
|
-
|
|
109
|
-
app.use(express.static('public', { index: false }));
|
|
110
|
-
|
|
111
|
-
function log(...args) {
|
|
112
|
-
// Uncomment to see full request log
|
|
113
|
-
// console.log(...args);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let htmlData = '';
|
|
117
|
-
|
|
118
|
-
async function setup() {
|
|
119
|
-
htmlData = await fs.promises.readFile(path.resolve('./public/index.html'), 'utf8');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async function buildPage(path) {
|
|
123
|
-
return new Promise((resolve) => {
|
|
124
|
-
const noodlModules = globalThis.__noodl_modules;
|
|
125
|
-
const projectData = globalThis.projectData;
|
|
126
|
-
|
|
127
|
-
// TODO: Maybe fix page router
|
|
128
|
-
globalThis.location = {
|
|
129
|
-
pathname: path,
|
|
130
|
-
search: ""
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
log('Create Component...');
|
|
134
|
-
const ViewerComponent = createElement(noodlModules, projectData);
|
|
135
|
-
log('created.');
|
|
136
|
-
|
|
137
|
-
const noodlRuntime = ViewerComponent.props.noodlRuntime;
|
|
138
|
-
|
|
139
|
-
noodlRuntime.eventEmitter.on('SSR_PageLoading', (id) => {
|
|
140
|
-
console.log('SSR_PageLoading', id);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
noodlRuntime.eventEmitter.on('SSR_PageReady', (id) => {
|
|
144
|
-
console.log('SSR_PageReady', id);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
noodlRuntime.eventEmitter.on('rootComponentUpdated', async () => {
|
|
148
|
-
log('Spin up...');
|
|
149
|
-
noodlRuntime.rootComponent.triggerDidMount();
|
|
150
|
-
for (let index = 0; index < 1000; index++) {
|
|
151
|
-
await new Promise((resolve) => setImmediate(() => resolve(), 0));
|
|
152
|
-
noodlRuntime.rootComponent.triggerDidMount();
|
|
153
|
-
noodlRuntime._doUpdate();
|
|
154
|
-
}
|
|
155
|
-
log('done.');
|
|
156
|
-
|
|
157
|
-
log('Rendering...');
|
|
158
|
-
const output1 = ReactDOMServer.renderToString(ViewerComponent);
|
|
159
|
-
log('result:', output1);
|
|
160
|
-
|
|
161
|
-
const result = htmlData.replace('<div id="root"></div>', `<div id="root">${output1}</div>`);
|
|
162
|
-
|
|
163
|
-
// TODO: Inject Noodl.SEO.meta
|
|
164
|
-
|
|
165
|
-
resolve(result);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
log('Setup Runtime...');
|
|
169
|
-
ssrSetupRuntime(noodlRuntime, noodlModules, projectData);
|
|
170
|
-
log('done.');
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
app.get('*', async (req, res) => {
|
|
175
|
-
const path = req.path;
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
const cacheKey = `cache__${path}`
|
|
179
|
-
const cached = await cacheFetch(cacheKey, () => buildPage(req.path));
|
|
180
|
-
res.send(cached);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error(error);
|
|
183
|
-
|
|
184
|
-
// We failed to render SSR, lets just respond with the index.html file,
|
|
185
|
-
// and then the user should be able to render the page client side.
|
|
186
|
-
res.send(htmlData);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
setup().then(() => {
|
|
191
|
-
app.listen(PORT, () => {
|
|
192
|
-
console.log(`Server is listening on port ${PORT}`);
|
|
193
|
-
});
|
|
194
|
-
});
|
package/static/ssr/index.json
DELETED
package/static/ssr/package.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "noodl-ssr",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "esbuild index.js --bundle --outfile=server.js --platform=node",
|
|
8
|
-
"start": "node ./server.js",
|
|
9
|
-
"dev": "node --inspect-brk ./server.js"
|
|
10
|
-
},
|
|
11
|
-
"author": "",
|
|
12
|
-
"license": "ISC",
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"esbuild": "^0.18.10",
|
|
15
|
-
"express": "^4.18.2",
|
|
16
|
-
"node-fetch": "^3.3.1",
|
|
17
|
-
"node-cache": "^5.1.2",
|
|
18
|
-
"react": "^17.0.2",
|
|
19
|
-
"react-dom": "^17.0.2",
|
|
20
|
-
"xmlhttprequest": "^1.8.0"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"nodemon": "^2.0.22"
|
|
24
|
-
}
|
|
25
|
-
}
|