|
@@ -5,6 +5,7 @@ import BasicInterceptor from '../../../../lib/util/BasicInterceptor';
|
|
|
|
|
|
|
|
import { Lsx } from '../../components/Lsx';
|
|
import { Lsx } from '../../components/Lsx';
|
|
|
import { LsxContext } from '../LsxContext';
|
|
import { LsxContext } from '../LsxContext';
|
|
|
|
|
+import { LsxCacheHelper } from '../LsxCacheHelper';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* The interceptor for lsx
|
|
* The interceptor for lsx
|
|
@@ -38,6 +39,8 @@ export class LsxPreRenderInterceptor extends BasicInterceptor {
|
|
|
const parsedHTML = context.parsedHTML;
|
|
const parsedHTML = context.parsedHTML;
|
|
|
const currentPagePath = context.currentPagePath;
|
|
const currentPagePath = context.currentPagePath;
|
|
|
|
|
|
|
|
|
|
+ this.initializeCache(contextName);
|
|
|
|
|
+
|
|
|
context.lsxContextMap = {};
|
|
context.lsxContextMap = {};
|
|
|
|
|
|
|
|
// TODO retrieve from args for interceptor
|
|
// TODO retrieve from args for interceptor
|
|
@@ -71,8 +74,24 @@ export class LsxPreRenderInterceptor extends BasicInterceptor {
|
|
|
return `<div id="${renderId}" />`;
|
|
return `<div id="${renderId}" />`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * initialize cache
|
|
|
|
|
+ * when contextName is 'preRender' -> clear cache
|
|
|
|
|
+ * when contextName is 'preRenderPreview' -> doesn't clear cache
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {string} contextName
|
|
|
|
|
+ *
|
|
|
|
|
+ * @memberOf LsxPreRenderInterceptor
|
|
|
|
|
+ */
|
|
|
|
|
+ initializeCache(contextName) {
|
|
|
|
|
+ if (contextName === 'preRender') {
|
|
|
|
|
+ LsxCacheHelper.clearAllStateCaches();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
|
|
* @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
|
|
|
|
|
+ *
|
|
|
* @param {number} length
|
|
* @param {number} length
|
|
|
* @return random strings
|
|
* @return random strings
|
|
|
*/
|
|
*/
|