BREAKING CHANGE(improved the loading of the environment. Can now be used in sync environments.): update
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartntml',
|
||||
version: '1.0.12',
|
||||
version: '2.0.0',
|
||||
description: 'lit-html for the backend'
|
||||
}
|
||||
|
32
ts/index.ts
32
ts/index.ts
@@ -1,35 +1,19 @@
|
||||
import './instrument/happydom.js';
|
||||
import * as plugins from './smartntml.plugins.js';
|
||||
import * as deesElement from '@designestate/dees-element';
|
||||
|
||||
const deesElement = plugins.deesElement;
|
||||
export {
|
||||
deesElement
|
||||
}
|
||||
|
||||
export class Smartntml {
|
||||
// STATIC
|
||||
public static async create() {
|
||||
const smartntml = new Smartntml();
|
||||
return smartntml;
|
||||
}
|
||||
|
||||
private static smartntmlSingletonDeferred: plugins.smartpromise.Deferred<Smartntml>;
|
||||
public static async createSingleton() {
|
||||
if (this.smartntmlSingletonDeferred) {
|
||||
return this.smartntmlSingletonDeferred.promise;
|
||||
}
|
||||
this.smartntmlSingletonDeferred = plugins.smartpromise.defer();
|
||||
const smartntmlInstance = await this.create();
|
||||
this.smartntmlSingletonDeferred.resolve(smartntmlInstance);
|
||||
return this.smartntmlSingletonDeferred.promise;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
private render = deesElement.render;
|
||||
public html = deesElement.html;
|
||||
public unsafeHTML = deesElement.unsafeHTML;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public async renderTemplateResult(templateResult: deesElement.TemplateResult, stripCommentsArg = true) {
|
||||
public async renderTemplateResult(templateResult: plugins.deesElement.TemplateResult, stripCommentsArg = true) {
|
||||
const element = document.createElement('div');
|
||||
this.render(templateResult, element);
|
||||
plugins.deesElement.render(templateResult, element);
|
||||
let stringResult = element.innerHTML;
|
||||
if (stripCommentsArg) {
|
||||
stringResult = stringResult.replace(/<!--(.*?)-->/g, '');
|
||||
|
4
ts/instrument/happydom.ts
Normal file
4
ts/instrument/happydom.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// happy-dom setup
|
||||
import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
||||
GlobalRegistrator.register();
|
||||
window.location.href = 'http://localhost';
|
@@ -1,8 +1,3 @@
|
||||
// happy-dom setup
|
||||
import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
||||
GlobalRegistrator.register();
|
||||
window.location.href = 'http://localhost';
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
@@ -10,4 +5,11 @@ export {
|
||||
smartpromise
|
||||
}
|
||||
|
||||
// designestate
|
||||
import * as deesElement from '@designestate/dees-element';
|
||||
|
||||
export {
|
||||
deesElement
|
||||
}
|
||||
|
||||
// third party scope
|
||||
|
Reference in New Issue
Block a user