Skip to content

Commit

Permalink
Merge branch '1.3.x' into temp-489ead
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky authored Dec 16, 2024
2 parents c24711e + 7dd44c2 commit 9651711
Show file tree
Hide file tree
Showing 50 changed files with 1,034 additions and 212 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.mergify.yml export-ignore
/castor.php export-ignore
/CODE_OF_CONDUCT.md export-ignore
/ecs.php export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- name: "Check file permissions"
run: |
test "$(find . -type f -not -path './.git/*' -executable)" == ""
test "$(find . -type f -not -path './.git/*' -not -wholename './link' -executable)" == ""
- name: "Find non-printable ASCII characters"
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0

- name: "Release"
uses: "laminas/automatic-releases@1.24.0"
uses: "laminas/automatic-releases@1.25.0"
with:
command-name: "laminas:automatic-releases:release"
env:
Expand All @@ -42,7 +42,7 @@ jobs:
fetch-depth: 0

- name: "Create Merge-Up Pull Request"
uses: "laminas/automatic-releases@1.24.0"
uses: "laminas/automatic-releases@1.25.0"
with:
command-name: "laminas:automatic-releases:create-merge-up-pull-request"
env:
Expand All @@ -65,7 +65,7 @@ jobs:
fetch-depth: 0

- name: "Create and/or Switch to new Release Branch"
uses: "laminas/automatic-releases@1.24.0"
uses: "laminas/automatic-releases@1.25.0"
with:
command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor"
env:
Expand All @@ -88,7 +88,7 @@ jobs:
fetch-depth: 0

- name: "Bump Changelog Version On Originating Release Branch"
uses: "laminas/automatic-releases@1.24.0"
uses: "laminas/automatic-releases@1.25.0"
with:
command-name: "laminas:automatic-releases:bump-changelog"
env:
Expand All @@ -111,7 +111,7 @@ jobs:
fetch-depth: 0

- name: "Create new milestones"
uses: "laminas/automatic-releases@1.24.0"
uses: "laminas/automatic-releases@1.25.0"
with:
command-name: "laminas:automatic-releases:create-milestones"
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@v2.3.1
uses: ossf/scorecard-action@v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -50,7 +50,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.4.0
with:
name: SARIF file
path: results.sarif
Expand Down
16 changes: 16 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pull_request_rules:
- name: Automatic merge
description: Merge when PR passes all branch protection and has label automerge
conditions:
- label = automerge
actions:
merge:
- name: Label conflicting pull requests
description: Add a label to a pull request with conflict to spot it easily
conditions:
- conflict
- '-closed'
actions:
label:
toggle:
- conflict
82 changes: 76 additions & 6 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,58 @@
"version": "1.0.0",
"symfony": {
"controllers": {
"backgroundsync-form": {
"main": "src/backgroundsync-form_controller.js",
"name": "pwa/backgroundsync-form",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"badge": {
"main": "src/badge_controller.js",
"name": "pwa/badge",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"battery": {
"main": "src/battery_controller.js",
"name": "pwa/battery",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"connection-status": {
"main": "src/connection-status_controller.js",
"name": "pwa/connection-status",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"backgroundsync-form": {
"main": "src/backgroundsync-form_controller.js",
"name": "pwa/backgroundsync-form",
"device-orientation": {
"main": "src/device-orientation_controller.js",
"name": "pwa/device-orientation",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"sync-broadcast": {
"main": "src/sync-broadcast_controller.js",
"name": "pwa/sync-broadcast",
"fullscreen": {
"main": "src/fullscreen_controller.js",
"name": "pwa/fullscreen",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"geolocation": {
"main": "src/geolocation_controller.js",
"name": "pwa/geolocation",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"install": {
"main": "src/install_controller.js",
"name": "pwa/install",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
Expand All @@ -32,6 +67,41 @@
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"presentation": {
"main": "src/presentation_controller.js",
"name": "pwa/presentation",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"receiver": {
"main": "src/receiver_controller.js",
"name": "pwa/receiver",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"share": {
"main": "src/share_controller.js",
"name": "pwa/share",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"sync-broadcast": {
"main": "src/sync-broadcast_controller.js",
"name": "pwa/sync-broadcast",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
},
"vibration": {
"main": "src/vibration_controller.js",
"name": "pwa/vibration",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true
}
},
"importmap": {
Expand Down
10 changes: 10 additions & 0 deletions assets/src/abstract_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

import { Controller } from '@hotwired/stimulus';

/* stimulusFetch: 'lazy' */
export default class extends Controller {
dispatchEvent = (name, payload) => {
this.dispatch(name, { detail: payload });
}
}
43 changes: 26 additions & 17 deletions assets/src/backgroundsync-form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { Controller } from '@hotwired/stimulus';
/* stimulusFetch: 'lazy' */
export default class extends Controller {
static values = {
params: { type: Object, default: {
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
redirect: 'follow',
referrerPolicy: 'no-referrer'
}},
params: {
type: Object,
default: {
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
redirect: 'follow',
referrerPolicy: 'no-referrer'
}
},
headers: { type: Object, default: {} },
redirection: { type: String, default: null },
};
Expand All @@ -28,19 +31,25 @@ export default class extends Controller {
try {
const params = this.paramsValue;
params.headers = this.headersValue;
if (form.enctype === 'multipart/form-data') {
params.body = new FormData(form);
} else if (form.enctype === 'application/json') {
params.body = JSON.stringify(Object.fromEntries(new FormData(form)));
} else if (form.enctype === 'application/x-www-form-urlencoded') {
params.headers['Content-Type'] = 'application/x-www-form-urlencoded';
params.body = new URLSearchParams(new FormData(form));
} else {
console.error('Unsupported form enctype');
switch (form.enctype) {
case 'multipart/form-data':
params.headers['Content-Type'] = 'multipart/form-data';
params.body = new FormData(form);
break;
case 'application/json':
params.headers['Content-Type'] = 'application/json';
params.body = JSON.stringify(Object.fromEntries(new FormData(form)));
break;
case 'application/x-www-form-urlencoded':
params.headers['Content-Type'] = 'application/x-www-form-urlencoded';
params.body = (new URLSearchParams(new FormData(form))).toString();
break;
default:
console.error('Unknown form enctype');
return;
}
params.method = form.method.toUpperCase();
const response = await fetch(url, params);
console.log(new URLSearchParams(params.body).toString(), params, params.headers);
if (response.redirected) {
window.location.assign(response.url);
return;
Expand Down
16 changes: 16 additions & 0 deletions assets/src/badge_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

import AbstractController from './abstract_controller.js';

/* stimulusFetch: 'lazy' */
export default class extends AbstractController {
update = async ({counter}) => {
await navigator.setAppBadge(counter);
this.dispatchEvent('badge:updated', { counter });
}

clear = async () => {
await navigator.clearAppBadge();
this.dispatchEvent('badge:cleared');
}
}
36 changes: 36 additions & 0 deletions assets/src/battery_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

import AbstractController from './abstract_controller.js';

/* stimulusFetch: 'lazy' */
export default class extends AbstractController {
async connect() {
const battery = await navigator.getBattery();
battery.addEventListener('chargingchange', () => this.updateChargeInfo(battery));
battery.addEventListener('levelchange', () => this.updateLevelInfo(battery));
battery.addEventListener('chargingtimechange', () => this.updateChargingInfo(battery));
battery.addEventListener('dischargingtimechange', () => this.updateDischargingInfo(battery));

await this.updateChargeInfo(battery);
await this.updateLevelInfo(battery);
await this.updateChargingInfo(battery);
await this.updateDischargingInfo(battery);
}
update = async ({counter}) => {
await navigator.setAppBadge(counter);
this.dispatchEvent('badge:updated', { counter });
}

updateChargeInfo = async (battery) => {
this.dispatchEvent('battery:charge', { charging: battery.charging });
}
updateLevelInfo = async (battery) => {
this.dispatchEvent('battery:level', { level: battery.level });
}
updateChargingInfo = async (battery) => {
this.dispatchEvent('battery:chargingtime', { chargingTime: battery.chargingTime });
}
updateDischargingInfo = async (battery) => {
this.dispatchEvent('battery:dischargingtime', { dischargingTime: battery.dischargingTime });
}
}
7 changes: 2 additions & 5 deletions assets/src/connection-status_controller.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

import { Controller } from '@hotwired/stimulus';
import AbstractController from './abstract_controller.js';

/* stimulusFetch: 'lazy' */
export default class extends Controller {
export default class extends AbstractController {
static targets = ['message', 'attribute'];
static values = {
onlineMessage: { type: String, default: 'You are online.' },
Expand Down Expand Up @@ -37,9 +37,6 @@ export default class extends Controller {
});
});
}
dispatchEvent = (name, payload) => {
this.dispatch(name, { detail: payload });
}

statusChanged = (data) => {
this.messageTargets.forEach((element) => {
Expand Down
21 changes: 21 additions & 0 deletions assets/src/device-orientation_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

import AbstractController from './abstract_controller.js';

/* stimulusFetch: 'lazy' */
export default class extends AbstractController {
connect() {
window.addEventListener(
'deviceorientation',
(event) => {
this.dispatchEvent({
absolute: event.absolute,
alpha: event.alpha,
beta: event.beta,
gamma: event.gamma
})
},
true
);
}
}
Loading

0 comments on commit 9651711

Please sign in to comment.