Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb36c641a9 | |||
ae74e0b4f2 | |||
d2a330e5d9 | |||
f40287fbb6 | |||
e27bd8a53f | |||
d6fc173a5b | |||
52c245d655 | |||
c2e0c0ab19 |
1943
package-lock.json
generated
1943
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-domtools",
|
"name": "@designestate/dees-domtools",
|
||||||
"version": "1.0.14",
|
"version": "1.0.18",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "tools to simplify complex css structures",
|
"description": "tools to simplify complex css structures",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -9,11 +9,12 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)",
|
"build": "(tsbuild --web && tsbundle npm)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
|
"@gitzone/tsbundle": "^1.0.69",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^14.0.5",
|
"@types/node": "^14.0.5",
|
||||||
@ -21,7 +22,7 @@
|
|||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^4.0.2",
|
"@pushrocks/lik": "^4.0.10",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@pushrocks/smartstate": "^1.0.15",
|
"@pushrocks/smartstate": "^1.0.15",
|
||||||
"lit-element": "^2.3.1"
|
"lit-element": "^2.3.1"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './domtools.plugins';
|
import * as plugins from './domtools.plugins';
|
||||||
import { Stringmap, FastMap } from '@pushrocks/lik';
|
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap';
|
||||||
|
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap';
|
||||||
|
|
||||||
export class DomTools {
|
export class DomTools {
|
||||||
public static async setupDomTools() {
|
public static async setupDomTools() {
|
||||||
@ -10,8 +11,8 @@ export class DomTools {
|
|||||||
// lets make sure the dom is ready
|
// lets make sure the dom is ready
|
||||||
const readyStateChangedFunc = () => {
|
const readyStateChangedFunc = () => {
|
||||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||||
domToolsInstance.headElement = document.querySelector('head');
|
domToolsInstance.elements.headElement = document.querySelector('head');
|
||||||
domToolsInstance.bodyElement = document.querySelector('body');
|
domToolsInstance.elements.bodyElement = document.querySelector('body');
|
||||||
domToolsInstance.domReady.resolve();
|
domToolsInstance.domReady.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -24,24 +25,36 @@ export class DomTools {
|
|||||||
return domToolsInstance;
|
return domToolsInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public smartstate = new plugins.smartstate.Smartstate();
|
||||||
|
|
||||||
public domToolsReady = plugins.smartpromise.defer();
|
public domToolsReady = plugins.smartpromise.defer();
|
||||||
public domReady = plugins.smartpromise.defer();
|
public domReady = plugins.smartpromise.defer();
|
||||||
public globalStylesReady = plugins.smartpromise.defer();
|
public globalStylesReady = plugins.smartpromise.defer();
|
||||||
|
|
||||||
// elements
|
// elements
|
||||||
public headElement: HTMLElement;
|
public elements: {
|
||||||
public bodyElement: HTMLElement;
|
headElement: HTMLElement;
|
||||||
|
bodyElement: HTMLElement;
|
||||||
|
} = {
|
||||||
|
headElement: null,
|
||||||
|
bodyElement: null,
|
||||||
|
};
|
||||||
|
|
||||||
public async setGlobalStyles(stylesText: string) {
|
public async setGlobalStyles(stylesText: string) {
|
||||||
await this.domReady.promise;
|
await this.domReady.promise;
|
||||||
const styleElement = document.createElement('style');
|
const styleElement = document.createElement('style');
|
||||||
styleElement.type = 'text/css';
|
styleElement.type = 'text/css';
|
||||||
styleElement.appendChild(document.createTextNode(stylesText));
|
styleElement.appendChild(document.createTextNode(stylesText));
|
||||||
this.headElement.appendChild(styleElement);
|
this.elements.headElement.appendChild(styleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private runOnceTrackerStringMap = new Stringmap();
|
private runOnceTrackerStringMap = new Stringmap();
|
||||||
private runOnceResultMap = new FastMap();
|
private runOnceResultMap = new FastMap();
|
||||||
|
/**
|
||||||
|
* run a function once and always get the Promise of the first execution
|
||||||
|
* @param identifierArg
|
||||||
|
* @param funcArg
|
||||||
|
*/
|
||||||
public async runOnce<T>(identifierArg: string, funcArg: () => Promise<T>) {
|
public async runOnce<T>(identifierArg: string, funcArg: () => Promise<T>) {
|
||||||
const runningId = `${identifierArg}+runningCheck`;
|
const runningId = `${identifierArg}+runningCheck`;
|
||||||
if(!this.runOnceTrackerStringMap.checkString(identifierArg)) {
|
if(!this.runOnceTrackerStringMap.checkString(identifierArg)) {
|
||||||
|
1
ts/domtools.classes.router.ts
Normal file
1
ts/domtools.classes.router.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import * as plugins from './domtools.plugins';
|
Reference in New Issue
Block a user