Skip to content

Commit 02480fa

Browse files
authored
Merge pull request #21 from php-flasher/feat/hotwired-turbo-support
Feat/hotwired turbo support
2 parents 329cd53 + 4a71e6d commit 02480fa

31 files changed

+6621
-6030
lines changed

package.json

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@flasher/flasher-js",
3+
"type": "module",
34
"version": "1.1.0",
45
"description": "PHPFlasher javascript monorepo",
56
"keywords": [
@@ -39,35 +40,35 @@
3940
"url": "https://github.com/php-flasher/flasher-js.git"
4041
},
4142
"devDependencies": {
42-
"@babel/core": "^7.18.6",
43-
"@lerna-lite/cli": "^1.6.0",
44-
"@lerna-lite/exec": "^1.6.0",
45-
"@lerna-lite/run": "^1.6.0",
46-
"@rollup/plugin-babel": "^5.3.1",
47-
"@rollup/plugin-commonjs": "^22.0.1",
48-
"@rollup/plugin-node-resolve": "^13.3.0",
49-
"@rollup/plugin-typescript": "^8.3.3",
50-
"@types/node": "^18.0.0",
51-
"@typescript-eslint/eslint-plugin": "^5.30.3",
52-
"@typescript-eslint/parser": "^5.30.3",
53-
"cssnano": "^5.1.12",
54-
"eslint": "^8.19.0",
43+
"@babel/core": "^7.20.2",
44+
"@lerna-lite/cli": "^1.12.0",
45+
"@lerna-lite/exec": "^1.12.0",
46+
"@lerna-lite/run": "^1.12.0",
47+
"@rollup/plugin-babel": "^6.0.2",
48+
"@rollup/plugin-commonjs": "^23.0.2",
49+
"@rollup/plugin-node-resolve": "^15.0.1",
50+
"@rollup/plugin-typescript": "^9.0.2",
51+
"@types/node": "^18.11.9",
52+
"@typescript-eslint/eslint-plugin": "^5.43.0",
53+
"@typescript-eslint/parser": "^5.43.0",
54+
"cssnano": "^5.1.14",
55+
"eslint": "^8.28.0",
5556
"eslint-config-airbnb": "^19.0.4",
5657
"eslint-config-airbnb-typescript": "^17.0.0",
5758
"eslint-plugin-import": "^2.26.0",
58-
"eslint-plugin-jsx-a11y": "^6.6.0",
59-
"eslint-plugin-react": "^7.30.1",
59+
"eslint-plugin-jsx-a11y": "^6.6.1",
60+
"eslint-plugin-react": "^7.31.11",
6061
"eslint-plugin-react-hooks": "^4.6.0",
61-
"node-sass": "^7.0.1",
62+
"node-sass": "^8.0.0",
6263
"postcss-discard-comments": "^5.1.2",
63-
"rollup": "^2.75.7",
64+
"rollup": "^3.3.0",
6465
"rollup-plugin-clear": "^2.0.7",
6566
"rollup-plugin-filesize": "^9.1.2",
6667
"rollup-plugin-styles": "^4.0.0",
6768
"rollup-plugin-terser": "^7.0.2",
68-
"rollup-plugin-typescript2": "^0.32.1",
69-
"ts-node": "^10.8.2",
70-
"tslib": "^2.4.0",
71-
"typescript": "^4.7.4"
69+
"rollup-plugin-typescript2": "^0.34.1",
70+
"ts-node": "^10.9.1",
71+
"tslib": "^2.4.1",
72+
"typescript": "^4.9.3"
7273
}
7374
}

packages/flasher/dist/flasher.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@
113113
var containerSelector = ".fl-main-container[data-position=\"".concat(options.position, "\"]");
114114
var container = document.querySelector(containerSelector);
115115
if (container) {
116+
container.dataset.turboCache = 'false';
116117
return container;
117118
}
118119
container = document.createElement('div');
119120
container.classList.add('fl-main-container');
120121
container.dataset.position = options.position;
122+
container.dataset.turboCache = 'false';
121123
Object.keys(options.style).forEach(function (key) {
122124
container === null || container === void 0 ? void 0 : container.style.setProperty(key, options.style[key]);
123125
});
@@ -187,7 +189,7 @@
187189
template.addEventListener('mouseover', function () { return clearInterval(progressInterval); });
188190
};
189191
FlasherFactory.prototype.applyDarkMode = function () {
190-
if (document.body.classList.contains('fl-dark-mode')) {
192+
if (document.body.classList.contains('fl-dark-mode') || document.querySelector('style.flasher-js')) {
191193
return;
192194
}
193195
var _a = [].concat(this.options.darkMode), mode = _a[0], _b = _a[1], className = _b === void 0 ? '.dark' : _b;
@@ -197,6 +199,7 @@
197199
: "".concat(className, " ").concat(css);
198200
var style = document.createElement('style');
199201
style.type = 'text/css';
202+
style.classList.add('flasher-js');
200203
style.appendChild(document.createTextNode(css));
201204
document.head.appendChild(style);
202205
document.body.classList.add('fl-dark-mode');
@@ -348,7 +351,7 @@
348351
tag.setAttribute('src', urls[0]);
349352
tag.setAttribute('type', 'text/javascript');
350353
tag.onload = function () { return _this.addScripts(urls.slice(1), callback); };
351-
document.body.appendChild(tag);
354+
document.head.appendChild(tag);
352355
};
353356
Flasher.prototype.renderEnvelopes = function (envelopes, context) {
354357
var _this = this;

packages/flasher/dist/flasher.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/flasher/dist/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ var FlasherFactory = (function () {
109109
var containerSelector = ".fl-main-container[data-position=\"".concat(options.position, "\"]");
110110
var container = document.querySelector(containerSelector);
111111
if (container) {
112+
container.dataset.turboCache = 'false';
112113
return container;
113114
}
114115
container = document.createElement('div');
115116
container.classList.add('fl-main-container');
116117
container.dataset.position = options.position;
118+
container.dataset.turboCache = 'false';
117119
Object.keys(options.style).forEach(function (key) {
118120
container === null || container === void 0 ? void 0 : container.style.setProperty(key, options.style[key]);
119121
});
@@ -183,7 +185,7 @@ var FlasherFactory = (function () {
183185
template.addEventListener('mouseover', function () { return clearInterval(progressInterval); });
184186
};
185187
FlasherFactory.prototype.applyDarkMode = function () {
186-
if (document.body.classList.contains('fl-dark-mode')) {
188+
if (document.body.classList.contains('fl-dark-mode') || document.querySelector('style.flasher-js')) {
187189
return;
188190
}
189191
var _a = [].concat(this.options.darkMode), mode = _a[0], _b = _a[1], className = _b === void 0 ? '.dark' : _b;
@@ -193,6 +195,7 @@ var FlasherFactory = (function () {
193195
: "".concat(className, " ").concat(css);
194196
var style = document.createElement('style');
195197
style.type = 'text/css';
198+
style.classList.add('flasher-js');
196199
style.appendChild(document.createTextNode(css));
197200
document.head.appendChild(style);
198201
document.body.classList.add('fl-dark-mode');
@@ -344,7 +347,7 @@ var Flasher = (function () {
344347
tag.setAttribute('src', urls[0]);
345348
tag.setAttribute('type', 'text/javascript');
346349
tag.onload = function () { return _this.addScripts(urls.slice(1), callback); };
347-
document.body.appendChild(tag);
350+
document.head.appendChild(tag);
348351
};
349352
Flasher.prototype.renderEnvelopes = function (envelopes, context) {
350353
var _this = this;

packages/flasher/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
"url": "https://github.com/php-flasher/flasher-js.git"
3737
},
3838
"dependencies": {
39-
"csstype": "^3.1.0"
39+
"csstype": "^3.1.1"
4040
}
4141
}

packages/flasher/src/flasher.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export default class Flasher {
160160
tag.setAttribute('type', 'text/javascript');
161161
tag.onload = () => this.addScripts(urls.slice(1), callback);
162162

163-
document.body.appendChild(tag);
163+
document.head.appendChild(tag);
164164
}
165165

166166
renderEnvelopes(envelopes: Envelope[], context: ResponseContext): void {

packages/flasher/src/flasherFactory.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,14 @@ export default class FlasherFactory implements NotificationFactoryInterface {
108108
const containerSelector = `.fl-main-container[data-position="${options.position}"]`;
109109
let container = document.querySelector(containerSelector) as HTMLDivElement;
110110
if (container) {
111+
container.dataset.turboCache = 'false';
111112
return container;
112113
}
113114

114115
container = document.createElement('div');
115116
container.classList.add('fl-main-container');
116117
container.dataset.position = options.position;
118+
container.dataset.turboCache = 'false';
117119

118120
Object.keys(options.style).forEach((key: string) => {
119121
container?.style.setProperty(key, options.style[key as keyof Properties] as string);
@@ -200,7 +202,7 @@ export default class FlasherFactory implements NotificationFactoryInterface {
200202
}
201203

202204
applyDarkMode(): void {
203-
if (document.body.classList.contains('fl-dark-mode')) {
205+
if (document.body.classList.contains('fl-dark-mode') || document.querySelector('style.flasher-js')) {
204206
return;
205207
}
206208

@@ -213,6 +215,7 @@ export default class FlasherFactory implements NotificationFactoryInterface {
213215

214216
const style = document.createElement('style');
215217
style.type = 'text/css';
218+
style.classList.add('flasher-js');
216219
style.appendChild(document.createTextNode(css));
217220
document.head.appendChild(style);
218221

0 commit comments

Comments
 (0)