BREAKING CHANGE(improved the loading of the environment. Can now be used in sync environments.): update

This commit is contained in:
2023-03-30 11:08:29 +02:00
parent 2f1ce0058c
commit a689252f4b
7 changed files with 47 additions and 160 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartntml',
version: '1.0.12',
version: '2.0.0',
description: 'lit-html for the backend'
}

View File

@@ -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, '');

View File

@@ -0,0 +1,4 @@
// happy-dom setup
import { GlobalRegistrator } from '@happy-dom/global-registrator';
GlobalRegistrator.register();
window.location.href = 'http://localhost';

View File

@@ -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