Compare commits
255 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2110278cac | |||
| a3f7f456ef | |||
| ea895024c0 | |||
| 078ccdf1c3 | |||
| 918769e416 | |||
| 039ee19ffd | |||
| d16bc1652d | |||
| 6fa99f8ed8 | |||
| 5ce92130b4 | |||
| b0774b0cba | |||
| c44e19f3e0 | |||
| 07f09b4457 | |||
| 10ea4ca265 | |||
| dfd61ce744 | |||
| 3093ccd4f6 | |||
| eb1ac75e49 | |||
| 0683378e39 | |||
| 25a813d35f | |||
| 916fd48858 | |||
| 90bb1eb432 | |||
| 126e0fc900 | |||
| a20b321bb0 | |||
| 33721f86ab | |||
| 987c821eed | |||
| b0bed44810 | |||
| 0a7da5132d | |||
| b0bb8e9e2b | |||
| 1f346e24db | |||
| c34cca7eb6 | |||
| 15e58fbf5d | |||
| 2383e6ec21 | |||
| 5820bf81f6 | |||
| 9c6cfa3603 | |||
| cc934a9c0e | |||
| 16fd982c57 | |||
| 843c873254 | |||
| de1532627d | |||
| 618b6c5ba0 | |||
| 185b8a3947 | |||
| 77dddfc300 | |||
| bb6b4788b8 | |||
| c223038b39 | |||
| bd4fab872f | |||
| 385cab0b1b | |||
| b6620120e9 | |||
| 20e2149fd9 | |||
| af2eaf010f | |||
| fdfc7b4963 | |||
| 28be3f3095 | |||
| 3b946d7700 | |||
| 20e14bf14d | |||
| 23a9ea9dfc | |||
| a64af6f0ff | |||
| e456df08d1 | |||
| fd758e5ec1 | |||
| c45eac1796 | |||
| 5530642c3e | |||
| 6b8bd28057 | |||
| 1ba907d2cc | |||
| 6a7da41c98 | |||
| b67a602f78 | |||
| fa093e6f5b | |||
| 29f26d2ea7 | |||
| 77fe34ebac | |||
| 9ccd2fb2cf | |||
| 02f67c64df | |||
| 31dd8aa258 | |||
| 5f66725c6b | |||
| 89af82d2c4 | |||
| 98dab6c683 | |||
| 805ce5ed88 | |||
| 6f30b7618d | |||
| 42fd443ad8 | |||
| b2cb49a314 | |||
| d580df7e0a | |||
| 68ea3052fd | |||
| 252d56a321 | |||
| 497e6d1c11 | |||
| f1949bdc5d | |||
| d36d4a921a | |||
| e6194045d1 | |||
| 6147e5f02f | |||
| 0e64232e26 | |||
| fa66a51612 | |||
| b26cc004c1 | |||
| f923802ba1 | |||
| cf589d727f | |||
| b6720aef9d | |||
| ce945173ec | |||
| 0c016ea6d9 | |||
| 467b0d3011 | |||
| 333e991231 | |||
| 94c6c5a525 | |||
| bb64a8ecac | |||
| a4a26e44aa | |||
| f350905907 | |||
| a90e326f5e | |||
| 7c9aef342d | |||
| 99eab4e35f | |||
| 6d12aed53e | |||
| 29bcd17350 | |||
| f2e858d0b8 | |||
| 83a78a2c97 | |||
| d77c657d6a | |||
| f8f2f05396 | |||
| 7ee0d63a2c | |||
| e01f1a6a72 | |||
| c7b9374169 | |||
| dfe189ff1c | |||
| b777508b7a | |||
| 52664d8ea1 | |||
| 7bad85a1fa | |||
| e5056a7be3 | |||
| 989d4d35d2 | |||
| c5e75419b3 | |||
| ca52d06c60 | |||
| d33366c487 | |||
| 3bc5e1d0e2 | |||
| 96a88112dc | |||
| 6c0c1e165f | |||
| 653a4138a9 | |||
| d776843494 | |||
| 79e64c4cc2 | |||
| 7192d3fbf7 | |||
| 42bcb8243d | |||
| 52fb046fa8 | |||
| b83d3e1aed | |||
| 4ec8707596 | |||
| 69e1b52e72 | |||
| a5ff175913 | |||
| f84e7c48ae | |||
| 185d9ff957 | |||
| 6145bd66dc | |||
| d58272a604 | |||
| 68ca1e8906 | |||
| 7023888f38 | |||
| 1356666700 | |||
| b436fe77b0 | |||
| 3de788bb75 | |||
| d50e320f17 | |||
| a7532c8816 | |||
| 2d5944cdd7 | |||
| 5a8527068a | |||
| ffd0bb925a | |||
| 4a5fb3ef4b | |||
| a059c268af | |||
| 714aa77839 | |||
| 2527e6e586 | |||
| 88f7f20b6f | |||
| 8e23b7ebec | |||
| b3d12c39bf | |||
| d102d5a7e6 | |||
| 8be31958b4 | |||
| e21f6c3920 | |||
| 356a756962 | |||
| 0bb66e8221 | |||
| b70077c43f | |||
| 9c5f024e5f | |||
| 5eea208924 | |||
| f21fdb2eb8 | |||
| d6ea74cb71 | |||
| 10375576a7 | |||
| 367be854ff | |||
| 0933c1d83b | |||
| af1eb73028 | |||
| 4bff0091c9 | |||
| 7bae4585f3 | |||
| d9cdff2897 | |||
| 189060f11d | |||
| fc2dfa8018 | |||
| be44cb7a78 | |||
| de6aba4289 | |||
| 3babbce2c5 | |||
| 707956b7ee | |||
| c71a6170d5 | |||
| 3f98f2867c | |||
| 7c86f5a8f6 | |||
| 472ec3158e | |||
| 9a0d09d9de | |||
| 5975ca7320 | |||
| 97583c650d | |||
| f5fd0662d3 | |||
| 14c91ed81f | |||
| 1aabacdf87 | |||
| 1747afe04a | |||
| a1bd7f74a7 | |||
| 6ff89390b7 | |||
| 2ad8d0a9fd | |||
| ae01670361 | |||
| 5657b0be1d | |||
| 781ae3c3b1 | |||
| da79e623cc | |||
| 3ca6b5e34e | |||
| 98f0bc013d | |||
| d32a544de2 | |||
| 070221d6c9 | |||
| 19714854ba | |||
| 50ebea1b5f | |||
| df0527f3c1 | |||
| b620b7393e | |||
| ab5b9511fd | |||
| da86e64056 | |||
| effc331a67 | |||
| fa24708a47 | |||
| 31126e30eb | |||
| ef0a4eae80 | |||
| e711302c28 | |||
| 1cfc07fe8e | |||
| 7f221c1a8c | |||
| 09f927c0d4 | |||
| 1042e79625 | |||
| fced2efcbd | |||
| 83fe1d62e7 | |||
| 78bce9600c | |||
| 2860b5b6e0 | |||
| b802935d27 | |||
| b73a702b74 | |||
| b3deb31ab5 | |||
| 6ea5482e3d | |||
| 0ead7215ff | |||
| 286bb0887a | |||
| 4456f00816 | |||
| b60a1bebe0 | |||
| 94127227a6 | |||
| b5af1b1226 | |||
| a6f382dd7f | |||
| 0de00cb2c1 | |||
| 570a026cf8 | |||
| 48b5cc770c | |||
| 7ae2de5843 | |||
| e4d87ae882 | |||
| 259a669e24 | |||
| bf461dd1a0 | |||
| 63c9ae97d4 | |||
| a83239e0d9 | |||
| 8da64f1b50 | |||
| 2d4c0e4e49 | |||
| 1c8f7fa59e | |||
| a613c0aca2 | |||
| 127564cd71 | |||
| e077bf5b25 | |||
| 64a3f57813 | |||
| 1315e8c3f6 | |||
| d059862841 | |||
| ad34affb9e | |||
| 011b3fb76a | |||
| 47099d02b5 | |||
| f4029ed008 | |||
| d5732822e4 | |||
| c467a92e7c | |||
| 746c1148e3 | |||
| d75e66ba78 | |||
| 7c805a075e | |||
| 5e1a44ad88 | |||
| 093eae2c97 |
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@@ -1,137 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
401
changelog.md
Normal file
401
changelog.md
Normal file
@@ -0,0 +1,401 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-11-16 - 2.3.6 - fix(readme)
|
||||
Normalize README formatting and improve breakpoint helpers section
|
||||
|
||||
- Fixed inconsistent Markdown list formatting in the Features section (added space after list dash for emoji bullets)
|
||||
- Bolded the "Available breakpoint helpers" heading and added spacing for improved readability
|
||||
- Clarified breakpoint helper listing to ensure cssForPhone is documented
|
||||
|
||||
## 2025-11-16 - 2.3.5 - fix(dependencies)
|
||||
bump dependency versions in package.json
|
||||
|
||||
- Updated devDependencies:
|
||||
- - @git.zone/tsbuild: ^2.6.4 -> ^2.7.1
|
||||
- - @git.zone/tsbundle: ^2.4.0 -> ^2.5.1
|
||||
- - @git.zone/tstest: ^2.3.1 -> ^2.7.0
|
||||
- Updated dependencies:
|
||||
- - @push.rocks/smartjson: ^5.0.20 -> ^5.2.0
|
||||
- - @push.rocks/smartrouter: ^1.3.2 -> ^1.3.3
|
||||
- - @push.rocks/smartstate: ^2.0.20 -> ^2.0.27
|
||||
- - @push.rocks/smartstring: ^4.0.15 -> ^4.1.0
|
||||
|
||||
## 2025-11-16 - 2.3.4 - fix(domtools)
|
||||
Prevent race conditions during DomTools initialization and improve runOnce error handling
|
||||
|
||||
- Add a static initializationPromise to serialize and await concurrent DomTools.setupDomTools() calls to avoid race conditions when multiple initializations are requested.
|
||||
- Initialize Keyboard only after the document is ready (check document.readyState and use readystatechange listener) so document.body/head are available before creating the Keyboard instance; resolve domReady and domToolsReady appropriately.
|
||||
- Support ignoreGlobal path to create isolated DomTools instances while keeping global initialization guarded by initializationPromise.
|
||||
- Enhance runOnce: store errors from the first execution and re-throw them to all waiting callers; always clear the running flag in a finally block to prevent permanent stuck state.
|
||||
|
||||
## 2025-06-20 - 2.3.3 - fix(package.json)
|
||||
Update dependency versions and add pnpm package manager field
|
||||
|
||||
- Update @git.zone/tsbuild from ^2.2.1 to ^2.6.4
|
||||
- Update @git.zone/tsbundle from ^2.2.5 to ^2.4.0
|
||||
- Update @git.zone/tstest from ^1.0.96 to ^2.3.1
|
||||
- Update @push.rocks/tapbundle from ^5.5.6 to ^6.0.3
|
||||
- Update @push.rocks/lik from ^6.1.0 to ^6.2.2
|
||||
- Update @push.rocks/smartpromise from ^4.2.2 to ^4.2.3
|
||||
- Update @push.rocks/smartrx from ^3.0.7 to ^3.0.10
|
||||
- Update @push.rocks/smartstate from ^2.0.19 to ^2.0.20
|
||||
- Update lenis from ^1.1.20 to ^1.3.4
|
||||
- Update lit from ^3.2.1 to ^3.3.0
|
||||
- Add packageManager field for pnpm
|
||||
|
||||
## 2025-02-01 - 2.3.2 - fix(scroller)
|
||||
Rename method from scrollToElement to toElement for consistency
|
||||
|
||||
- Updated method name in Scroller class for better coherence with existing naming conventions.
|
||||
|
||||
## 2025-01-31 - 2.3.1 - fix(scroller)
|
||||
Removed passive option from scroll event listener
|
||||
|
||||
- The 'passive: true' option was removed from the native scroll event listener attachment.
|
||||
|
||||
## 2025-01-31 - 2.3.0 - feat(scroller)
|
||||
Enhance Scroller class with callback execution and adaptive scroll listener
|
||||
|
||||
- Added support for executing scroll callbacks in the Scroller class.
|
||||
- Integrated adaptive scrolling mechanism using Lenis, with native smooth scrolling detection.
|
||||
- Ensured seamless switching between native scroll listener and Lenis scroll listener.
|
||||
|
||||
## 2025-01-31 - 2.2.0 - feat(core)
|
||||
Enhance scrolling capabilities by integrating Scroller class and adding lenis support
|
||||
|
||||
- Replaced SweetScroll setup in domtools.classes.domtools.ts with Scroller class.
|
||||
- Moved SweetScroll initialization and methods to new Scroller class.
|
||||
- Added lenis support in the Scroller class for enhanced scrolling capabilities.
|
||||
- Updated dev and dependencies versions in package.json.
|
||||
|
||||
## 2025-01-09 - 2.1.1 - fix(themamanager)
|
||||
Fixed automatic global theme change subscription for background updates.
|
||||
|
||||
- Corrected the logic for updating the document's background color upon theme changes using themeObservable subscription.
|
||||
|
||||
## 2025-01-09 - 2.1.0 - feat(themeManager)
|
||||
Exposed method to enable automatic global theme change.
|
||||
|
||||
- Enable easier application of dark and bright themes by exposing a method.
|
||||
- Updated devDependencies and dependencies in package.json to latest versions.
|
||||
|
||||
## 2024-10-21 - 2.0.65 - fix(ThemeManager)
|
||||
Refactor ThemeManager class to separate global style setting logic
|
||||
|
||||
- Moved logic to set global styles into a dedicated function setGlobalStylesOnPurpose in ThemeManager.
|
||||
|
||||
## 2024-10-06 - 2.0.64 - fix(pluginexports)
|
||||
Add missing import for smartrouter in pluginexports.
|
||||
|
||||
- Fixed a missing import for smartrouter in ts/domtools.pluginexports.ts.
|
||||
|
||||
## 2024-10-06 - 2.0.63 - fix(dependencies)
|
||||
Update @push.rocks/smartrouter to version ^1.3.2 for better compatibility
|
||||
|
||||
- Updated @push.rocks/smartrouter from version ^1.2.1 to ^1.3.2 in package.json.
|
||||
|
||||
## 2024-10-06 - 2.0.62 - fix(dependencies)
|
||||
Update dependencies to resolve potential issues and improve stability
|
||||
|
||||
|
||||
## 2024-10-04 - 2.0.61 - fix(core)
|
||||
Correct import statement for SweetScroll.
|
||||
|
||||
- Fix import syntax for SweetScroll in domtools.pluginexports.ts
|
||||
|
||||
## 2024-10-02 - 2.0.60 - fix(dependencies)
|
||||
Update dependencies to latest versions
|
||||
|
||||
- Bump @git.zone/tsbuild version from 2.1.82 to 2.1.84
|
||||
- Bump @push.rocks/tapbundle version from 5.0.23 to 5.3.0
|
||||
- Bump @types/node version from 20.14.9 to 22.7.4
|
||||
- Bump @api.global/typedrequest version from 3.0.30 to 3.0.32
|
||||
- Bump @push.rocks/smartstate version from 2.0.17 to 2.0.18
|
||||
- Bump lit version from 3.1.4 to 3.2.0
|
||||
|
||||
## 2024-10-02 - 2.0.59 - fix(core)
|
||||
Refactor plugin exports to improve modularity
|
||||
|
||||
- Refactored the plugin exports to be more modular and organized.
|
||||
- Replaced redundant plugin object definition in ts/index.ts with a simpler import and export pattern.
|
||||
|
||||
## 2024-07-01 - 2.0.58 - fix(dependencies)
|
||||
Update dependencies and correct font family in styles
|
||||
|
||||
- Updated @git.zone/tsbuild to ^2.1.82
|
||||
- Updated @git.zone/tstest to ^1.0.90
|
||||
- Updated @push.rocks/tapbundle to ^5.0.23
|
||||
- Updated @types/node to ^20.14.9
|
||||
- Updated @api.global/typedrequest to ^3.0.30
|
||||
- Updated @design.estate/dees-comms to ^1.0.27
|
||||
- Updated @push.rocks/lik to ^6.0.15
|
||||
- Updated @push.rocks/smartjson to ^5.0.20
|
||||
- Updated @push.rocks/smartpromise to ^4.0.4
|
||||
- Updated @push.rocks/webrequest to ^3.0.37
|
||||
- Updated @push.rocks/webstore to ^2.0.20
|
||||
- Updated lit to ^3.1.4
|
||||
- Updated default font family to 'Geist Sans', 'Inter', sans-serif
|
||||
|
||||
## 2024-04-20 - 2.0.57 - Documentation
|
||||
Update to project documentation
|
||||
|
||||
- Updated existing documentation to reflect recent changes
|
||||
|
||||
## 2023-10-23 - 2.0.42...2.0.55 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2023-10-07 - 2.0.41...2.0.51 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2023-09-17 - 2.0.40 - Core
|
||||
Fixes in core functionality
|
||||
|
||||
- Fix(core): update
|
||||
|
||||
## 2023-08-07 - 2.0.36...2.0.38 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2023-04-05 - 2.0.28...2.0.30 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2023-01-07 - 2.0.26...2.0.27 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2022-12-31 - 2.0.24...2.0.25 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2022-08-01 - 2.0.22...2.0.23 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2022-05-01 - 2.0.19...2.0.21 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2022-04-22 - 2.0.18...2.0.19 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2022-04-21 - 2.0.10...2.0.17 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2022-03-18 - 2.0.0 - Core
|
||||
Major release
|
||||
|
||||
- Fix(core): update
|
||||
|
||||
## 2021-11-21 - 1.0.98...1.0.99 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2021-09-16 - 1.0.94...1.0.95 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2021-09-08 - 1.0.91...1.0.93 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2021-09-01 - 1.0.89...1.0.90 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2021-08-19 - 1.0.87 - Core
|
||||
Fixes in core functionality
|
||||
|
||||
- Fix(core): update
|
||||
|
||||
## 2021-03-10 - 1.0.84...1.0.86 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-12-07 - 1.0.79...1.0.83 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-11-30 - 1.0.74...1.0.77 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-11-24 - 1.0.66...1.0.70 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-11-23 - 1.0.64...1.0.65 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2020-11-06 - 1.0.61...1.0.63 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-10-07 - 1.0.53...1.0.55 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-09-16 - 1.0.49...1.0.52 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-09-13 - 1.0.45...1.0.47 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-09-12 - 1.0.41...1.0.44 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-07-27 - 1.0.38...1.0.40 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-06-28 - 1.0.29...1.0.36 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-06-03 - 1.0.26...1.0.28 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-05-28 - 1.0.21...1.0.25 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-05-27 - 1.0.18...1.0.20 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-05-26 - 1.0.16...1.0.17 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2020-05-25 - 1.0.14...1.0.15 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
|
||||
## 2020-05-24 - 1.0.11...1.0.13 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
|
||||
## 2020-05-23 - 1.0.3...1.0.10 - Core
|
||||
Multiple updates and fixes
|
||||
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- Fix(core): update
|
||||
- ...
|
||||
1
license
1
license
@@ -1,4 +1,5 @@
|
||||
Copyright (c) 2020 Lossless GmbH (hello@lossless.com)
|
||||
Copyright (c) 2017 Nathan Friend (ts-keycode-enum)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,17 +2,36 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "designestate",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "design.estate",
|
||||
"gitrepo": "dees-domtools",
|
||||
"shortDescription": "tools to simplify complex css structures",
|
||||
"npmPackagename": "@designestate/dees-domtools",
|
||||
"description": "A package providing tools to simplify complex CSS structures and web development tasks, featuring TypeScript support and integration with various web technologies.",
|
||||
"npmPackagename": "@design.estate/dees-domtools",
|
||||
"license": "MIT",
|
||||
"projectDomain": "design.estate"
|
||||
"projectDomain": "design.estate",
|
||||
"keywords": [
|
||||
"CSS tools",
|
||||
"web development",
|
||||
"TypeScript support",
|
||||
"CSS structure simplification",
|
||||
"web components",
|
||||
"theme management",
|
||||
"DOM manipulation",
|
||||
"responsive design",
|
||||
"design system",
|
||||
"lit element",
|
||||
"keyboard event handling",
|
||||
"state management",
|
||||
"routing",
|
||||
"performance optimization"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
||||
11448
package-lock.json
generated
11448
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
71
package.json
71
package.json
@@ -1,38 +1,44 @@
|
||||
{
|
||||
"name": "@designestate/dees-domtools",
|
||||
"version": "1.0.63",
|
||||
"name": "@design.estate/dees-domtools",
|
||||
"version": "2.3.6",
|
||||
"private": false,
|
||||
"description": "tools to simplify complex css structures",
|
||||
"description": "A package providing tools to simplify complex CSS structures and web development tasks, featuring TypeScript support and integration with various web technologies.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web && tsbundle npm)",
|
||||
"format": "(gitzone format)"
|
||||
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||
"format": "(gitzone format)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.14.6",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@git.zone/tsbuild": "^2.7.1",
|
||||
"@git.zone/tsbundle": "^2.5.1",
|
||||
"@git.zone/tstest": "^2.7.0",
|
||||
"@push.rocks/tapbundle": "^6.0.3",
|
||||
"@types/node": "^22.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.54",
|
||||
"@designestate/dees-comms": "^1.0.7",
|
||||
"@pushrocks/lik": "^4.0.17",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartrouter": "^1.0.4",
|
||||
"@pushrocks/smartstate": "^1.0.17",
|
||||
"@pushrocks/webrequest": "^2.0.13",
|
||||
"@pushrocks/websetup": "^3.0.11",
|
||||
"@pushrocks/webstore": "^1.0.16",
|
||||
"lit-element": "^2.4.0",
|
||||
"@api.global/typedrequest": "^3.1.10",
|
||||
"@design.estate/dees-comms": "^1.0.27",
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartjson": "^5.2.0",
|
||||
"@push.rocks/smartmarkdown": "^3.0.3",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartrouter": "^1.3.3",
|
||||
"@push.rocks/smartrx": "^3.0.10",
|
||||
"@push.rocks/smartstate": "^2.0.27",
|
||||
"@push.rocks/smartstring": "^4.1.0",
|
||||
"@push.rocks/smarturl": "^3.1.0",
|
||||
"@push.rocks/webrequest": "^3.0.37",
|
||||
"@push.rocks/websetup": "^3.0.19",
|
||||
"@push.rocks/webstore": "^2.0.20",
|
||||
"lenis": "^1.3.4",
|
||||
"lit": "^3.3.0",
|
||||
"sweet-scroll": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
@@ -49,5 +55,22 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
],
|
||||
"keywords": [
|
||||
"CSS tools",
|
||||
"web development",
|
||||
"TypeScript support",
|
||||
"CSS structure simplification",
|
||||
"web components",
|
||||
"theme management",
|
||||
"DOM manipulation",
|
||||
"responsive design",
|
||||
"design system",
|
||||
"lit element",
|
||||
"keyboard event handling",
|
||||
"state management",
|
||||
"routing",
|
||||
"performance optimization"
|
||||
],
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
|
||||
11736
pnpm-lock.yaml
generated
Normal file
11736
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
513
readme.md
513
readme.md
@@ -1,39 +1,494 @@
|
||||
# @designestate/dees-domtools
|
||||
tools to simplify complex css structures
|
||||
# @design.estate/dees-domtools
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-domtools)
|
||||
* [gitlab.com (source)](https://gitlab.com/designestate/dees-domtools)
|
||||
* [github.com (source mirror)](https://github.com/designestate/dees-domtools)
|
||||
* [docs (typedoc)](https://designestate.gitlab.io/dees-domtools/)
|
||||
> 🎨 A comprehensive TypeScript toolkit for simplifying DOM manipulation, CSS management, and web component development
|
||||
|
||||
## Status for master
|
||||
Modern web development made elegant. `@design.estate/dees-domtools` provides a powerful suite of utilities for managing complex CSS structures, handling browser events, implementing smooth scrolling, and building responsive web applications with ease.
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
## Features
|
||||
|
||||
## Usage
|
||||
- 🚀 **Smart DOM Management** - Singleton-based DomTools instance with race-condition-free initialization
|
||||
- 📱 **Responsive Breakpoints** - Built-in support for desktop, tablet, phablet, and phone viewports with container queries
|
||||
- 🎭 **Theme Management** - Automatic dark/light mode detection and switching with RxJS observables
|
||||
- ⌨️ **Keyboard Shortcuts** - Elegant keyboard event handling with combo support
|
||||
- 📜 **Smooth Scrolling** - Native and Lenis-powered smooth scrolling with automatic detection
|
||||
- 🎯 **State Management** - Integrated state management with smartstate
|
||||
- 🧭 **Routing** - Client-side routing with smartrouter
|
||||
- 🌐 **WebSetup** - Easy management of website metadata, favicons, and SEO tags
|
||||
- 💅 **CSS Utilities** - Grid helpers, breakpoint utilities, and base styles for web components
|
||||
|
||||
Use TypeScript for best in class intellisense
|
||||
## Installation
|
||||
|
||||
## Contribution
|
||||
```bash
|
||||
npm install @design.estate/dees-domtools
|
||||
```
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
Or with pnpm:
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
```bash
|
||||
pnpm add @design.estate/dees-domtools
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
## Quick Start
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
```typescript
|
||||
import { DomTools } from '@design.estate/dees-domtools';
|
||||
|
||||
// Initialize DomTools (singleton pattern - safe to call multiple times)
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
|
||||
// Wait for DOM to be ready
|
||||
await domtools.domReady.promise;
|
||||
|
||||
// Now you're ready to rock! 🎸
|
||||
console.log('DOM is ready, head and body elements are available');
|
||||
```
|
||||
|
||||
## Core API
|
||||
|
||||
### DomTools Instance
|
||||
|
||||
The `DomTools` class is the heart of the library. It provides a singleton instance that manages all the utilities.
|
||||
|
||||
```typescript
|
||||
import { DomTools } from '@design.estate/dees-domtools';
|
||||
|
||||
// Setup with options
|
||||
const domtools = await DomTools.setupDomTools({
|
||||
ignoreGlobal: false // Set to true to create isolated instance
|
||||
});
|
||||
|
||||
// Access DOM elements (available after domReady)
|
||||
await domtools.domReady.promise;
|
||||
const head = domtools.elements.headElement;
|
||||
const body = domtools.elements.bodyElement;
|
||||
```
|
||||
|
||||
**Key Properties:**
|
||||
|
||||
- `domtools.router` - SmartRouter instance for client-side routing
|
||||
- `domtools.themeManager` - Theme management (dark/light mode)
|
||||
- `domtools.scroller` - Smooth scrolling utilities
|
||||
- `domtools.keyboard` - Keyboard event handling
|
||||
- `domtools.websetup` - Website metadata management
|
||||
- `domtools.smartstate` - State management
|
||||
- `domtools.deesComms` - Communication utilities
|
||||
|
||||
**Lifecycle Promises:**
|
||||
|
||||
- `domtools.domToolsReady.promise` - Resolves when DomTools is initialized
|
||||
- `domtools.domReady.promise` - Resolves when DOM is interactive/complete
|
||||
- `domtools.globalStylesReady.promise` - Resolves when global styles are set
|
||||
|
||||
### Responsive Breakpoints
|
||||
|
||||
Built-in breakpoint system with both media queries and container queries:
|
||||
|
||||
```typescript
|
||||
import { breakpoints, css } from '@design.estate/dees-domtools';
|
||||
import { css as litCss } from 'lit';
|
||||
|
||||
// Breakpoint values (in pixels)
|
||||
breakpoints.desktop // 1600px
|
||||
breakpoints.notebook // 1240px
|
||||
breakpoints.tablet // 1024px
|
||||
breakpoints.phablet // 600px
|
||||
breakpoints.phone // 400px
|
||||
|
||||
// Use with Lit components
|
||||
const myStyles = litCss`
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
${breakpoints.cssForTablet(litCss`
|
||||
.container {
|
||||
padding: 10px;
|
||||
}
|
||||
`)}
|
||||
|
||||
${breakpoints.cssForPhone(litCss`
|
||||
.container {
|
||||
padding: 5px;
|
||||
}
|
||||
`)}
|
||||
`;
|
||||
```
|
||||
|
||||
**Available breakpoint helpers:**
|
||||
|
||||
- `cssForDesktop(css)` - Styles for 1600px and above
|
||||
- `cssForNotebook(css)` - Styles for 1240px and below
|
||||
- `cssForTablet(css)` - Styles for 1024px and below
|
||||
- `cssForPhablet(css)` - Styles for 600px and below
|
||||
- `cssForPhone(css)` - Styles for 400px and below
|
||||
|
||||
### Theme Management
|
||||
|
||||
Automatic theme detection with system preference support:
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
const { themeManager } = domtools;
|
||||
|
||||
// Toggle between dark and light
|
||||
themeManager.toggleDarkBright();
|
||||
|
||||
// Set specific theme
|
||||
themeManager.goDark();
|
||||
themeManager.goBright();
|
||||
|
||||
// Enable automatic global background changes
|
||||
await themeManager.enableAutomaticGlobalThemeChange();
|
||||
|
||||
// Subscribe to theme changes
|
||||
themeManager.themeObservable.subscribe((isBright) => {
|
||||
console.log(`Theme is now: ${isBright ? 'light' : 'dark'}`);
|
||||
});
|
||||
|
||||
// Check current theme
|
||||
if (themeManager.goBrightBoolean) {
|
||||
console.log('Light mode active');
|
||||
}
|
||||
```
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
Handle keyboard events with ease, including complex combinations:
|
||||
|
||||
```typescript
|
||||
import { Keyboard, Key } from '@design.estate/dees-domtools';
|
||||
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
await domtools.domReady.promise;
|
||||
|
||||
// Access the keyboard instance
|
||||
const { keyboard } = domtools;
|
||||
|
||||
// Listen for Ctrl+S
|
||||
keyboard.on([Key.Ctrl, Key.S]).subscribe((event) => {
|
||||
event.preventDefault();
|
||||
console.log('Save triggered!');
|
||||
});
|
||||
|
||||
// Listen for Ctrl+Shift+P
|
||||
keyboard.on([Key.Ctrl, Key.Shift, Key.P]).subscribe(() => {
|
||||
console.log('Command palette opened!');
|
||||
});
|
||||
|
||||
// Programmatically trigger key presses
|
||||
keyboard.triggerKeyPress([Key.Ctrl, Key.S]);
|
||||
|
||||
// Clean up when done
|
||||
keyboard.stopListening();
|
||||
```
|
||||
|
||||
**Available Keys:**
|
||||
|
||||
All standard keyboard keys are available in the `Key` enum, including:
|
||||
|
||||
- Modifiers: `Ctrl`, `Shift`, `Alt`
|
||||
- Letters: `A` through `Z`
|
||||
- Numbers: `Zero` through `Nine`
|
||||
- Function keys: `F1` through `F12`
|
||||
- Navigation: `Home`, `End`, `PageUp`, `PageDown`, arrows
|
||||
- And many more...
|
||||
|
||||
### Smooth Scrolling
|
||||
|
||||
Powerful scrolling utilities with Lenis integration:
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
const { scroller } = domtools;
|
||||
|
||||
// Scroll to an element smoothly
|
||||
const targetElement = document.querySelector('#section-2');
|
||||
await scroller.toElement(targetElement, {
|
||||
duration: 1000,
|
||||
easing: 'easeInOutQuad'
|
||||
});
|
||||
|
||||
// Enable Lenis smooth scrolling
|
||||
await scroller.enableLenisScroll({
|
||||
disableOnNativeSmoothScroll: true // Auto-disable if browser has native smooth scroll
|
||||
});
|
||||
|
||||
// Register scroll callbacks
|
||||
scroller.onScroll(() => {
|
||||
console.log('Page scrolled!');
|
||||
});
|
||||
|
||||
// Detect if native smooth scrolling is enabled
|
||||
const hasNativeSmooth = await scroller.detectNativeSmoothScroll();
|
||||
```
|
||||
|
||||
### CSS Utilities
|
||||
|
||||
Helper functions for common CSS patterns:
|
||||
|
||||
```typescript
|
||||
import { css } from '@design.estate/dees-domtools';
|
||||
|
||||
// Create responsive grid columns
|
||||
const gridTemplate = css.cssGridColumns(4, 16);
|
||||
// Returns: calc((100%/4) - (48px/4)) calc((100%/4) - (48px/4)) ...
|
||||
|
||||
// Use in your styles
|
||||
const styles = `
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: ${gridTemplate};
|
||||
gap: 16px;
|
||||
}
|
||||
`;
|
||||
```
|
||||
|
||||
### Global Styles & External Resources
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
|
||||
// Add global CSS
|
||||
await domtools.setGlobalStyles(`
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
`);
|
||||
|
||||
// Load external CSS
|
||||
await domtools.setExternalCss('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
|
||||
|
||||
// Load external JavaScript
|
||||
await domtools.setExternalScript('https://cdn.example.com/analytics.js');
|
||||
```
|
||||
|
||||
### Website Metadata
|
||||
|
||||
Manage your website's metadata easily:
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
|
||||
await domtools.setWebsiteInfo({
|
||||
metaObject: {
|
||||
title: 'My Awesome App',
|
||||
description: 'The best app ever created',
|
||||
keywords: ['awesome', 'app', 'web'],
|
||||
author: 'Your Name'
|
||||
},
|
||||
faviconUrl: '/favicon.ico',
|
||||
appleTouchIconUrl: '/apple-touch-icon.png'
|
||||
});
|
||||
```
|
||||
|
||||
### Web Component Base Styles
|
||||
|
||||
Kickstart your Lit elements with pre-configured styles:
|
||||
|
||||
```typescript
|
||||
import { LitElement } from 'lit';
|
||||
import { elementBasic } from '@design.estate/dees-domtools';
|
||||
|
||||
class MyElement extends LitElement {
|
||||
static styles = [elementBasic.staticStyles];
|
||||
|
||||
async connectedCallback() {
|
||||
super.connectedCallback();
|
||||
await elementBasic.setup(this);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**The `elementBasic.staticStyles` includes:**
|
||||
|
||||
- Box-sizing reset
|
||||
- Smooth transitions for background and color
|
||||
- Custom scrollbar styles
|
||||
- Default font family (Geist Sans, Inter fallback)
|
||||
|
||||
### State Management
|
||||
|
||||
Integrated state management with smartstate:
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
|
||||
// Access the state part
|
||||
const state = domtools.domToolsStatePart;
|
||||
|
||||
// Get current state
|
||||
const currentState = state.getState();
|
||||
console.log(currentState.virtualViewport); // 'native'
|
||||
console.log(currentState.jwt); // null
|
||||
|
||||
// Update state
|
||||
state.setState({
|
||||
virtualViewport: 'tablet',
|
||||
jwt: 'your-token-here'
|
||||
});
|
||||
|
||||
// Subscribe to state changes
|
||||
state.subscribe((newState) => {
|
||||
console.log('State updated:', newState);
|
||||
});
|
||||
```
|
||||
|
||||
### Run Once Pattern
|
||||
|
||||
Execute expensive operations only once, even if called multiple times:
|
||||
|
||||
```typescript
|
||||
const domtools = await DomTools.setupDomTools();
|
||||
|
||||
// This will only execute once, even if called multiple times
|
||||
const result = await domtools.runOnce('myExpensiveOperation', async () => {
|
||||
console.log('Running expensive operation...');
|
||||
await someExpensiveAsyncOperation();
|
||||
return 'result';
|
||||
});
|
||||
|
||||
// Subsequent calls return the same result without re-executing
|
||||
const sameResult = await domtools.runOnce('myExpensiveOperation', async () => {
|
||||
console.log('This will never run!');
|
||||
return 'different result';
|
||||
});
|
||||
|
||||
console.log(result === sameResult); // true
|
||||
```
|
||||
|
||||
Error handling is built-in - if the function throws, all waiting callers receive the same error.
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Combining Features
|
||||
|
||||
Here's a real-world example combining multiple features:
|
||||
|
||||
```typescript
|
||||
import { DomTools, breakpoints, elementBasic, Key } from '@design.estate/dees-domtools';
|
||||
import { LitElement, html, css as litCss } from 'lit';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
|
||||
@customElement('my-app')
|
||||
class MyApp extends LitElement {
|
||||
static styles = [
|
||||
elementBasic.staticStyles,
|
||||
litCss`
|
||||
:host {
|
||||
display: block;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
${breakpoints.cssForTablet(litCss`
|
||||
:host {
|
||||
padding: 1rem;
|
||||
}
|
||||
`)}
|
||||
`
|
||||
];
|
||||
|
||||
private domtools?: DomTools;
|
||||
|
||||
async connectedCallback() {
|
||||
super.connectedCallback();
|
||||
|
||||
// Setup DomTools
|
||||
this.domtools = await elementBasic.setup(this);
|
||||
await this.domtools.domReady.promise;
|
||||
|
||||
// Setup keyboard shortcuts
|
||||
this.domtools.keyboard.on([Key.Ctrl, Key.K]).subscribe(() => {
|
||||
this.openCommandPalette();
|
||||
});
|
||||
|
||||
// Subscribe to theme changes
|
||||
this.domtools.themeManager.themeObservable.subscribe((isBright) => {
|
||||
this.requestUpdate();
|
||||
});
|
||||
|
||||
// Enable smooth scrolling
|
||||
await this.domtools.scroller.enableLenisScroll({
|
||||
disableOnNativeSmoothScroll: true
|
||||
});
|
||||
}
|
||||
|
||||
private openCommandPalette() {
|
||||
console.log('Command palette opened!');
|
||||
}
|
||||
|
||||
render() {
|
||||
const isDark = !this.domtools?.themeManager.goBrightBoolean;
|
||||
|
||||
return html`
|
||||
<div class="app" style="background: ${isDark ? '#1a1a1a' : '#ffffff'}">
|
||||
<h1>My Awesome App</h1>
|
||||
<button @click=${() => this.domtools?.themeManager.toggleDarkBright()}>
|
||||
Toggle Theme
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Support
|
||||
|
||||
This package is written in TypeScript and provides full type definitions:
|
||||
|
||||
```typescript
|
||||
import type {
|
||||
IDomToolsState,
|
||||
IDomToolsContructorOptions,
|
||||
TViewport
|
||||
} from '@design.estate/dees-domtools';
|
||||
|
||||
// Custom state interface
|
||||
interface MyState extends IDomToolsState {
|
||||
customProperty: string;
|
||||
}
|
||||
|
||||
// Type-safe viewport handling
|
||||
const viewport: TViewport = 'tablet';
|
||||
```
|
||||
|
||||
## Browser Support
|
||||
|
||||
Targets the latest version of Chrome. For other browsers, you may need to include polyfills.
|
||||
|
||||
## Why @design.estate/dees-domtools?
|
||||
|
||||
- ✅ **Race-condition free** - Carefully designed initialization prevents common timing issues
|
||||
- ✅ **TypeScript first** - Full type safety and IntelliSense support
|
||||
- ✅ **Modern APIs** - Built on Lit, RxJS, and other modern web standards
|
||||
- ✅ **Batteries included** - Everything you need for sophisticated web apps
|
||||
- ✅ **Production ready** - Used in real-world applications at design.estate
|
||||
- ✅ **Well maintained** - Active development and support
|
||||
|
||||
## Related Packages
|
||||
|
||||
This library integrates with the design.estate ecosystem:
|
||||
|
||||
- `@design.estate/dees-comms` - Communication utilities
|
||||
- `@push.rocks/websetup` - Website setup and meta management
|
||||
- `@push.rocks/smartrouter` - Client-side routing
|
||||
- `@push.rocks/smartstate` - State management
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as domtools from '../ts/index';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as domtools from '../ts/index.js';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
const domtoolsInstance = await domtools.DomTools.setupDomTools();
|
||||
expect(domtoolsInstance).to.be.instanceof(domtools.DomTools);
|
||||
expect(domtoolsInstance).toBeInstanceOf(domtools.DomTools);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-domtools',
|
||||
version: '2.3.6',
|
||||
description: 'A package providing tools to simplify complex CSS structures and web development tasks, featuring TypeScript support and integration with various web technologies.'
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
|
||||
export const desktop = 1240;
|
||||
export const tablet = 1024;
|
||||
export const phablet = 600;
|
||||
export const phone = 400;
|
||||
|
||||
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
||||
|
||||
export const getEnvironment = (): TViewport => {
|
||||
if (
|
||||
globalThis.deesDomTools &&
|
||||
globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport
|
||||
) {
|
||||
return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
|
||||
} else {
|
||||
return 'native';
|
||||
}
|
||||
};
|
||||
|
||||
export const cssForTablet = (contentArg) => {
|
||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||
return `
|
||||
@media (max-width: ${tablet}px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
} else if (
|
||||
getEnvironment() === 'tablet' ||
|
||||
getEnvironment() === 'phablet' ||
|
||||
getEnvironment() === 'phone'
|
||||
) {
|
||||
return `
|
||||
@media (min-width: 0px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
export const cssForPhablet = (contentArg) => {
|
||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||
return `
|
||||
@media (max-width: ${phablet}px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
} else if (getEnvironment() === 'phablet' || getEnvironment() === 'phone') {
|
||||
return `
|
||||
@media (min-width: 0px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
export const cssForPhone = (contentArg) => {
|
||||
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
||||
return `
|
||||
@media (max-width: ${phone}px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
} else if (getEnvironment() === 'phone') {
|
||||
return `
|
||||
@media (min-width: 0px) {
|
||||
${contentArg}
|
||||
}
|
||||
`;
|
||||
}
|
||||
};
|
||||
@@ -1,44 +1,71 @@
|
||||
import * as plugins from './domtools.plugins';
|
||||
import { Stringmap } from '@pushrocks/lik/dist_ts/lik.stringmap';
|
||||
import { FastMap } from '@pushrocks/lik/dist_ts/lik.fastmap';
|
||||
import { TViewport } from './domtools.breakpoints';
|
||||
|
||||
import { Scroller } from './domtools.classes.scroller';
|
||||
import { delayForRandom } from '@pushrocks/smartdelay';
|
||||
import { WebSetup } from '@pushrocks/websetup';
|
||||
import * as plugins from './domtools.plugins.js';
|
||||
import { type TViewport } from './domtools.css.breakpoints.js';
|
||||
import { Scroller } from './domtools.classes.scroller.js';
|
||||
import { WebSetup } from '@push.rocks/websetup';
|
||||
import { ThemeManager } from './domtools.classes.thememanager.js';
|
||||
import { Keyboard } from './domtools.classes.keyboard.js';
|
||||
|
||||
export interface IDomToolsState {
|
||||
virtualViewport: TViewport;
|
||||
jwt: string;
|
||||
}
|
||||
|
||||
export interface IDomToolsContructorOptions {
|
||||
ignoreGlobal?: boolean;
|
||||
}
|
||||
|
||||
export class DomTools {
|
||||
// ======
|
||||
// STATIC
|
||||
// ======
|
||||
private static initializationPromise: Promise<DomTools> | null = null;
|
||||
|
||||
/**
|
||||
* setups domtools
|
||||
*/
|
||||
public static async setupDomTools() {
|
||||
let domToolsInstance: DomTools;
|
||||
if (!globalThis.deesDomTools) {
|
||||
globalThis.deesDomTools = new DomTools();
|
||||
domToolsInstance = globalThis.deesDomTools;
|
||||
|
||||
// lets make sure the dom is ready
|
||||
const readyStateChangedFunc = () => {
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
domToolsInstance.elements.headElement = document.querySelector('head');
|
||||
domToolsInstance.elements.bodyElement = document.querySelector('body');
|
||||
domToolsInstance.domReady.resolve();
|
||||
}
|
||||
};
|
||||
document.addEventListener('readystatechange', readyStateChangedFunc);
|
||||
domToolsInstance.domToolsReady.resolve();
|
||||
} else {
|
||||
domToolsInstance = globalThis.deesDomTools;
|
||||
public static async setupDomTools(optionsArg: IDomToolsContructorOptions = {}): Promise<DomTools> {
|
||||
// If initialization is already in progress and we're not ignoring global, wait for it
|
||||
if (!optionsArg.ignoreGlobal && DomTools.initializationPromise) {
|
||||
return await DomTools.initializationPromise;
|
||||
}
|
||||
|
||||
// Create initialization promise to prevent race conditions
|
||||
if (!optionsArg.ignoreGlobal) {
|
||||
DomTools.initializationPromise = (async () => {
|
||||
let domToolsInstance: DomTools;
|
||||
if (!globalThis.deesDomTools) {
|
||||
globalThis.deesDomTools = new DomTools(optionsArg);
|
||||
domToolsInstance = globalThis.deesDomTools;
|
||||
|
||||
// lets make sure the dom is ready
|
||||
const readyStateChangedFunc = () => {
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
domToolsInstance.elements.headElement = document.querySelector('head');
|
||||
domToolsInstance.elements.bodyElement = document.querySelector('body');
|
||||
// Initialize keyboard now that document.body exists
|
||||
domToolsInstance.keyboard = new Keyboard(document.body);
|
||||
domToolsInstance.domReady.resolve();
|
||||
}
|
||||
};
|
||||
// Check current state immediately to avoid race condition
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
readyStateChangedFunc();
|
||||
} else {
|
||||
document.addEventListener('readystatechange', readyStateChangedFunc);
|
||||
}
|
||||
domToolsInstance.domToolsReady.resolve();
|
||||
} else {
|
||||
domToolsInstance = globalThis.deesDomTools;
|
||||
}
|
||||
await domToolsInstance.domToolsReady.promise;
|
||||
return domToolsInstance;
|
||||
})();
|
||||
return await DomTools.initializationPromise;
|
||||
} else {
|
||||
// ignoreGlobal case - create isolated instance
|
||||
const domToolsInstance = new DomTools(optionsArg);
|
||||
return domToolsInstance;
|
||||
}
|
||||
await domToolsInstance.domToolsReady.promise;
|
||||
return domToolsInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,13 +93,14 @@ export class DomTools {
|
||||
|
||||
public websetup: WebSetup = new WebSetup({
|
||||
metaObject: {
|
||||
title: 'loading...'
|
||||
}
|
||||
title: 'loading...',
|
||||
},
|
||||
});
|
||||
|
||||
public smartstate = new plugins.smartstate.Smartstate();
|
||||
public domToolsStatePart = this.smartstate.getStatePart<IDomToolsState>('domtools', {
|
||||
virtualViewport: 'native',
|
||||
jwt: null,
|
||||
});
|
||||
|
||||
public router = new plugins.smartrouter.SmartRouter({
|
||||
@@ -80,36 +108,27 @@ export class DomTools {
|
||||
});
|
||||
|
||||
public convenience = {
|
||||
typedrequest: plugins.typedrequest,
|
||||
smartdelay: plugins.smartdelay,
|
||||
smartjson: plugins.smartjson,
|
||||
smarturl: plugins.smarturl,
|
||||
};
|
||||
|
||||
public scroller: plugins.SweetScroll;
|
||||
|
||||
public deesComms = new plugins.deesComms.DeesComms();
|
||||
|
||||
private actionSetVirtualViewport = this.domToolsStatePart.createAction<TViewport>(
|
||||
async (statePart, payload) => {
|
||||
const currentState = statePart.getState();
|
||||
currentState.virtualViewport = payload;
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
public scroller = new Scroller(this);
|
||||
public themeManager = new ThemeManager(this);
|
||||
public keyboard: Keyboard = null; // Initialized after DOM ready to avoid accessing document.body before it exists
|
||||
|
||||
public domToolsReady = plugins.smartpromise.defer();
|
||||
public domReady = plugins.smartpromise.defer();
|
||||
public globalStylesReady = plugins.smartpromise.defer();
|
||||
|
||||
constructor() {
|
||||
// lets care about third party stuff
|
||||
this.domToolsReady.promise.then(() => {
|
||||
this.scroller = new plugins.SweetScroll({
|
||||
/* some options */
|
||||
});
|
||||
});
|
||||
}
|
||||
constructor(optionsArg: IDomToolsContructorOptions) {}
|
||||
|
||||
private runOnceTrackerStringMap = new plugins.lik.Stringmap();
|
||||
private runOnceResultMap = new plugins.lik.FastMap();
|
||||
private runOnceErrorMap = new plugins.lik.FastMap();
|
||||
|
||||
private runOnceTrackerStringMap = new Stringmap();
|
||||
private runOnceResultMap = new FastMap();
|
||||
/**
|
||||
* run a function once and always get the Promise of the first execution
|
||||
* @param identifierArg the indentifier arg identifies functions. functions with the same identifier are considered equal
|
||||
@@ -120,22 +139,37 @@ export class DomTools {
|
||||
if (!this.runOnceTrackerStringMap.checkString(identifierArg)) {
|
||||
this.runOnceTrackerStringMap.addString(identifierArg);
|
||||
this.runOnceTrackerStringMap.addString(runningId);
|
||||
const result = await funcArg();
|
||||
this.runOnceResultMap.addToMap(identifierArg, result);
|
||||
this.runOnceTrackerStringMap.removeString(runningId);
|
||||
try {
|
||||
const result = await funcArg();
|
||||
this.runOnceResultMap.addToMap(identifierArg, result);
|
||||
} catch (error) {
|
||||
// Store error so waiting callers can receive it
|
||||
this.runOnceErrorMap.addToMap(identifierArg, error);
|
||||
} finally {
|
||||
// Always remove running flag to prevent permanent stuck state
|
||||
this.runOnceTrackerStringMap.removeString(runningId);
|
||||
}
|
||||
}
|
||||
return await this.runOnceTrackerStringMap.registerUntilTrue(
|
||||
(stringMap) => {
|
||||
return !stringMap.includes(runningId);
|
||||
},
|
||||
() => {
|
||||
// Check if there was an error and re-throw it
|
||||
const error = this.runOnceErrorMap.getByKey(identifierArg);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return this.runOnceResultMap.getByKey(identifierArg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// setStuff
|
||||
|
||||
/**
|
||||
* allows to set global styles
|
||||
* @param stylesText the css text you want to set
|
||||
*/
|
||||
public async setGlobalStyles(stylesText: string) {
|
||||
await this.domReady.promise;
|
||||
const styleElement = document.createElement('style');
|
||||
@@ -144,10 +178,39 @@ export class DomTools {
|
||||
this.elements.headElement.appendChild(styleElement);
|
||||
}
|
||||
|
||||
public setVirtualViewport(environmentArg: TViewport) {
|
||||
this.domToolsStatePart.dispatchAction(this.actionSetVirtualViewport, environmentArg);
|
||||
/**
|
||||
* allows to set global styles
|
||||
* @param stylesText the css text you want to set
|
||||
*/
|
||||
public async setExternalScript(scriptLinkArg: string) {
|
||||
await this.domReady.promise;
|
||||
const done = plugins.smartpromise.defer();
|
||||
const script = document.createElement('script');
|
||||
script.src = scriptLinkArg;
|
||||
script.addEventListener('load', function () {
|
||||
done.resolve();
|
||||
});
|
||||
const parentNode = document.head || document.body;
|
||||
parentNode.append(script);
|
||||
await done.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows setting external css files
|
||||
* @param cssLinkArg a url to an external stylesheet
|
||||
*/
|
||||
public async setExternalCss(cssLinkArg: string) {
|
||||
const cssTag = document.createElement('link');
|
||||
cssTag.rel = 'stylesheet';
|
||||
cssTag.crossOrigin = 'anonymous';
|
||||
cssTag.href = cssLinkArg;
|
||||
document.head.append(cssTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* allows setting of website infos
|
||||
* @param optionsArg the website info
|
||||
*/
|
||||
public async setWebsiteInfo(optionsArg: plugins.websetup.IWebSetupConstructorOptions) {
|
||||
await this.websetup.setup(optionsArg);
|
||||
await this.websetup.readyPromise;
|
||||
|
||||
213
ts/domtools.classes.keyboard.ts
Normal file
213
ts/domtools.classes.keyboard.ts
Normal file
@@ -0,0 +1,213 @@
|
||||
import * as plugins from './domtools.plugins.js';
|
||||
|
||||
export enum Key {
|
||||
Backspace = 8,
|
||||
Tab = 9,
|
||||
Enter = 13,
|
||||
Shift = 16,
|
||||
Ctrl = 17,
|
||||
Alt = 18,
|
||||
PauseBreak = 19,
|
||||
CapsLock = 20,
|
||||
Escape = 27,
|
||||
Space = 32,
|
||||
PageUp = 33,
|
||||
PageDown = 34,
|
||||
End = 35,
|
||||
Home = 36,
|
||||
|
||||
LeftArrow = 37,
|
||||
UpArrow = 38,
|
||||
RightArrow = 39,
|
||||
DownArrow = 40,
|
||||
|
||||
Insert = 45,
|
||||
Delete = 46,
|
||||
|
||||
Zero = 48,
|
||||
ClosedParen = Zero,
|
||||
One = 49,
|
||||
ExclamationMark = One,
|
||||
Two = 50,
|
||||
AtSign = Two,
|
||||
Three = 51,
|
||||
PoundSign = Three,
|
||||
Hash = PoundSign,
|
||||
Four = 52,
|
||||
DollarSign = Four,
|
||||
Five = 53,
|
||||
PercentSign = Five,
|
||||
Six = 54,
|
||||
Caret = Six,
|
||||
Hat = Caret,
|
||||
Seven = 55,
|
||||
Ampersand = Seven,
|
||||
Eight = 56,
|
||||
Star = Eight,
|
||||
Asterik = Star,
|
||||
Nine = 57,
|
||||
OpenParen = Nine,
|
||||
|
||||
A = 65,
|
||||
B = 66,
|
||||
C = 67,
|
||||
D = 68,
|
||||
E = 69,
|
||||
F = 70,
|
||||
G = 71,
|
||||
H = 72,
|
||||
I = 73,
|
||||
J = 74,
|
||||
K = 75,
|
||||
L = 76,
|
||||
M = 77,
|
||||
N = 78,
|
||||
O = 79,
|
||||
P = 80,
|
||||
Q = 81,
|
||||
R = 82,
|
||||
S = 83,
|
||||
T = 84,
|
||||
U = 85,
|
||||
V = 86,
|
||||
W = 87,
|
||||
X = 88,
|
||||
Y = 89,
|
||||
Z = 90,
|
||||
|
||||
LeftWindowKey = 91,
|
||||
RightWindowKey = 92,
|
||||
SelectKey = 93,
|
||||
|
||||
Numpad0 = 96,
|
||||
Numpad1 = 97,
|
||||
Numpad2 = 98,
|
||||
Numpad3 = 99,
|
||||
Numpad4 = 100,
|
||||
Numpad5 = 101,
|
||||
Numpad6 = 102,
|
||||
Numpad7 = 103,
|
||||
Numpad8 = 104,
|
||||
Numpad9 = 105,
|
||||
|
||||
Multiply = 106,
|
||||
Add = 107,
|
||||
Subtract = 109,
|
||||
DecimalPoint = 110,
|
||||
Divide = 111,
|
||||
|
||||
F1 = 112,
|
||||
F2 = 113,
|
||||
F3 = 114,
|
||||
F4 = 115,
|
||||
F5 = 116,
|
||||
F6 = 117,
|
||||
F7 = 118,
|
||||
F8 = 119,
|
||||
F9 = 120,
|
||||
F10 = 121,
|
||||
F11 = 122,
|
||||
F12 = 123,
|
||||
|
||||
NumLock = 144,
|
||||
ScrollLock = 145,
|
||||
|
||||
SemiColon = 186,
|
||||
Equals = 187,
|
||||
Comma = 188,
|
||||
Dash = 189,
|
||||
Period = 190,
|
||||
UnderScore = Dash,
|
||||
PlusSign = Equals,
|
||||
ForwardSlash = 191,
|
||||
Tilde = 192,
|
||||
GraveAccent = Tilde,
|
||||
|
||||
OpenBracket = 219,
|
||||
ClosedBracket = 221,
|
||||
Quote = 222,
|
||||
}
|
||||
|
||||
export class Keyboard {
|
||||
private mapCombosToHandlers = new Map<number[], plugins.smartrx.rxjs.Subject<KeyboardEvent>>();
|
||||
private pressedKeys = new Set<Key>();
|
||||
|
||||
constructor(private domNode: Element | Document) {
|
||||
this.startListening();
|
||||
}
|
||||
|
||||
public keyEnum = Key;
|
||||
|
||||
public on(keys: Key[]) {
|
||||
const subject = new plugins.smartrx.rxjs.Subject<KeyboardEvent>();
|
||||
this.registerKeys(keys, subject);
|
||||
return subject;
|
||||
}
|
||||
|
||||
public triggerKeyPress(keysArg: Key[]) {
|
||||
for (const key of keysArg) {
|
||||
this.pressedKeys.add(key);
|
||||
}
|
||||
this.checkMatchingKeyboardSubjects();
|
||||
for (const key of keysArg) {
|
||||
this.pressedKeys.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
public startListening() {
|
||||
this.domNode.addEventListener('keydown', this.handleKeyDown);
|
||||
this.domNode.addEventListener('keyup', this.handleKeyUp);
|
||||
}
|
||||
|
||||
public stopListening() {
|
||||
this.domNode.removeEventListener('keydown', this.handleKeyDown);
|
||||
this.domNode.removeEventListener('keyup', this.handleKeyUp);
|
||||
}
|
||||
|
||||
public clear() {
|
||||
this.stopListening();
|
||||
this.mapCombosToHandlers.clear();
|
||||
this.pressedKeys.clear();
|
||||
}
|
||||
|
||||
private handleKeyDown = (event: KeyboardEvent) => {
|
||||
this.pressedKeys.add(event.keyCode);
|
||||
this.checkMatchingKeyboardSubjects(event);
|
||||
};
|
||||
|
||||
private checkMatchingKeyboardSubjects(payloadArg?) {
|
||||
this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
|
||||
if (this.areAllKeysPressed(keysArg)) {
|
||||
subjectArg.next(payloadArg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private handleKeyUp = (event: KeyboardEvent) => {
|
||||
this.pressedKeys.delete(event.keyCode);
|
||||
};
|
||||
|
||||
private areAllKeysPressed(keysArg: Key[]) {
|
||||
let result = true;
|
||||
|
||||
keysArg.forEach((key) => {
|
||||
if (!this.pressedKeys.has(key)) {
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private registerKeys(
|
||||
keysArg: Array<Key>,
|
||||
subjectArg: plugins.smartrx.rxjs.Subject<KeyboardEvent>
|
||||
) {
|
||||
if (!this.mapCombosToHandlers.has(keysArg)) {
|
||||
this.mapCombosToHandlers.set(keysArg, subjectArg);
|
||||
} else {
|
||||
const subject = this.mapCombosToHandlers.get(keysArg);
|
||||
return subject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,175 @@
|
||||
import * as plugins from './domtools.plugins';
|
||||
import type { DomTools } from './domtools.classes.domtools.js';
|
||||
import * as plugins from './domtools.plugins.js';
|
||||
|
||||
export class Scroller {
|
||||
// TODO: move sweet scroll over to here;
|
||||
}
|
||||
public domtoolsInstance: DomTools;
|
||||
|
||||
// Array to store scroll callback functions.
|
||||
private scrollCallbacks: Array<() => void> = [];
|
||||
|
||||
// Lenis instance (if activated) or null.
|
||||
private lenisInstance: plugins.Lenis | null = null;
|
||||
|
||||
// Bound handlers to allow removal from event listeners.
|
||||
private handleNativeScroll = (event: Event): void => {
|
||||
this.executeScrollCallbacks();
|
||||
};
|
||||
|
||||
private handleLenisScroll = (info: any): void => {
|
||||
this.executeScrollCallbacks();
|
||||
};
|
||||
|
||||
constructor(domtoolsInstanceArg: DomTools) {
|
||||
this.domtoolsInstance = domtoolsInstanceArg;
|
||||
// Attach the native scroll listener by default.
|
||||
this.attachNativeScrollListener();
|
||||
}
|
||||
|
||||
private sweetScroller = new plugins.SweetScroll({});
|
||||
|
||||
/**
|
||||
* Scrolls to a given element with options.
|
||||
*/
|
||||
public async toElement(
|
||||
elementArg: HTMLElement,
|
||||
optionsArg: Parameters<typeof this.sweetScroller.toElement>[1]
|
||||
) {
|
||||
this.sweetScroller.toElement(elementArg, optionsArg);
|
||||
await plugins.smartdelay.delayFor(optionsArg.duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects whether native smooth scrolling is enabled.
|
||||
*/
|
||||
public async detectNativeSmoothScroll() {
|
||||
const done = plugins.smartpromise.defer<boolean>();
|
||||
const sampleSize = 100;
|
||||
const acceptableDeltaDifference = 3;
|
||||
const minimumSmoothRatio = 0.75;
|
||||
|
||||
const eventDeltas: number[] = [];
|
||||
|
||||
function onWheel(event: WheelEvent) {
|
||||
eventDeltas.push(event.deltaY);
|
||||
|
||||
if (eventDeltas.length >= sampleSize) {
|
||||
window.removeEventListener('wheel', onWheel);
|
||||
analyzeEvents();
|
||||
}
|
||||
}
|
||||
|
||||
function analyzeEvents() {
|
||||
const totalDiffs = eventDeltas.length - 1;
|
||||
let smallDiffCount = 0;
|
||||
|
||||
for (let i = 0; i < totalDiffs; i++) {
|
||||
const diff = Math.abs(eventDeltas[i + 1] - eventDeltas[i]);
|
||||
if (diff <= acceptableDeltaDifference) {
|
||||
smallDiffCount++;
|
||||
}
|
||||
}
|
||||
|
||||
const smoothRatio = smallDiffCount / totalDiffs;
|
||||
if (smoothRatio >= minimumSmoothRatio) {
|
||||
console.log('Smooth scrolling detected.');
|
||||
done.resolve(true);
|
||||
} else {
|
||||
console.log('Smooth scrolling NOT detected.');
|
||||
done.resolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('wheel', onWheel);
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables Lenis scrolling.
|
||||
* If optionsArg.disableOnNativeSmoothScroll is true and native smooth scrolling is detected,
|
||||
* Lenis will be destroyed immediately.
|
||||
*/
|
||||
public async enableLenisScroll(optionsArg?: { disableOnNativeSmoothScroll?: boolean }) {
|
||||
const lenis = new plugins.Lenis({
|
||||
autoRaf: true,
|
||||
});
|
||||
|
||||
if (optionsArg?.disableOnNativeSmoothScroll) {
|
||||
if (await this.detectNativeSmoothScroll()) {
|
||||
lenis.destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Activate Lenis scrolling.
|
||||
this.lenisInstance = lenis;
|
||||
// Switch from native scroll listener to Lenis scroll listener.
|
||||
this.detachNativeScrollListener();
|
||||
this.attachLenisScrollListener();
|
||||
|
||||
// Monkey-patch the destroy method so that when Lenis is destroyed,
|
||||
// the native scroll listener is reattached.
|
||||
const originalDestroy = lenis.destroy.bind(lenis);
|
||||
lenis.destroy = () => {
|
||||
originalDestroy();
|
||||
this.detachLenisScrollListener();
|
||||
this.attachNativeScrollListener();
|
||||
this.lenisInstance = null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback to be executed on scroll.
|
||||
* @param callback A function to execute on each scroll event.
|
||||
*/
|
||||
public onScroll(callback: () => void): void {
|
||||
this.scrollCallbacks.push(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes all registered scroll callbacks concurrently.
|
||||
*/
|
||||
private executeScrollCallbacks(): void {
|
||||
// Execute all callbacks in parallel.
|
||||
this.scrollCallbacks.forEach((callback) => {
|
||||
try {
|
||||
callback();
|
||||
} catch (error) {
|
||||
console.error('Error in scroll callback:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the native scroll event listener.
|
||||
*/
|
||||
private attachNativeScrollListener(): void {
|
||||
window.addEventListener('scroll', this.handleNativeScroll);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detaches the native scroll event listener.
|
||||
*/
|
||||
private detachNativeScrollListener(): void {
|
||||
window.removeEventListener('scroll', this.handleNativeScroll);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the Lenis scroll event listener.
|
||||
*/
|
||||
private attachLenisScrollListener(): void {
|
||||
if (this.lenisInstance) {
|
||||
// Assuming that Lenis exposes an `on` method to listen to scroll events.
|
||||
this.lenisInstance.on('scroll', this.handleLenisScroll);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detaches the Lenis scroll event listener.
|
||||
*/
|
||||
private detachLenisScrollListener(): void {
|
||||
if (this.lenisInstance) {
|
||||
// Assuming that Lenis exposes an `off` method to remove scroll event listeners.
|
||||
this.lenisInstance.off('scroll', this.handleLenisScroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
ts/domtools.classes.thememanager.ts
Normal file
61
ts/domtools.classes.thememanager.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { DomTools } from './domtools.classes.domtools.js';
|
||||
import * as plugins from './domtools.plugins.js';
|
||||
|
||||
export class ThemeManager {
|
||||
public domtoolsRef: DomTools;
|
||||
|
||||
public goBrightBoolean = false;
|
||||
public preferredColorSchemeMediaMatch = window.matchMedia('(prefers-color-scheme: light)');
|
||||
|
||||
public themeObservable = new plugins.smartrx.rxjs.ReplaySubject<boolean>(1);
|
||||
|
||||
constructor(domtoolsRefArg: DomTools) {
|
||||
this.domtoolsRef = domtoolsRefArg;
|
||||
|
||||
// lets care
|
||||
this.goBrightBoolean = this.preferredColorSchemeMediaMatch.matches;
|
||||
this.preferredColorSchemeMediaMatch.addEventListener('change', (eventArg) => {
|
||||
this.goBrightBoolean = eventArg.matches;
|
||||
this.updateAllConnectedElements();
|
||||
});
|
||||
this.updateAllConnectedElements();
|
||||
}
|
||||
|
||||
public async enableAutomaticGlobalThemeChange() {
|
||||
if (document.body && document.body.style) {
|
||||
this.themeObservable.subscribe({
|
||||
next: (goBright) => {
|
||||
document.body.style.background = goBright ? '#fff' : '#000';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async updateAllConnectedElements() {
|
||||
this.themeObservable.next(this.goBrightBoolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the theme of the website to bright
|
||||
*/
|
||||
public goBright() {
|
||||
this.goBrightBoolean = true;
|
||||
this.updateAllConnectedElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* set the theme of the website to dark
|
||||
*/
|
||||
public goDark() {
|
||||
this.goBrightBoolean = false;
|
||||
this.updateAllConnectedElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* simply toggle between bright and dark
|
||||
*/
|
||||
public toggleDarkBright() {
|
||||
this.goBrightBoolean = !this.goBrightBoolean;
|
||||
this.updateAllConnectedElements();
|
||||
}
|
||||
}
|
||||
41
ts/domtools.css.basestyles.ts
Normal file
41
ts/domtools.css.basestyles.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { DomTools } from './domtools.classes.domtools.js';
|
||||
|
||||
import { css, unsafeCSS } from 'lit';
|
||||
|
||||
/**
|
||||
* changes scrollbar styles to be consistent across OS borders
|
||||
*/
|
||||
export const scrollBarStyles: string = (() => {
|
||||
const returnStylesOld = navigator.userAgent.indexOf('Mac OS X') === -1 ? css``.cssText : ``;
|
||||
const returnStyles = css`
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 0px;
|
||||
}
|
||||
body {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
`.cssText;
|
||||
return returnStyles;
|
||||
})();
|
||||
|
||||
export const globalBaseStyles: string = css`
|
||||
/*
|
||||
@font-face {
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2)
|
||||
format('woff2');
|
||||
} */
|
||||
|
||||
/* global body styles */
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: 'Geist Sans', 'Inter', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* scroll bar styles */
|
||||
${unsafeCSS(scrollBarStyles)}
|
||||
`.cssText;
|
||||
66
ts/domtools.css.breakpoints.ts
Normal file
66
ts/domtools.css.breakpoints.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { DomTools } from './domtools.classes.domtools.js';
|
||||
|
||||
import { CSSResult, unsafeCSS } from 'lit';
|
||||
|
||||
export const desktop = 1600;
|
||||
export const notebook = 1240;
|
||||
export const tablet = 1024;
|
||||
export const phablet = 600;
|
||||
export const phone = 400;
|
||||
|
||||
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
||||
|
||||
export const cssForDesktop = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (min-width: ${desktop}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (min-width: ${desktop}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForNotebook = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (max-width: ${notebook}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (max-width: ${notebook}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForTablet = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (max-width: ${tablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (max-width: ${tablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForPhablet = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (max-width: ${phablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (max-width: ${phablet}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
|
||||
export const cssForPhone = (cssArg: CSSResult) => {
|
||||
return unsafeCSS(`
|
||||
@container wccToolsViewport (max-width: ${phone}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
@media (max-width: ${phone}px) {
|
||||
${cssArg.cssText}
|
||||
}
|
||||
`);
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
|
||||
/**
|
||||
* changes scrollbar styles to be consistent across OS borders
|
||||
*/
|
||||
export const scrollBarStyles = (() => {
|
||||
const returnStyles = navigator.userAgent.indexOf("Windows") !== -1 ? `
|
||||
/* width */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
/* Track */
|
||||
::-webkit-scrollbar-track {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
/* Handle */
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #666;
|
||||
}
|
||||
|
||||
/* Handle on hover */
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #777;
|
||||
}
|
||||
` : ``;
|
||||
})();
|
||||
@@ -1,8 +1,22 @@
|
||||
import * as plugins from './domtools.plugins';
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
import { scrollBarStyles } from './domtools.css.theme';
|
||||
import * as plugins from './domtools.plugins.js';
|
||||
import { DomTools, type IDomToolsContructorOptions } from './domtools.classes.domtools.js';
|
||||
import { scrollBarStyles, globalBaseStyles } from './domtools.css.basestyles.js';
|
||||
|
||||
import { html } from 'lit-element';
|
||||
import { html, LitElement, css, unsafeCSS } from 'lit';
|
||||
|
||||
export const staticStyles = css`
|
||||
* {
|
||||
transition: background 0.1s, color 0.1s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
box-sizing: border-box;
|
||||
font-family: 'Geist Sans', 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
${unsafeCSS(scrollBarStyles)}
|
||||
`;
|
||||
|
||||
/**
|
||||
* styles to be included in every webcomponent
|
||||
@@ -10,10 +24,14 @@ import { html } from 'lit-element';
|
||||
export const styles = html`
|
||||
<style>
|
||||
* {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
transition: background 0.1s, color 0.1s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
font-family: 'Geist Sans', 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
${scrollBarStyles}
|
||||
</style>
|
||||
`;
|
||||
@@ -22,37 +40,20 @@ export const styles = html`
|
||||
* a basic setup for elements
|
||||
* makes sure everything is in check
|
||||
*/
|
||||
export const setup = async () => {
|
||||
const domTools = await DomTools.setupDomTools();
|
||||
export const setup = async (
|
||||
elementArg?: LitElement,
|
||||
optionsArg: IDomToolsContructorOptions = {}
|
||||
): Promise<DomTools> => {
|
||||
const domTools = await DomTools.setupDomTools(optionsArg);
|
||||
|
||||
if (elementArg) {
|
||||
// lets do something with the element
|
||||
// not used right now
|
||||
}
|
||||
|
||||
domTools.runOnce('elementBasicSetup', async () => {
|
||||
// bodyStyles
|
||||
domTools.setGlobalStyles(`
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
`);
|
||||
|
||||
// material font
|
||||
domTools.setGlobalStyles(`
|
||||
@font-face {
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(https://fonts.gstatic.com/s/materialicons/v42/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
|
||||
}
|
||||
`);
|
||||
|
||||
// Roboto Font
|
||||
domTools.setGlobalStyles(`
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100;300;400');
|
||||
`);
|
||||
|
||||
// scrollbars
|
||||
domTools.setGlobalStyles(`
|
||||
${scrollBarStyles}
|
||||
`);
|
||||
domTools.setGlobalStyles(globalBaseStyles);
|
||||
});
|
||||
return domTools;
|
||||
};
|
||||
|
||||
23
ts/domtools.pluginexports.ts
Normal file
23
ts/domtools.pluginexports.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartmarkdown from '@push.rocks/smartmarkdown';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import SweetScroll from 'sweet-scroll';
|
||||
import * as smartstate from '@push.rocks/smartstate';
|
||||
import * as smartrouter from '@push.rocks/smartrouter';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
import * as smarturl from '@push.rocks/smarturl';
|
||||
import * as typedrequest from '@api.global/typedrequest';
|
||||
|
||||
export {
|
||||
smartdelay,
|
||||
smartmarkdown,
|
||||
smartpromise,
|
||||
SweetScroll,
|
||||
smartstate,
|
||||
smartrouter,
|
||||
smartrx,
|
||||
smartstring,
|
||||
smarturl,
|
||||
typedrequest
|
||||
};
|
||||
@@ -1,27 +1,55 @@
|
||||
// designestate scope
|
||||
import * as deesComms from '@designestate/dees-comms';
|
||||
import * as deesComms from '@design.estate/dees-comms';
|
||||
|
||||
export {
|
||||
deesComms
|
||||
};
|
||||
export { deesComms };
|
||||
|
||||
// apiglobal scope
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
import * as typedrequest from '@api.global/typedrequest';
|
||||
|
||||
export { typedrequest };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrouter from '@pushrocks/smartrouter';
|
||||
import * as smartstate from '@pushrocks/smartstate';
|
||||
import * as webrequest from '@pushrocks/webrequest';
|
||||
import * as websetup from '@pushrocks/websetup';
|
||||
import * as webstore from '@pushrocks/webstore';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartjson from '@push.rocks/smartjson';
|
||||
import * as smartmarkdown from '@push.rocks/smartmarkdown';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartrouter from '@push.rocks/smartrouter';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
import * as smartstate from '@push.rocks/smartstate';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
import * as smarturl from '@push.rocks/smarturl';
|
||||
import * as webrequest from '@push.rocks/webrequest';
|
||||
import * as websetup from '@push.rocks/websetup';
|
||||
import * as webstore from '@push.rocks/webstore';
|
||||
|
||||
export { smartdelay, smartpromise, smartrouter, smartstate, webrequest, websetup, webstore };
|
||||
// subscope lik
|
||||
import { ObjectMap } from '@push.rocks/lik/dist_ts/lik.objectmap.js';
|
||||
import { Stringmap } from '@push.rocks/lik/dist_ts/lik.stringmap.js';
|
||||
import { FastMap } from '@push.rocks/lik/dist_ts/lik.fastmap.js';
|
||||
const lik = {
|
||||
ObjectMap,
|
||||
Stringmap,
|
||||
FastMap,
|
||||
};
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartdelay,
|
||||
smartjson,
|
||||
smartmarkdown,
|
||||
smartpromise,
|
||||
smartrouter,
|
||||
smartrx,
|
||||
smarturl,
|
||||
smartstate,
|
||||
smartstring,
|
||||
webrequest,
|
||||
websetup,
|
||||
webstore,
|
||||
};
|
||||
|
||||
// third party scope
|
||||
import Lenis from 'lenis'
|
||||
import SweetScroll from 'sweet-scroll';
|
||||
|
||||
export { SweetScroll };
|
||||
export { Lenis, SweetScroll };
|
||||
|
||||
25
ts/index.ts
25
ts/index.ts
@@ -1,15 +1,20 @@
|
||||
export * from './domtools.colors';
|
||||
export * from './domtools.colors.js';
|
||||
|
||||
import * as elementBasic from './domtools.elementbasic';
|
||||
import * as breakpoints from './domtools.breakpoints';
|
||||
import * as css from './domtools.css';
|
||||
import * as elementBasic from './domtools.elementbasic.js';
|
||||
import * as breakpoints from './domtools.css.breakpoints.js';
|
||||
import * as css from './domtools.css.js';
|
||||
|
||||
export { css, breakpoints, elementBasic };
|
||||
export { DomTools } from './domtools.classes.domtools';
|
||||
export { TypedRequest } from '@apiglobal/typedrequest';
|
||||
export { DomTools, type IDomToolsContructorOptions } from './domtools.classes.domtools.js';
|
||||
export { TypedRequest } from '@api.global/typedrequest';
|
||||
export { type IWebSetupConstructorOptions } from '@push.rocks/websetup';
|
||||
|
||||
import * as allPlugins from './domtools.plugins';
|
||||
import * as plugins from './domtools.pluginexports.js';
|
||||
export { plugins };
|
||||
|
||||
export const plugins = {
|
||||
smartpromise: allPlugins.smartpromise,
|
||||
};
|
||||
// type exports
|
||||
import type { rxjs } from '@push.rocks/smartrx';
|
||||
|
||||
export type {
|
||||
rxjs,
|
||||
}
|
||||
|
||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
Reference in New Issue
Block a user