@lightningjs/blits 1.45.1 → 2.0.0-beta.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/CHANGELOG.md +0 -17
- package/README.md +0 -2
- package/index.d.ts +23 -86
- package/package.json +5 -24
- package/scripts/prepublishOnly.js +1 -4
- package/src/component/base/methods.js +16 -76
- package/src/component/base/utils.js +18 -4
- package/src/component/setup/props.js +37 -28
- package/src/component/setup/state.js +4 -4
- package/src/component.js +25 -16
- package/src/components/Circle.js +49 -7
- package/src/components/FPScounter.js +226 -88
- package/src/components/RouterView.js +50 -5
- package/src/components/Sprite.js +61 -20
- package/src/engines/L3/element.js +109 -86
- package/src/engines/L3/fontLoader.js +26 -31
- package/src/engines/L3/shaderLoader.js +56 -6
- package/src/focus.js +9 -9
- package/src/launch.js +1 -2
- package/src/lib/codegenerator/generator.js +117 -16
- package/src/lib/colors/colors.js +0 -1
- package/src/lib/lifecycle.js +3 -3
- package/src/lib/precompiler/precompiler.js +14 -23
- package/src/lib/reactivityguard/computedprops.js +1 -6
- package/src/lib/shaders/shaders.js +163 -0
- package/src/lib/symbols.js +8 -0
- package/src/lib/templateparser/parser.js +6 -2
- package/src/lib/utils.js +36 -0
- package/src/router/router.js +7 -7
- package/vite/blitsTips.js +57 -0
- package/vite/msdfGenerator.js +52 -6
- package/vite/preCompiler.js +5 -15
- package/vscode/data/template-attributes.json +112 -0
- package/src/plugins/appstate.d.ts +0 -29
- package/src/plugins/index.d.ts +0 -29
- package/src/plugins/language.d.ts +0 -34
- package/src/plugins/storage/storage.d.ts +0 -29
- package/src/plugins/theme.d.ts +0 -35
package/vite/msdfGenerator.js
CHANGED
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
import path from 'path'
|
|
19
19
|
import * as fs from 'fs'
|
|
20
20
|
import { createHash } from 'crypto'
|
|
21
|
-
import {
|
|
22
|
-
import { adjustFont } from '@lightningjs/msdf-generator/adjustFont'
|
|
21
|
+
import { createRequire } from 'module'
|
|
23
22
|
|
|
24
23
|
class TaskQueue {
|
|
25
24
|
constructor() {
|
|
@@ -42,6 +41,48 @@ let config
|
|
|
42
41
|
let checksumPaths = []
|
|
43
42
|
let checksumData = []
|
|
44
43
|
|
|
44
|
+
let msdfLoaded = false
|
|
45
|
+
let genFont, setGeneratePaths, adjustFont
|
|
46
|
+
async function loadMsdfModules() {
|
|
47
|
+
// do not try to load it repeatedly
|
|
48
|
+
if (msdfLoaded) return true
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// Create a require function that resolves from the app's working directory
|
|
52
|
+
// This ensures the msdf-generator is resolved from the app's node_modules
|
|
53
|
+
const userRequire = createRequire(process.cwd() + '/')
|
|
54
|
+
|
|
55
|
+
const msdfGeneratorPath = userRequire.resolve('@lightningjs/msdf-generator')
|
|
56
|
+
const msdfGeneratorUrl = new URL(`file:///${msdfGeneratorPath.replace(/\\/g, '/')}`).href
|
|
57
|
+
const msdfGenerator = await import(msdfGeneratorUrl)
|
|
58
|
+
genFont = msdfGenerator.genFont
|
|
59
|
+
setGeneratePaths = msdfGenerator.setGeneratePaths
|
|
60
|
+
|
|
61
|
+
const adjustFontPath = userRequire.resolve('@lightningjs/msdf-generator/adjustFont')
|
|
62
|
+
const adjustFontUrl = new URL(`file:///${adjustFontPath.replace(/\\/g, '/')}`).href
|
|
63
|
+
const adjustFontModule = await import(adjustFontUrl)
|
|
64
|
+
adjustFont = adjustFontModule.adjustFont
|
|
65
|
+
return true
|
|
66
|
+
} catch {
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function getMsdfReady() {
|
|
72
|
+
msdfLoaded = await loadMsdfModules()
|
|
73
|
+
|
|
74
|
+
if (!msdfLoaded) {
|
|
75
|
+
console.error('\n\x1b[31mError: @lightningjs/msdf-generator package is not installed.\x1b[0m')
|
|
76
|
+
console.error(
|
|
77
|
+
'This package is required for generating MSDF fonts during development and build.\n'
|
|
78
|
+
)
|
|
79
|
+
console.error('\nPlease install it as a dev dependency in your project:\n')
|
|
80
|
+
console.error(' \x1b[33mnpm install --save-dev @lightningjs/msdf-generator\x1b[0m\n')
|
|
81
|
+
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
45
86
|
export default function () {
|
|
46
87
|
let msdfOutputDir = ''
|
|
47
88
|
let buildOutputPath = ''
|
|
@@ -156,15 +197,20 @@ export default function () {
|
|
|
156
197
|
}
|
|
157
198
|
|
|
158
199
|
const generateSDF = async (inputFilePath, outputDirPath, configFilePath) => {
|
|
200
|
+
// plugin only required if there is a msdf conversion
|
|
201
|
+
// so it is better to check when generateSDF is called
|
|
202
|
+
await getMsdfReady()
|
|
203
|
+
|
|
159
204
|
// Ensure the destination directory exists
|
|
160
205
|
fs.mkdirSync(outputDirPath, { recursive: true })
|
|
161
|
-
|
|
162
206
|
setGeneratePaths(path.dirname(inputFilePath), outputDirPath, configFilePath)
|
|
163
207
|
|
|
164
208
|
let font = await genFont(path.basename(inputFilePath), 'msdf')
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
else
|
|
209
|
+
if (font) {
|
|
210
|
+
await adjustFont(font)
|
|
211
|
+
} else {
|
|
212
|
+
console.error('Failed to generate MSDF file')
|
|
213
|
+
}
|
|
168
214
|
}
|
|
169
215
|
|
|
170
216
|
// Finds all font files (.ttf, .otf, .woff) in a directory
|
package/vite/preCompiler.js
CHANGED
|
@@ -32,22 +32,12 @@ export default function () {
|
|
|
32
32
|
|
|
33
33
|
// we should only precompile .blits, .js and .ts files
|
|
34
34
|
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
fileExtension === '.mjs')
|
|
35
|
+
fileExtension === '.js' ||
|
|
36
|
+
fileExtension === '.ts' ||
|
|
37
|
+
fileExtension === '.blits' ||
|
|
38
|
+
fileExtension === '.mjs'
|
|
40
39
|
) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (typeof result === 'object') {
|
|
44
|
-
return {
|
|
45
|
-
code: result.code,
|
|
46
|
-
map: result.map,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// No transformation needed - return null so Vite knows no changes were made
|
|
50
|
-
return null
|
|
40
|
+
return compiler(source, filePath, config.mode)
|
|
51
41
|
}
|
|
52
42
|
|
|
53
43
|
// vite expects null if there is no modification
|
|
@@ -231,6 +231,117 @@
|
|
|
231
231
|
"RouterView"
|
|
232
232
|
]
|
|
233
233
|
},
|
|
234
|
+
"border": {
|
|
235
|
+
"attrType": "regular",
|
|
236
|
+
"types": [
|
|
237
|
+
"number",
|
|
238
|
+
{
|
|
239
|
+
"type": "object",
|
|
240
|
+
"properties": {
|
|
241
|
+
"width": {
|
|
242
|
+
"type": "number"
|
|
243
|
+
},
|
|
244
|
+
"top": {
|
|
245
|
+
"type": "number"
|
|
246
|
+
},
|
|
247
|
+
"right": {
|
|
248
|
+
"type": "number"
|
|
249
|
+
},
|
|
250
|
+
"bottom": {
|
|
251
|
+
"type": "number"
|
|
252
|
+
},
|
|
253
|
+
"left": {
|
|
254
|
+
"type": "number"
|
|
255
|
+
},
|
|
256
|
+
"color": {
|
|
257
|
+
"type": "string"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"defaultValue": "undefined",
|
|
263
|
+
"reactive": true,
|
|
264
|
+
"description": "Apply a border, default color is white.",
|
|
265
|
+
"usedIn": [
|
|
266
|
+
"Element"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
"rounded": {
|
|
270
|
+
"attrType": "regular",
|
|
271
|
+
"types": [
|
|
272
|
+
"number",
|
|
273
|
+
{
|
|
274
|
+
"type": "object",
|
|
275
|
+
"properties": {
|
|
276
|
+
"radius": {
|
|
277
|
+
"type": "number"
|
|
278
|
+
},
|
|
279
|
+
"top-left": {
|
|
280
|
+
"type": "number"
|
|
281
|
+
},
|
|
282
|
+
"top-right": {
|
|
283
|
+
"type": "number"
|
|
284
|
+
},
|
|
285
|
+
"bottom-right": {
|
|
286
|
+
"type": "number"
|
|
287
|
+
},
|
|
288
|
+
"bottom-left": {
|
|
289
|
+
"type": "number"
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
"defaultValue": "undefined",
|
|
295
|
+
"reactive": true,
|
|
296
|
+
"description": "Apply a to corners, or (a) specific corner(s)",
|
|
297
|
+
"usedIn": [
|
|
298
|
+
"Element"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
"shadow": {
|
|
302
|
+
"attrType": "regular",
|
|
303
|
+
"types": [
|
|
304
|
+
{
|
|
305
|
+
"type": "object",
|
|
306
|
+
"properties": {
|
|
307
|
+
"x": {
|
|
308
|
+
"type": "number"
|
|
309
|
+
},
|
|
310
|
+
"y": {
|
|
311
|
+
"type": "number"
|
|
312
|
+
},
|
|
313
|
+
"blur": {
|
|
314
|
+
"type": "number"
|
|
315
|
+
},
|
|
316
|
+
"spread": {
|
|
317
|
+
"type": "number"
|
|
318
|
+
},
|
|
319
|
+
"color": {
|
|
320
|
+
"type": "string"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"defaultValue": "undefined",
|
|
326
|
+
"reactive": true,
|
|
327
|
+
"description": "Apply a to corners, or (a) specific corner(s)",
|
|
328
|
+
"usedIn": [
|
|
329
|
+
"Element"
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
"shader": {
|
|
333
|
+
"attrType": "regular",
|
|
334
|
+
"types": [
|
|
335
|
+
"string",
|
|
336
|
+
"object"
|
|
337
|
+
],
|
|
338
|
+
"defaultValue": null,
|
|
339
|
+
"reactive": true,
|
|
340
|
+
"description": "Enable a specific shader to apply.",
|
|
341
|
+
"usedIn": [
|
|
342
|
+
"Element"
|
|
343
|
+
]
|
|
344
|
+
},
|
|
234
345
|
"clipping": {
|
|
235
346
|
"attrType": "regular",
|
|
236
347
|
"types": [
|
|
@@ -387,6 +498,7 @@
|
|
|
387
498
|
"values": [
|
|
388
499
|
"none",
|
|
389
500
|
"width",
|
|
501
|
+
"height",
|
|
390
502
|
"both"
|
|
391
503
|
],
|
|
392
504
|
"defaultValue": "none",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import type { AppStatePlugin } from '@lightningjs/blits'
|
|
19
|
-
|
|
20
|
-
// Re-export AppStatePlugin for direct imports
|
|
21
|
-
export type { AppStatePlugin }
|
|
22
|
-
|
|
23
|
-
declare const appState: {
|
|
24
|
-
readonly name: 'appState'
|
|
25
|
-
plugin: <TState extends Record<string, unknown>>(state?: TState) => AppStatePlugin<TState>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default appState
|
|
29
|
-
|
package/src/plugins/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export { default as language } from './language.js'
|
|
19
|
-
export { default as theme } from './theme.js'
|
|
20
|
-
export { default as appState } from './appstate.js'
|
|
21
|
-
export { default as storage } from './storage/storage.js'
|
|
22
|
-
|
|
23
|
-
// Re-export plugin interfaces for convenience
|
|
24
|
-
export type { LanguagePlugin, ThemePlugin, StoragePlugin, AppStatePlugin } from '@lightningjs/blits'
|
|
25
|
-
|
|
26
|
-
// Re-export option types
|
|
27
|
-
export type { LanguagePluginOptions } from './language.js'
|
|
28
|
-
export type { ThemePluginConfig } from './theme.js'
|
|
29
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import type { LanguagePlugin } from '@lightningjs/blits'
|
|
19
|
-
|
|
20
|
-
export interface LanguagePluginOptions {
|
|
21
|
-
file?: string
|
|
22
|
-
language?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Re-export LanguagePlugin for direct imports
|
|
26
|
-
export type { LanguagePlugin }
|
|
27
|
-
|
|
28
|
-
declare const language: {
|
|
29
|
-
readonly name: 'language'
|
|
30
|
-
plugin: (options?: LanguagePluginOptions) => LanguagePlugin
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default language
|
|
34
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import type { StoragePlugin } from '@lightningjs/blits'
|
|
19
|
-
|
|
20
|
-
// Re-export StoragePlugin for direct imports
|
|
21
|
-
export type { StoragePlugin }
|
|
22
|
-
|
|
23
|
-
declare const storage: {
|
|
24
|
-
readonly name: 'storage'
|
|
25
|
-
plugin: () => StoragePlugin
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default storage
|
|
29
|
-
|
package/src/plugins/theme.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import type { ThemePlugin } from '@lightningjs/blits'
|
|
19
|
-
|
|
20
|
-
export interface ThemePluginConfig {
|
|
21
|
-
themes?: Record<string, Record<string, unknown>>
|
|
22
|
-
current?: string
|
|
23
|
-
base?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Re-export ThemePlugin for direct imports
|
|
27
|
-
export type { ThemePlugin }
|
|
28
|
-
|
|
29
|
-
declare const theme: {
|
|
30
|
-
readonly name: 'theme'
|
|
31
|
-
plugin: (config?: ThemePluginConfig | Record<string, unknown>) => ThemePlugin
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default theme
|
|
35
|
-
|