@lightningjs/blits 1.27.0 → 1.28.0
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/.github/workflows/comment-lint-results.yml +80 -130
- package/.github/workflows/comment-test-results.yml +68 -101
- package/CHANGELOG.md +17 -0
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/announcer/speechSynthesis.js +14 -5
- package/src/component/base/methods.js +2 -1
- package/src/component.js +6 -2
- package/src/engines/L3/element.js +5 -0
- package/src/launch.js +19 -3
- package/src/router/router.js +14 -9
|
@@ -8,144 +8,94 @@ on:
|
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
comment-lint-results:
|
|
11
|
-
# Only run this job if the previous workflow failed (indicating lint errors)
|
|
12
11
|
if: github.event.workflow_run.conclusion == 'failure'
|
|
13
12
|
runs-on: ubuntu-latest
|
|
14
13
|
permissions:
|
|
15
14
|
pull-requests: write
|
|
16
15
|
|
|
17
16
|
steps:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
core.info('Downloading lint results artifact');
|
|
17
|
+
- name: Download Lint Results
|
|
18
|
+
id: download
|
|
19
|
+
uses: actions/github-script@v6
|
|
20
|
+
with:
|
|
21
|
+
result-encoding: string
|
|
22
|
+
script: |
|
|
25
23
|
|
|
26
|
-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
27
|
-
owner: context.repo.owner,
|
|
28
|
-
repo: context.repo.repo,
|
|
29
|
-
run_id: ${{ github.event.workflow_run.id }}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const matchArtifact = artifacts.data.artifacts.find(artifact => artifact.name === "lint-results");
|
|
33
|
-
if (!matchArtifact) {
|
|
34
|
-
core.setFailed('No lint results artifact found');
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
core.info(`Found artifact id: ${matchArtifact.id}`);
|
|
39
|
-
|
|
40
|
-
const download = await github.rest.actions.downloadArtifact({
|
|
41
|
-
owner: context.repo.owner,
|
|
42
|
-
repo: context.repo.repo,
|
|
43
|
-
artifact_id: matchArtifact.id,
|
|
44
|
-
archive_format: 'zip'
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const fs = require('fs');
|
|
48
24
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
25
|
+
core.info('Downloading lint-results artifact');
|
|
26
|
+
const runId = context.payload.workflow_run.id;
|
|
27
|
+
|
|
28
|
+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
29
|
+
owner: context.repo.owner,
|
|
30
|
+
repo: context.repo.repo,
|
|
31
|
+
run_id: runId
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const art = artifacts.data.artifacts.find(a => a.name === "lint-results");
|
|
35
|
+
if (!art) {
|
|
36
|
+
core.setFailed('No lint-results artifact found');
|
|
37
|
+
return 'false';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
core.info(`Found artifact id ${art.id}, downloading…`);
|
|
41
|
+
const dl = await github.rest.actions.downloadArtifact({
|
|
42
|
+
owner: context.repo.owner,
|
|
43
|
+
repo: context.repo.repo,
|
|
44
|
+
artifact_id: art.id,
|
|
45
|
+
archive_format: 'zip'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
require('fs').writeFileSync('lint-results.zip', Buffer.from(dl.data));
|
|
49
|
+
core.info('Downloaded and saved lint-results.zip');
|
|
50
|
+
return 'true';
|
|
51
|
+
|
|
52
|
+
} catch (err) {
|
|
53
|
+
core.setFailed(`Download failed: ${err.message}`);
|
|
54
|
+
return 'false';
|
|
55
55
|
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
core.setFailed(`Failed to download artifact: ${error.message}`);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
result-encoding: string
|
|
61
|
-
|
|
62
|
-
- name: Extract Lint Results
|
|
63
|
-
if: steps.download.outputs.result == 'true'
|
|
64
|
-
id: extract
|
|
65
|
-
run: |
|
|
66
|
-
mkdir -p lint-results
|
|
67
|
-
unzip -o lint-results.zip -d lint-results
|
|
68
56
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (pulls.data.length > 0) {
|
|
114
|
-
core.info(`Found PR by branch: #${pulls.data[0].number}`);
|
|
115
|
-
return pulls.data[0].number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
core.info('No PR found for this workflow run');
|
|
119
|
-
return null;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
core.setFailed(`Failed to find PR: ${error.message}`);
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
result-encoding: string
|
|
125
|
-
|
|
126
|
-
- name: Post Lint Results as PR Comment
|
|
127
|
-
if: steps.find-pr.outputs.result != 'null' && steps.find-pr.outputs.result != ''
|
|
128
|
-
uses: actions/github-script@v6
|
|
129
|
-
with:
|
|
130
|
-
script: |
|
|
131
|
-
try {
|
|
132
|
-
const pr_number = parseInt(${{ steps.find-pr.outputs.result }});
|
|
133
|
-
|
|
134
|
-
if (isNaN(pr_number)) {
|
|
135
|
-
core.warning('Invalid PR number');
|
|
136
|
-
return;
|
|
57
|
+
- name: Extract Lint Results
|
|
58
|
+
if: steps.download.outputs.result == 'true'
|
|
59
|
+
id: extract
|
|
60
|
+
run: |
|
|
61
|
+
mkdir -p lint-results
|
|
62
|
+
unzip -o lint-results.zip -d lint-results
|
|
63
|
+
|
|
64
|
+
if [ -f lint-results/errors.md ]; then
|
|
65
|
+
echo "LINT_ERRORS<<EOF" >> $GITHUB_ENV
|
|
66
|
+
cat lint-results/errors.md >> $GITHUB_ENV
|
|
67
|
+
echo "EOF" >> $GITHUB_ENV
|
|
68
|
+
echo "HAS_ERRORS=true" >> $GITHUB_OUTPUT
|
|
69
|
+
else
|
|
70
|
+
echo "HAS_ERRORS=false" >> $GITHUB_OUTPUT
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
- name: Post Lint Results as PR Comment
|
|
74
|
+
if: steps.extract.outputs.HAS_ERRORS == 'true'
|
|
75
|
+
uses: actions/github-script@v6
|
|
76
|
+
with:
|
|
77
|
+
script: |
|
|
78
|
+
try {
|
|
79
|
+
const pulls = context.payload.workflow_run.pull_requests;
|
|
80
|
+
core.info(`Found ${pulls.length} triggering PR(s)`);
|
|
81
|
+
|
|
82
|
+
if (pulls.length === 0) {
|
|
83
|
+
core.warning('No associated PRs; skipping comment.');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const body = process.env.LINT_ERRORS;
|
|
88
|
+
for (const pr of pulls) {
|
|
89
|
+
core.info(`Commenting lint errors on PR #${pr.number}`);
|
|
90
|
+
await github.rest.issues.createComment({
|
|
91
|
+
owner: context.repo.owner,
|
|
92
|
+
repo: context.repo.repo,
|
|
93
|
+
issue_number: pr.number,
|
|
94
|
+
body
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
core.info('All comments posted');
|
|
98
|
+
} catch (err) {
|
|
99
|
+
core.error('Failed to post lint comment:', err);
|
|
100
|
+
core.setFailed(err.message);
|
|
137
101
|
}
|
|
138
|
-
|
|
139
|
-
core.info(`Posting comment to PR #${pr_number}`);
|
|
140
|
-
|
|
141
|
-
await github.rest.issues.createComment({
|
|
142
|
-
owner: context.repo.owner,
|
|
143
|
-
repo: context.repo.repo,
|
|
144
|
-
issue_number: pr_number,
|
|
145
|
-
body: process.env.LINT_ERRORS
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
core.info(`Successfully posted lint errors comment to PR #${pr_number}`);
|
|
149
|
-
} catch (error) {
|
|
150
|
-
core.setFailed(`Failed to post comment: ${error.message}`);
|
|
151
|
-
}
|
|
@@ -3,8 +3,7 @@ name: Comment Test Results
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_run:
|
|
5
5
|
workflows: ["Run Blits Tests"]
|
|
6
|
-
types:
|
|
7
|
-
- completed
|
|
6
|
+
types: [completed]
|
|
8
7
|
|
|
9
8
|
jobs:
|
|
10
9
|
comment-test-results:
|
|
@@ -13,102 +12,70 @@ jobs:
|
|
|
13
12
|
pull-requests: write
|
|
14
13
|
|
|
15
14
|
steps:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (pulls.data.length > 0) {
|
|
85
|
-
return pulls.data[0].number;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.log('No PR found');
|
|
89
|
-
return null;
|
|
90
|
-
result-encoding: string
|
|
91
|
-
|
|
92
|
-
- name: Post Test Results as PR Comment
|
|
93
|
-
if: steps.find-pr.outputs.result != 'null'
|
|
94
|
-
uses: actions/github-script@v6
|
|
95
|
-
with:
|
|
96
|
-
script: |
|
|
97
|
-
const fs = require('fs');
|
|
98
|
-
const pr_number = parseInt(${{ steps.find-pr.outputs.result }});
|
|
99
|
-
const status = process.env.FAILED === 'true' ? '❌ FAILED' : '✅ PASSED';
|
|
100
|
-
|
|
101
|
-
let commentBody = `#### Test Results: ${status}\n**Run at:** ${process.env.TIMESTAMP}\n\n**Summary:**\n${process.env.SUMMARY}`;
|
|
102
|
-
|
|
103
|
-
// Add error output if it exists
|
|
104
|
-
if (fs.existsSync('raw_error.txt')) {
|
|
105
|
-
const errorOutput = fs.readFileSync('raw_error.txt', 'utf8');
|
|
106
|
-
commentBody += '\n\n**Error Output:**\n```\n' + errorOutput + '\n```';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
github.rest.issues.createComment({
|
|
110
|
-
owner: context.repo.owner,
|
|
111
|
-
repo: context.repo.repo,
|
|
112
|
-
issue_number: pr_number,
|
|
113
|
-
body: commentBody
|
|
114
|
-
});
|
|
15
|
+
- name: Download Test Results
|
|
16
|
+
uses: actions/github-script@v6
|
|
17
|
+
with:
|
|
18
|
+
script: |
|
|
19
|
+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
20
|
+
owner: context.repo.owner,
|
|
21
|
+
repo: context.repo.repo,
|
|
22
|
+
run_id: ${{ github.event.workflow_run.id }}
|
|
23
|
+
});
|
|
24
|
+
const art = artifacts.data.artifacts.find(a => a.name === "test-results");
|
|
25
|
+
if (!art) core.setFailed('No test-results artifact found');
|
|
26
|
+
const dl = await github.rest.actions.downloadArtifact({
|
|
27
|
+
owner: context.repo.owner,
|
|
28
|
+
repo: context.repo.repo,
|
|
29
|
+
artifact_id: art.id,
|
|
30
|
+
archive_format: 'zip'
|
|
31
|
+
});
|
|
32
|
+
require('fs').writeFileSync('test-results.zip', Buffer.from(dl.data));
|
|
33
|
+
- name: Extract Test Results
|
|
34
|
+
run: |
|
|
35
|
+
mkdir -p test-results
|
|
36
|
+
unzip -o test-results.zip -d test-results
|
|
37
|
+
echo "TIMESTAMP=$(cat test-results/timestamp.txt)" >> $GITHUB_ENV
|
|
38
|
+
echo "SUMMARY=$(cat test-results/summary.txt)" >> $GITHUB_ENV
|
|
39
|
+
echo "FAILED=$(cat test-results/failed.txt)" >> $GITHUB_ENV
|
|
40
|
+
if [ -f test-results/error.txt ]; then cp test-results/error.txt raw_error.txt; fi
|
|
41
|
+
|
|
42
|
+
- name: Post Test Results as PR Comment
|
|
43
|
+
uses: actions/github-script@v6
|
|
44
|
+
with:
|
|
45
|
+
script: |
|
|
46
|
+
const fs = require('fs');
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const pulls = context.payload.workflow_run.pull_requests;
|
|
50
|
+
console.log(`Found ${pulls.length} triggering PR(s).`);
|
|
51
|
+
|
|
52
|
+
if (pulls.length === 0) {
|
|
53
|
+
console.warn('No pull requests found for this workflow run; skipping comment.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const status = process.env.FAILED === 'true' ? '❌ FAILED' : '✅ PASSED';
|
|
58
|
+
let commentBody = `#### Test Results: ${status}\n`
|
|
59
|
+
+ `**Run at:** ${process.env.TIMESTAMP}\n\n`
|
|
60
|
+
+ `**Summary:**\n${process.env.SUMMARY}`;
|
|
61
|
+
|
|
62
|
+
if (fs.existsSync('raw_error.txt')) {
|
|
63
|
+
commentBody += '\n\n**Error Output:**\n```\n'
|
|
64
|
+
+ fs.readFileSync('raw_error.txt', 'utf8')
|
|
65
|
+
+ '\n```';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const pr of pulls) {
|
|
69
|
+
console.log(`Commenting on PR #${pr.number}`);
|
|
70
|
+
await github.rest.issues.createComment({
|
|
71
|
+
owner: context.repo.owner,
|
|
72
|
+
repo: context.repo.repo,
|
|
73
|
+
issue_number: pr.number,
|
|
74
|
+
body: commentBody
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error('🛑 Failed to post test results comment:', err);
|
|
80
|
+
core.setFailed(`Comment step failed: ${err.message}`);
|
|
81
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
_15 apr 2025_
|
|
4
|
+
|
|
5
|
+
## v1.28.0
|
|
6
|
+
|
|
7
|
+
- Added graceful handling of announcer when speechSynthesis API is not available
|
|
8
|
+
- Renamed `beforeAll` method on router to `beforeEach` (as specified in the type definitions)
|
|
9
|
+
- Fixed detection of correct PR to comment for github workflows
|
|
10
|
+
|
|
11
|
+
_15 apr 2025_
|
|
12
|
+
|
|
13
|
+
## v1.27.1
|
|
14
|
+
|
|
15
|
+
- Fixed issue with global watcher on router state not being cleared out
|
|
16
|
+
- Minor performance updates
|
|
17
|
+
- Fixed issue with retrieving correct renderer version for logging
|
|
18
|
+
- Fixed issue with nested layouts not properly updating parent layout
|
|
19
|
+
|
|
3
20
|
_11 apr 2025_
|
|
4
21
|
|
|
5
22
|
## v1.27.0
|
package/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader, type Re
|
|
|
23
23
|
declare module '@lightningjs/blits' {
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
export interface AnnouncerUtterance extends Promise {
|
|
26
|
+
export interface AnnouncerUtterance extends Promise<T> {
|
|
27
27
|
/**
|
|
28
28
|
* Removes a specific message from the announcement queue,
|
|
29
29
|
* to make sure it isn't spoke out.
|
|
@@ -481,7 +481,7 @@ declare module '@lightningjs/blits' {
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
export interface RouterHooks {
|
|
484
|
-
beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route
|
|
484
|
+
beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route> | void;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
export interface RouterConfig {
|
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import { Log } from '../lib/log.js'
|
|
19
|
+
|
|
18
20
|
const syn = window.speechSynthesis
|
|
19
21
|
|
|
20
22
|
const isAndroid = /android/i.test((window.navigator || {}).userAgent || '')
|
|
@@ -82,14 +84,21 @@ const speak = (options) => {
|
|
|
82
84
|
|
|
83
85
|
export default {
|
|
84
86
|
speak(options) {
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
+
if (syn !== undefined) {
|
|
88
|
+
if (initialized === false) {
|
|
89
|
+
initialize()
|
|
90
|
+
}
|
|
91
|
+
return speak(options)
|
|
92
|
+
} else {
|
|
93
|
+
Log.error('speechSynthesis web API not available')
|
|
94
|
+
return Promise.reject({ error: 'unavailable' })
|
|
87
95
|
}
|
|
88
|
-
return speak(options)
|
|
89
96
|
},
|
|
90
97
|
cancel() {
|
|
91
|
-
syn
|
|
92
|
-
|
|
98
|
+
if (syn !== undefined) {
|
|
99
|
+
syn.cancel()
|
|
100
|
+
clear()
|
|
101
|
+
}
|
|
93
102
|
},
|
|
94
103
|
// @todo
|
|
95
104
|
// getVoices() {
|
|
@@ -58,9 +58,10 @@ export default {
|
|
|
58
58
|
eventListeners.removeListeners(this)
|
|
59
59
|
deleteChildren(this[symbols.children])
|
|
60
60
|
removeGlobalEffects(this[symbols.effects])
|
|
61
|
-
Log.debug(`Destroyed component ${this.componentId}`)
|
|
62
61
|
this[symbols.state] = {}
|
|
63
62
|
this[symbols.props] = {}
|
|
63
|
+
this[symbols.effects].length = 0
|
|
64
|
+
Log.debug(`Destroyed component ${this.componentId}`)
|
|
64
65
|
},
|
|
65
66
|
writable: false,
|
|
66
67
|
enumerable: true,
|
package/src/component.js
CHANGED
|
@@ -195,13 +195,17 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
195
195
|
|
|
196
196
|
let old = this[key]
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
const eff = (force = false) => {
|
|
199
199
|
const newValue = target[key]
|
|
200
200
|
if (old !== newValue || force === true) {
|
|
201
201
|
this[symbols.watchers][watchKey].apply(this, [newValue, old])
|
|
202
202
|
old = newValue
|
|
203
203
|
}
|
|
204
|
-
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// store reference to the effect
|
|
207
|
+
this[symbols.effects].push(eff)
|
|
208
|
+
effect(eff)
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
|
|
@@ -128,6 +128,11 @@ const layoutFn = function (config) {
|
|
|
128
128
|
if (config['@updated'] !== undefined) {
|
|
129
129
|
config['@updated']({ w: this.node.width, h: this.node.height }, this)
|
|
130
130
|
}
|
|
131
|
+
|
|
132
|
+
// trigger layout on parent if parent is a layout
|
|
133
|
+
if (this.config.parent && this.config.parent.props.__layout === true) {
|
|
134
|
+
this.config.parent.triggerLayout(this.config.parent.props)
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
const isTransition = (value) => {
|
package/src/launch.js
CHANGED
|
@@ -19,17 +19,33 @@ import Settings from './settings.js'
|
|
|
19
19
|
import { initLog, Log } from './lib/log.js'
|
|
20
20
|
import engine from './engine.js'
|
|
21
21
|
import blitsPackageInfo from '../package.json' assert { type: 'json' }
|
|
22
|
-
import rendererPackageInfo from '../../renderer/package.json' assert { type: 'json' }
|
|
23
22
|
|
|
24
23
|
export let renderer = {}
|
|
25
24
|
export const stage = {}
|
|
26
25
|
|
|
26
|
+
async function rendererVersion() {
|
|
27
|
+
let rendererPackageInfo
|
|
28
|
+
try {
|
|
29
|
+
// Dynamically import the renderer package.json
|
|
30
|
+
rendererPackageInfo = await import('../../renderer/package.json')
|
|
31
|
+
if (rendererPackageInfo !== undefined) {
|
|
32
|
+
return rendererPackageInfo.version
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// Fallback to renderer version in dependencies
|
|
36
|
+
return blitsPackageInfo.dependencies['@lightningjs/renderer']
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
export default (App, target, settings) => {
|
|
28
41
|
Settings.set(settings)
|
|
29
42
|
|
|
30
43
|
initLog()
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
|
|
45
|
+
rendererVersion().then((v) => {
|
|
46
|
+
Log.info('Blits Version ', blitsPackageInfo.version)
|
|
47
|
+
Log.info('Renderer Version ', v)
|
|
48
|
+
})
|
|
33
49
|
|
|
34
50
|
stage.element = engine.Element
|
|
35
51
|
|
package/src/router/router.js
CHANGED
|
@@ -23,15 +23,20 @@ import { Log } from '../lib/log.js'
|
|
|
23
23
|
import { stage } from '../launch.js'
|
|
24
24
|
import Focus from '../focus.js'
|
|
25
25
|
import Announcer from '../announcer/announcer.js'
|
|
26
|
+
import Settings from '../settings.js'
|
|
26
27
|
|
|
27
28
|
export let currentRoute
|
|
28
|
-
export const state = reactive(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
export const state = reactive(
|
|
30
|
+
{
|
|
31
|
+
path: '',
|
|
32
|
+
navigating: false,
|
|
33
|
+
data: null,
|
|
34
|
+
params: null,
|
|
35
|
+
hash: '',
|
|
36
|
+
},
|
|
37
|
+
Settings.get('reactivityMode'),
|
|
38
|
+
true
|
|
39
|
+
)
|
|
35
40
|
|
|
36
41
|
// Changed from WeakMap to Map to allow for caching of views by the url hash.
|
|
37
42
|
// We are manually doing the cleanup of the cache when the route is not marked as keepAlive.
|
|
@@ -143,8 +148,8 @@ export const navigate = async function () {
|
|
|
143
148
|
let beforeEachResult
|
|
144
149
|
if (this.parent[symbols.routerHooks]) {
|
|
145
150
|
const hooks = this.parent[symbols.routerHooks]
|
|
146
|
-
if (hooks.
|
|
147
|
-
beforeEachResult = await hooks.
|
|
151
|
+
if (hooks.beforeEach) {
|
|
152
|
+
beforeEachResult = await hooks.beforeEach(route, previousRoute)
|
|
148
153
|
if (isString(beforeEachResult)) {
|
|
149
154
|
to(beforeEachResult)
|
|
150
155
|
return
|