@lightningjs/blits 1.48.0 → 2.0.0-beta.2
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/element-test-full.txt +0 -0
- package/index.d.ts +19 -48
- package/package.json +4 -3
- 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 +26 -17
- package/src/components/Circle.js +49 -7
- package/src/components/FPScounter.js +226 -88
- package/src/components/RouterView.js +57 -6
- package/src/components/Sprite.js +54 -8
- 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 +116 -15
- package/src/lib/colors/colors.js +0 -1
- package/src/lib/lifecycle.js +4 -4
- package/src/lib/shaders/shaders.js +164 -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 +9 -9
- package/test-output.txt +0 -0
- package/vite/blitsTips.js +57 -0
- package/vite/msdfGenerator.js +52 -6
- package/vscode/data/template-attributes.json +112 -0
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
|
|
@@ -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",
|