@solidtv/renderer 1.0.4 → 1.0.6
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/dist/src/core/CoreNode.d.ts +34 -1
- package/dist/src/core/CoreNode.js +48 -56
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +2 -0
- package/dist/src/core/CoreTextNode.js +35 -18
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.js +0 -1
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.js +3 -0
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/TextureMemoryManager.d.ts +0 -13
- package/dist/src/core/TextureMemoryManager.js +0 -24
- package/dist/src/core/TextureMemoryManager.js.map +1 -1
- package/dist/src/core/animations/AnimationManager.d.ts +1 -0
- package/dist/src/core/animations/AnimationManager.js.map +1 -1
- package/dist/src/core/animations/CoreAnimation.d.ts +1 -0
- package/dist/src/core/animations/CoreAnimation.js +1 -0
- package/dist/src/core/animations/CoreAnimation.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +4 -6
- package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasTextRenderer.js +12 -1
- package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/SdfFontHandler.js +5 -4
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/SdfTextRenderer.js +16 -6
- package/dist/src/core/text-rendering/SdfTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/TextRenderer.d.ts +0 -31
- package/dist/src/main-api/Inspector.js +78 -5
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.js +4 -2
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/core/CoreNode.test.ts +47 -46
- package/src/core/CoreNode.ts +86 -55
- package/src/core/CoreTextNode.ts +38 -23
- package/src/core/CoreTextureManager.ts +0 -2
- package/src/core/Stage.ts +3 -0
- package/src/core/TextureMemoryManager.ts +0 -27
- package/src/core/animations/AnimationManager.ts +1 -0
- package/src/core/animations/CoreAnimation.ts +2 -1
- package/src/core/renderers/webgl/WebGlRenderer.ts +4 -6
- package/src/core/text-rendering/CanvasTextRenderer.ts +14 -1
- package/src/core/text-rendering/SdfFontHandler.ts +6 -5
- package/src/core/text-rendering/SdfTextRenderer.ts +19 -6
- package/src/core/text-rendering/TextRenderer.ts +0 -31
- package/src/main-api/Inspector.ts +87 -5
- package/src/main-api/Renderer.ts +4 -2
|
@@ -230,8 +230,59 @@ const knownProperties = new Set<string>([
|
|
|
230
230
|
'parent',
|
|
231
231
|
'data',
|
|
232
232
|
'text',
|
|
233
|
+
'componentName',
|
|
234
|
+
'componentLocation',
|
|
233
235
|
]);
|
|
234
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Convert a PascalCase or camelCase component name to a valid custom-element
|
|
239
|
+
* tag name by inserting hyphens before uppercase letters and lower-casing.
|
|
240
|
+
* A mandatory "x-" prefix is added so the name always contains a hyphen,
|
|
241
|
+
* which is required by the Custom Elements spec.
|
|
242
|
+
*
|
|
243
|
+
* Examples:
|
|
244
|
+
* "MyButton" → "x-my-button"
|
|
245
|
+
* "FocusRing" → "x-focus-ring"
|
|
246
|
+
* "view" → "x-view"
|
|
247
|
+
*/
|
|
248
|
+
function toCustomElementTag(componentName: string): string {
|
|
249
|
+
const kebab = componentName
|
|
250
|
+
.replace(/([A-Z])/g, '-$1')
|
|
251
|
+
.toLowerCase()
|
|
252
|
+
.replace(/^-/, ''); // strip leading hyphen if name starts with uppercase
|
|
253
|
+
return `${kebab}-x`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Registry of custom element tag names that have already been defined so we
|
|
258
|
+
* only call customElements.define() once per unique component name.
|
|
259
|
+
*/
|
|
260
|
+
const registeredCustomElements = new Set<string>();
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Ensure a minimal custom element class is registered for the given tag name.
|
|
264
|
+
* The element extends HTMLElement with no additional behaviour; its only
|
|
265
|
+
* purpose is to make Chrome DevTools show the component name in the Elements
|
|
266
|
+
* panel.
|
|
267
|
+
*/
|
|
268
|
+
function ensureCustomElement(tagName: string): void {
|
|
269
|
+
if (registeredCustomElements.has(tagName)) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
registeredCustomElements.add(tagName);
|
|
273
|
+
|
|
274
|
+
// Guard: skip if already defined (e.g. by another module) or if the
|
|
275
|
+
// Custom Elements API is unavailable (SSR / test environments).
|
|
276
|
+
if (
|
|
277
|
+
typeof customElements === 'undefined' ||
|
|
278
|
+
customElements.get(tagName) !== undefined
|
|
279
|
+
) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
customElements.define(tagName, class extends HTMLElement {});
|
|
284
|
+
}
|
|
285
|
+
|
|
235
286
|
export class Inspector {
|
|
236
287
|
private root: HTMLElement | null = null;
|
|
237
288
|
private canvas: HTMLCanvasElement | null = null;
|
|
@@ -732,14 +783,29 @@ export class Inspector {
|
|
|
732
783
|
id: number,
|
|
733
784
|
properties: CoreNodeProps | CoreTextNodeProps,
|
|
734
785
|
): HTMLElement {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
786
|
+
// Use a custom element tag when the node carries a componentName so that
|
|
787
|
+
// Chrome DevTools' Elements panel shows the framework component name
|
|
788
|
+
// instead of a generic <div>.
|
|
789
|
+
const componentName = (properties as CoreNodeProps).componentName;
|
|
790
|
+
let el: HTMLElement;
|
|
791
|
+
|
|
792
|
+
if (componentName) {
|
|
793
|
+
const tagName = toCustomElementTag(componentName);
|
|
794
|
+
ensureCustomElement(tagName);
|
|
795
|
+
el = document.createElement(tagName);
|
|
796
|
+
// Store the original PascalCase name as a readable attribute.
|
|
797
|
+
// el.setAttribute('data-component', componentName);
|
|
798
|
+
} else {
|
|
799
|
+
el = document.createElement('div');
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
el.style.position = 'absolute';
|
|
803
|
+
el.id = id.toString();
|
|
738
804
|
|
|
739
805
|
// set initial properties
|
|
740
806
|
for (const key in properties) {
|
|
741
807
|
this.updateNodeProperty(
|
|
742
|
-
|
|
808
|
+
el,
|
|
743
809
|
// really typescript? really?
|
|
744
810
|
key as keyof CoreNodeProps,
|
|
745
811
|
properties[key as keyof CoreNodeProps],
|
|
@@ -747,7 +813,7 @@ export class Inspector {
|
|
|
747
813
|
);
|
|
748
814
|
}
|
|
749
815
|
|
|
750
|
-
return
|
|
816
|
+
return el;
|
|
751
817
|
}
|
|
752
818
|
|
|
753
819
|
createNodes(node: CoreNode): boolean {
|
|
@@ -1205,6 +1271,22 @@ export class Inspector {
|
|
|
1205
1271
|
}
|
|
1206
1272
|
return;
|
|
1207
1273
|
}
|
|
1274
|
+
|
|
1275
|
+
// Component metadata – handled when the element is created in createDiv;
|
|
1276
|
+
// re-applied here to support dynamic updates (rare but possible).
|
|
1277
|
+
if (property === 'componentName' && value) {
|
|
1278
|
+
const tagName = toCustomElementTag(String(value));
|
|
1279
|
+
ensureCustomElement(tagName);
|
|
1280
|
+
// div.setAttribute('data-component', String(value));
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
if (property === 'componentLocation' && value) {
|
|
1285
|
+
// Expose the source path so Chrome DevTools extensions and VS Code's
|
|
1286
|
+
// browser debugger can offer "open in editor" functionality.
|
|
1287
|
+
// div.setAttribute('data-location', String(value));
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1208
1290
|
}
|
|
1209
1291
|
|
|
1210
1292
|
updateViewport(
|
package/src/main-api/Renderer.ts
CHANGED
|
@@ -957,8 +957,10 @@ export class RendererMain extends EventEmitter {
|
|
|
957
957
|
this.canvas.width = deviceLogicalWidth * devicePhysicalPixelRatio;
|
|
958
958
|
this.canvas.height = deviceLogicalHeight * devicePhysicalPixelRatio;
|
|
959
959
|
|
|
960
|
-
this.canvas.style
|
|
961
|
-
|
|
960
|
+
if (this.canvas.style) {
|
|
961
|
+
this.canvas.style.width = `${deviceLogicalWidth}px`;
|
|
962
|
+
this.canvas.style.height = `${deviceLogicalHeight}px`;
|
|
963
|
+
}
|
|
962
964
|
|
|
963
965
|
this.stage.renderer.updateViewport();
|
|
964
966
|
|