Skip to content

Commit

Permalink
feat: Supports AssetMapper (#2)
Browse files Browse the repository at this point in the history
* feat: Supports AssetMapper

* fix psalm warning
  • Loading branch information
priyadi authored Apr 4, 2024
1 parent d2cdab2 commit 4f0f7f6
Show file tree
Hide file tree
Showing 11 changed files with 1,263 additions and 1,311 deletions.
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.26.0" installed="3.26.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="php-cs-fixer" version="^3.42.0" installed="3.42.0" location="./tools/php-cs-fixer" copy="false"/>
</phive>
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.4.1

* feat: Supports AssetMapper

## 1.4.0

* Supports Symfony 7
Expand Down
3 changes: 0 additions & 3 deletions assets/.babelrc

This file was deleted.

11 changes: 11 additions & 0 deletions assets/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
presets: [
['@babel/preset-env', {
"loose": true,
"modules": false
}]
],
assumptions: {
superIsCallableConstructor: false,
},
};
91 changes: 39 additions & 52 deletions assets/dist/autoexpire.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,48 @@

'use strict';

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _stimulus = require("@hotwired/stimulus");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var _default = exports["default"] = /*#__PURE__*/function (_Controller) {
_inherits(_default, _Controller);
var _super = _createSuper(_default);
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
import { Controller } from '@hotwired/stimulus';
var _default = /*#__PURE__*/function (_Controller) {
function _default() {
_classCallCheck(this, _default);
return _super.apply(this, arguments);
return _callSuper(this, _default, arguments);
}
_createClass(_default, [{
key: "connect",
value: function connect() {
var element = this.element;
var href = element.getAttribute('href');
if (!href) {
return;
}
var url = new URL(href, 'http://example.com/');
if (!url) {
return;
}
var expiration = parseInt(url.searchParams.get('expiration'));
var secondsToExpiration = 1800;
if (expiration) {
var now = new Date().getTime() / 1000;
secondsToExpiration = expiration - now;
}
if (secondsToExpiration < 0) {
secondsToExpiration = 1;
}
setTimeout(function () {
element.classList.add('disabled');
element.setAttribute('disabled', 'disabled');
element.setAttribute('tabindex', '-1');
element.setAttribute('aria-disabled', 'true');
element.setAttribute('title', 'This link has expired. Please refresh the page, and try again.');
element.href = '#';
}, secondsToExpiration * 1000);
_inheritsLoose(_default, _Controller);
var _proto = _default.prototype;
_proto.connect = function connect() {
var element = this.element;
var href = element.getAttribute('href');
if (!href) {
return;
}
var url = new URL(href, 'http://example.com/');
if (!url) {
return;
}
var expiration = parseInt(url.searchParams.get('expiration'));
var secondsToExpiration = 1800;
if (expiration) {
var now = new Date().getTime() / 1000;
secondsToExpiration = expiration - now;
}
if (secondsToExpiration < 0) {
secondsToExpiration = 1;
}
}]);
setTimeout(function () {
element.classList.add('disabled');
element.setAttribute('disabled', 'disabled');
element.setAttribute('tabindex', '-1');
element.setAttribute('aria-disabled', 'true');
element.setAttribute('title', 'This link has expired. Please refresh the page, and try again.');
element.href = '#';
}, secondsToExpiration * 1000);
};
return _default;
}(_stimulus.Controller);
}(Controller);
export { _default as default };
Loading

0 comments on commit 4f0f7f6

Please sign in to comment.