@dreher-media/dm-js-lib 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -0
- package/dist/dm-js-lib.min.js +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @dreher-media/dm-js-lib
|
|
2
|
+
|
|
3
|
+
Centralized JavaScript library for Dreher.Media websites with CDN delivery.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
### Build
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will compile TypeScript and create `dist/dm-js-lib.min.js`.
|
|
20
|
+
|
|
21
|
+
### Format Code
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run format
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Check formatting:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm run format:check
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Release Workflow
|
|
34
|
+
|
|
35
|
+
### 1. Build and Publish
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run release:patch # 1.0.0 -> 1.0.1 (builds, versions, and publishes)
|
|
39
|
+
npm run release:minor # 1.0.0 -> 1.1.0 (builds, versions, and publishes)
|
|
40
|
+
npm run release:major # 1.0.0 -> 2.0.0 (builds, versions, and publishes)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The release script will:
|
|
44
|
+
1. Update the version in `package.json`
|
|
45
|
+
2. Build the project (via `prepublishOnly` hook)
|
|
46
|
+
3. Publish to npm
|
|
47
|
+
|
|
48
|
+
### 2. Commit and Push
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git add .
|
|
52
|
+
git commit -m "Release v1.2.3"
|
|
53
|
+
git push
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## CDN Usage
|
|
57
|
+
|
|
58
|
+
jsDelivr automatically serves from npm with full semantic versioning support:
|
|
59
|
+
|
|
60
|
+
### Pinned Version (Frozen)
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@1.2.3/dist/dm-js-lib.min.js"></script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Patch-Only Auto-Update
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@1.2.x/dist/dm-js-lib.min.js"></script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Automatically updates only on patch versions (e.g., `1.2.0 → 1.2.1`), never on minor or major versions.
|
|
73
|
+
|
|
74
|
+
### Version Range
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@^1.2.0/dist/dm-js-lib.min.js"></script>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Updates to any compatible version (patches and minor versions, but not major).
|
|
81
|
+
|
|
82
|
+
### Latest (Staging)
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@latest/dist/dm-js-lib.min.js"></script>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Always points to the newest published version.
|
|
89
|
+
|
|
90
|
+
## Versioning Strategy
|
|
91
|
+
|
|
92
|
+
- All versions follow **semantic versioning (semver)**
|
|
93
|
+
- Published versions are **immutable** - once published to npm, never changed
|
|
94
|
+
- Version ranges (`@1.2.x`, `@^1.2.0`) automatically resolve to compatible versions
|
|
95
|
+
- `@latest` always points to the newest published version
|
|
96
|
+
- Multiple minor version lines can receive security patches independently
|
|
97
|
+
|
|
98
|
+
## Project Structure
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
dm-js-lib/
|
|
102
|
+
src/
|
|
103
|
+
types/
|
|
104
|
+
global.d.ts
|
|
105
|
+
modules/
|
|
106
|
+
[module files]
|
|
107
|
+
index.ts
|
|
108
|
+
dist/
|
|
109
|
+
dm-js-lib.min.js
|
|
110
|
+
package.json
|
|
111
|
+
tsconfig.json
|
|
112
|
+
rollup.config.mjs
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Dependencies
|
|
116
|
+
|
|
117
|
+
- **rollup** - Build tool
|
|
118
|
+
- **@rollup/plugin-typescript** - TypeScript support
|
|
119
|
+
- **rollup-plugin-terser** - Minification
|
|
120
|
+
- **typescript** - TypeScript compiler
|
|
121
|
+
- **prettier** - Code formatter
|
|
122
|
+
|
|
123
|
+
## Publishing to npm
|
|
124
|
+
|
|
125
|
+
Before publishing, ensure you have:
|
|
126
|
+
|
|
127
|
+
1. An npm account
|
|
128
|
+
2. Access to the `@dreher-media` organization (or change the package name)
|
|
129
|
+
3. Logged in: `npm login`
|
|
130
|
+
|
|
131
|
+
Then use the release scripts which handle building and publishing automatically.
|
|
132
|
+
|
|
133
|
+
## External Dependencies (Runtime)
|
|
134
|
+
|
|
135
|
+
The library integrates with these external services (loaded separately):
|
|
136
|
+
|
|
137
|
+
- **FsCC (Finsweet Cookie Consent)** - Cookie consent management
|
|
138
|
+
- **Webflow** - Webflow CMS and interactions
|
|
139
|
+
- **Plyr** - Video player library
|
|
140
|
+
- **YouTube IFrame API** - YouTube player
|
|
141
|
+
- **Vimeo Player API** - Vimeo player
|
|
142
|
+
- **Dailymotion Player Library** - Dailymotion player
|
|
143
|
+
- **Swiper** - Carousel/slider library (optional, for video swipers)
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
148
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){"use strict";!function(){let e=!1;const t=()=>{window.FsCC?(e||(window.FsCC.consentController.on("updateconsents",()=>{t()}),e=!0),document.querySelectorAll("[fs-cc-reject]").forEach(e=>{const t=e.getAttribute("fs-cc-reject");if(!t)return;const o=window.FsCC?.store.consents[t]??!1,n=document.querySelector(`[fs-cc="${t}"]`);o?(e.style.display="none",n&&(n.style.display="block")):(e.style.display="block",n&&(n.style.display="none"))})):setTimeout(t,200)};document.addEventListener("DOMContentLoaded",t)}(),void 0!==window.Webflow&&window.Webflow.push(()=>{document.querySelectorAll(".copyright-year").forEach(e=>{e.textContent=(new Date).getFullYear().toString()});const e=sessionStorage.getItem("selected_lang");if(e){const t=document.querySelector(`.biography-lang-links .tab-link[data-lang="${e}"]`);t?.click?.()}}),function(){const e=e=>{const t=(e||"").replace(/\/+$/,"").replace(/\.html?$/i,"");return""===t?"/":t};window.addEventListener("load",()=>{const t=e(window.location.pathname);document.querySelectorAll("a[href]").forEach(o=>{const n=o.getAttribute("href");if(!n)return;if(n.startsWith("#")||n.toLowerCase().startsWith("javascript:"))return;let a;try{a=new URL(n,window.location.href)}catch{return}if(a.origin!==window.location.origin)return;e(a.pathname)===t&&o.classList.add("w--current")})})}(),document.querySelectorAll("[data-separator]").forEach(e=>{const t=e.getAttribute("data-separator");if(!t)return;const o=Array.from(e.children);o.forEach((e,n)=>{if(n<o.length-1){const o=document.createElement("span");o.innerHTML=` ${t} `,e.insertAdjacentElement("afterend",o)}})}),document.querySelectorAll(".tab-link").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.parentNode;if(o){const e=o.querySelector(".tab-link.active");e&&e.classList.remove("active"),t.classList.add("active")}})}),document.querySelectorAll(".biography-lang-links .tab-link[data-lang]").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.dataset?.lang;o&&(sessionStorage.setItem("selected_lang",o),document.querySelectorAll(`.biography-text:not(.${o})`).forEach(e=>{e.style.display="none"}),document.querySelectorAll(`.biography-text.${o}`).forEach(e=>{e.style.display="block"}),document.querySelectorAll(`.biography-lang-links .tab-link:not([data-lang="${o}"])`).forEach(e=>{e.classList.remove("active")}),document.querySelectorAll(`.biography-lang-links .tab-link[data-lang="${o}"]`).forEach(e=>{e.classList.add("active")}))})}),function(){void 0!==window.Plyr&&window.Plyr.setup("._init-plyr");const e=document.querySelectorAll(".youtube"),t={};let o=!1;const n=(e=null)=>{for(const[o,n]of Object.entries(t))if(e!==o)if("youtube"===n.type){n.player.pauseVideo()}else if("vimeo"===n.type){n.player.pause()}else if("dailymotion"===n.type){n.player.pause()}},a=e=>{n(e),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.stop()})},r=e=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.start()})},i=()=>{o=!0,e.forEach(e=>{e.addEventListener("click",()=>{const o=e.querySelector("[data-custom-embed]");o&&(e.innerHTML=o.innerHTML);const n=e,i=`player_${n.dataset.id}`,l=n.dataset.type,d=n.dataset.videoId,c=parseInt(n.dataset.time||"0",10);if(d&&l)if(a(i),"youtube"===l&&window.YT){const e=new window.YT.Player(i,{videoId:d,playerVars:{start:c},events:{onReady:e=>{e.target.playVideo()},onStateChange:e=>{e.data===window.YT.PlayerState.PLAYING?a(i):e.data!==window.YT.PlayerState.PAUSED&&e.data!==window.YT.PlayerState.ENDED||r()}}});t[i]={type:l,player:e}}else if("vimeo"===l&&window.Vimeo){const e=document.getElementById(i);e&&(e.innerHTML="");const o=new window.Vimeo.Player(i,{id:d,autoplay:!0,start:c});o.on("play",()=>a(i)),o.on("pause",()=>r()),t[i]={type:l,player:o}}else"dailymotion"===l&&window.dailymotion&&window.dailymotion.createPlayer(i,{video:d,params:{autoplay:1,start:c,mute:!1}}).then(e=>{e.on("play",()=>a(i)),e.on("pause",()=>r()),e.on("ended",()=>r()),t[i]={type:"dailymotion",player:e}}).catch(e=>{console.error("Error initializing Dailymotion player:",e)})})})};window.onYouTubeIframeAPIReady=i,document.addEventListener("DOMContentLoaded",()=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.on("slideChange",()=>{n()})}),setTimeout(()=>{o||i()},500)})}(),function(){const e=["maxresdefault","sddefault","hqdefault","mqdefault","default"],t=(o,n=0)=>{if(o.naturalWidth>120)return;if(n>=e.length)return;const a=e[n],r=o.src,i=new Image;i.onload=()=>{i.naturalWidth>120?o.src=i.src:t(o,n+1)},i.onerror=()=>{t(o,n+1)},i.src=r.replace(/maxresdefault/,a)};document.querySelectorAll(".youtube img").forEach(e=>{t(e)})}(),document.querySelectorAll("[data-download-href]").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const o=e.getAttribute("data-download-href"),n=e.getAttribute("data-download-filename");o&&((e,t)=>{const o=document.createElement("a");o.href=e,o.download=t||e.split("/").pop()||"download",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(o,n)})})}();
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dreher-media/dm-js-lib",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Centralized JavaScript library for Dreher.Media websites with CDN delivery",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/dm-js-lib.min.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/dm-js-lib.min.js",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
13
|
+
"format": "prettier --write \"src/**/*.{ts,js}\" \"*.{js,json,md}\"",
|
|
14
|
+
"format:check": "prettier --check \"src/**/*.{ts,js}\" \"*.{js,json,md}\"",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"release:patch": "npm version patch && npm publish",
|
|
17
|
+
"release:minor": "npm version minor && npm publish",
|
|
18
|
+
"release:major": "npm version major && npm publish"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cdn",
|
|
22
|
+
"javascript",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
29
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
30
|
+
"prettier": "^3.2.5",
|
|
31
|
+
"rollup": "^4.9.1",
|
|
32
|
+
"typescript": "^5.3.3"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"tslib": "^2.8.1"
|
|
36
|
+
}
|
|
37
|
+
}
|