Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
0dd10351ad | |||
1d2b489830 | |||
446c9d0f59 | |||
a689252f4b | |||
2f1ce0058c | |||
a49c8e7aa7 | |||
73e5132f2e | |||
13e1d1fcb3 | |||
8c2ac4c6c9 | |||
29515b468e | |||
d2c6131e7c | |||
c9776fc683 | |||
9a77b5722a | |||
28d9d62bb4 | |||
9fa8754a15 | |||
6ff92ff880 | |||
eb9cae4be3 | |||
cd5cee545b | |||
fd8aa388ad | |||
58db360c79 | |||
bda524348e | |||
b33f7ed33e | |||
69d2434c90 | |||
9fd7931a4d |
6490
package-lock.json
generated
6490
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartntml",
|
"name": "@pushrocks/smartntml",
|
||||||
"version": "1.0.2",
|
"version": "2.0.1",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "lit-html for the backend",
|
"description": "lit-html for the backend",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -13,15 +13,18 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsbundle": "^2.0.4",
|
"@gitzone/tsbundle": "^2.0.7",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tsrun": "^1.2.39",
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
"@gitzone/tstest": "^1.0.73",
|
||||||
"@types/node": "^17.0.35"
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
|
"@types/node": "^18.7.23",
|
||||||
|
"why-is-node-running": "^2.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@happy-dom/global-registrator": "^4.1.0",
|
"@designestate/dees-element": "^2.0.20",
|
||||||
"lit": "^2.2.5"
|
"@happy-dom/global-registrator": "^8.9.0",
|
||||||
|
"@pushrocks/smartpromise": "^3.1.7"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
4565
pnpm-lock.yaml
generated
Normal file
4565
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
test/test.ts
12
test/test.ts
@ -1,20 +1,26 @@
|
|||||||
|
import log from 'why-is-node-running';
|
||||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartntml from '../ts/index.js';
|
import * as smartntml from '../ts/index.js';
|
||||||
|
|
||||||
let testSmartntmlInstance: smartntml.Smartntml;
|
let testSmartntmlInstance: smartntml.Smartntml;
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
testSmartntmlInstance = await smartntml.Smartntml.createAndInit();
|
testSmartntmlInstance = new smartntml.Smartntml();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should render a string', async () => {
|
tap.test('should render a string', async () => {
|
||||||
const arrayArg = [1, 2, 3, 4, 5, 6];
|
const arrayArg = [1, 2, 3, 4, 5, 6];
|
||||||
const stringResult = await testSmartntmlInstance.renderTemplateResult(testSmartntmlInstance.html`
|
const stringResult = await testSmartntmlInstance.renderTemplateResult(smartntml.deesElement.html`
|
||||||
<div class="hello">${arrayArg.map(
|
<div class="hello">${arrayArg.map(
|
||||||
(element) => testSmartntmlInstance.html`<div>${element}</div>`
|
(element) => smartntml.deesElement.html`<div>${element}</div>`
|
||||||
)}</div>
|
)}</div>
|
||||||
`);
|
`);
|
||||||
console.log(stringResult);
|
console.log(stringResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should log', async () => {
|
||||||
|
log();
|
||||||
|
setTimeout(()=> process.exit(0), 0);
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartntml',
|
name: '@pushrocks/smartntml',
|
||||||
version: '1.0.2',
|
version: '2.0.1',
|
||||||
description: 'lit-html for the backend'
|
description: 'lit-html for the backend'
|
||||||
}
|
}
|
||||||
|
33
ts/index.ts
33
ts/index.ts
@ -1,32 +1,23 @@
|
|||||||
|
import './instrument/happydom.js';
|
||||||
import * as plugins from './smartntml.plugins.js';
|
import * as plugins from './smartntml.plugins.js';
|
||||||
|
|
||||||
import type * as litTypes from 'lit';
|
const deesElement = plugins.deesElement;
|
||||||
|
export {
|
||||||
|
deesElement
|
||||||
|
}
|
||||||
|
|
||||||
export class Smartntml {
|
export class Smartntml {
|
||||||
// STATIC
|
|
||||||
public static async createAndInit() {
|
|
||||||
const smartntml = new Smartntml();
|
|
||||||
await smartntml.init();
|
|
||||||
return smartntml;
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCE
|
|
||||||
render: typeof litTypes.render;
|
|
||||||
html: typeof litTypes.html;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init() {
|
public async renderTemplateResult(templateResult: plugins.deesElement.TemplateResult, stripCommentsArg = true) {
|
||||||
const lit = await import('lit');
|
|
||||||
this.render = lit.render;
|
|
||||||
this.html = lit.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async renderTemplateResult(templateResult: litTypes.TemplateResult) {
|
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
this.render(templateResult, element);
|
plugins.deesElement.render(templateResult, element);
|
||||||
return element.innerHTML;
|
let stringResult = element.innerHTML;
|
||||||
|
if (stripCommentsArg) {
|
||||||
|
stringResult = stringResult.replace(/<!--(.*?)-->/g, '');
|
||||||
|
}
|
||||||
|
return stringResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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,2 +1,15 @@
|
|||||||
import { GlobalRegistrator } from '@happy-dom/global-registrator';
|
// @pushrocks scope
|
||||||
GlobalRegistrator.register();
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartpromise
|
||||||
|
}
|
||||||
|
|
||||||
|
// designestate
|
||||||
|
import * as deesElement from '@designestate/dees-element';
|
||||||
|
|
||||||
|
export {
|
||||||
|
deesElement
|
||||||
|
}
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
Reference in New Issue
Block a user