@novely/solid-renderer 0.44.2 → 0.45.0-experemental
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/index.jsx +22 -44
- package/dist/styles/index.css +5 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.jsx
CHANGED
|
@@ -3131,7 +3131,7 @@ var clickOutside = (node, handler) => {
|
|
|
3131
3131
|
|
|
3132
3132
|
// src/components/Character.tsx
|
|
3133
3133
|
var Character = (props) => {
|
|
3134
|
-
return props.characters[props.character].
|
|
3134
|
+
return props.characters[props.character].element;
|
|
3135
3135
|
};
|
|
3136
3136
|
|
|
3137
3137
|
// src/components/Icon.tsx
|
|
@@ -5313,7 +5313,6 @@ var createEmitter = () => {
|
|
|
5313
5313
|
};
|
|
5314
5314
|
|
|
5315
5315
|
// src/renderer.tsx
|
|
5316
|
-
var _tmpl$20 = /* @__PURE__ */ template(`<canvas>`);
|
|
5317
5316
|
var {
|
|
5318
5317
|
preloadAudioBlocking
|
|
5319
5318
|
} = createAudioMisc();
|
|
@@ -5371,47 +5370,26 @@ var createSolidRenderer = ({
|
|
|
5371
5370
|
if (chars[character]) {
|
|
5372
5371
|
return chars[character];
|
|
5373
5372
|
}
|
|
5374
|
-
const
|
|
5375
|
-
|
|
5376
|
-
setAttribute(_el$, "data-character", character);
|
|
5377
|
-
return _el$;
|
|
5378
|
-
})();
|
|
5379
|
-
const canvasContext = canvas.getContext("2d");
|
|
5373
|
+
const element = document.createElement("div");
|
|
5374
|
+
element.setAttribute("data-character", character);
|
|
5380
5375
|
const characterHandle = {
|
|
5381
|
-
|
|
5376
|
+
element,
|
|
5382
5377
|
emotions: {},
|
|
5383
5378
|
emotion(emotion, shouldRender) {
|
|
5384
5379
|
let stored = this.emotions[emotion];
|
|
5385
5380
|
if (!stored) {
|
|
5386
5381
|
stored = this.emotions[emotion] = options.getCharacterAssets(character, emotion).map((src) => imagePreloadWithCachingNotComplete(src));
|
|
5387
5382
|
}
|
|
5383
|
+
const images = stored.map((image) => `url("${image.src}")`).reverse();
|
|
5384
|
+
characterAssetSizes;
|
|
5388
5385
|
if (shouldRender && stored) {
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
const {
|
|
5397
|
-
clientWidth: contextClientWidth,
|
|
5398
|
-
clientHeight: contextClientHeight
|
|
5399
|
-
} = context.root;
|
|
5400
|
-
const widthFactor = mainClientWidth / contextClientWidth;
|
|
5401
|
-
const heightFactor = mainClientHeight / contextClientHeight;
|
|
5402
|
-
const maxFactor = Math.ceil(Math.max(widthFactor, heightFactor));
|
|
5403
|
-
canvas.dataset.scaleBy = (1 / maxFactor).toFixed(3);
|
|
5404
|
-
} else {
|
|
5405
|
-
canvas.dataset.scalyBy = "1";
|
|
5406
|
-
}
|
|
5407
|
-
const sizes = characterAssetSizes[character];
|
|
5408
|
-
if (sizes) {
|
|
5409
|
-
const scaleBy = canvas.dataset.scaleBy ? Number(canvas.dataset.scaleBy) : 1;
|
|
5410
|
-
canvas.width = Math.min(sizes.width * scaleBy * 2, sizes.width) * devicePixelRatio;
|
|
5411
|
-
canvas.height = Math.min(sizes.height * scaleBy * 2, sizes.height) * devicePixelRatio;
|
|
5412
|
-
canvas.dataset.resized = "true";
|
|
5413
|
-
}
|
|
5414
|
-
canvasDrawImages(canvas, canvasContext, stored);
|
|
5386
|
+
Promise.allSettled(stored.map((image) => imageLoaded(image))).then(() => {
|
|
5387
|
+
const sizesSorted = stored.slice().sort((a, b) => b.width - a.width);
|
|
5388
|
+
const sizes = sizesSorted[0];
|
|
5389
|
+
element.style.setProperty("width", sizes.naturalWidth + "px");
|
|
5390
|
+
element.style.setProperty("height", sizes.naturalHeight + "px");
|
|
5391
|
+
element.style.setProperty("--background-image", images.join(", "));
|
|
5392
|
+
});
|
|
5415
5393
|
}
|
|
5416
5394
|
},
|
|
5417
5395
|
append(className2, style3) {
|
|
@@ -5421,12 +5399,12 @@ var createSolidRenderer = ({
|
|
|
5421
5399
|
visible: true
|
|
5422
5400
|
});
|
|
5423
5401
|
const {
|
|
5424
|
-
|
|
5402
|
+
element: element2
|
|
5425
5403
|
} = chars[character];
|
|
5426
|
-
|
|
5404
|
+
element2.className = "";
|
|
5427
5405
|
if (className2) {
|
|
5428
|
-
void
|
|
5429
|
-
|
|
5406
|
+
void element2.offsetHeight;
|
|
5407
|
+
element2.className = className2;
|
|
5430
5408
|
}
|
|
5431
5409
|
},
|
|
5432
5410
|
remove(className2, style3, duration, restoring) {
|
|
@@ -5449,7 +5427,7 @@ var createSolidRenderer = ({
|
|
|
5449
5427
|
resolve();
|
|
5450
5428
|
}, duration);
|
|
5451
5429
|
if (className2) {
|
|
5452
|
-
chars[character].
|
|
5430
|
+
chars[character].element.className = className2;
|
|
5453
5431
|
}
|
|
5454
5432
|
$contextState.mutate((s) => s.characters[character], (prev) => {
|
|
5455
5433
|
return {
|
|
@@ -5461,12 +5439,12 @@ var createSolidRenderer = ({
|
|
|
5461
5439
|
});
|
|
5462
5440
|
},
|
|
5463
5441
|
animate(classes) {
|
|
5464
|
-
const classNames = classes.filter((className2) => !
|
|
5465
|
-
|
|
5442
|
+
const classNames = classes.filter((className2) => !element.classList.contains(className2));
|
|
5443
|
+
element.classList.add(...classNames);
|
|
5466
5444
|
const onAnimationEnd = () => {
|
|
5467
|
-
|
|
5445
|
+
element.classList.remove(...classNames);
|
|
5468
5446
|
};
|
|
5469
|
-
|
|
5447
|
+
element.addEventListener("animationend", onAnimationEnd, {
|
|
5470
5448
|
once: true
|
|
5471
5449
|
});
|
|
5472
5450
|
}
|
package/dist/styles/index.css
CHANGED
|
@@ -88,10 +88,14 @@
|
|
|
88
88
|
position: fixed;
|
|
89
89
|
overflow: hidden;
|
|
90
90
|
}
|
|
91
|
-
.characters >
|
|
91
|
+
.characters > div {
|
|
92
|
+
background-image: var(--background-image);
|
|
92
93
|
min-width: unset;
|
|
93
94
|
max-height: 85%;
|
|
94
95
|
max-width: calc(100% / max(2, var(--shown-characters-count)));
|
|
96
|
+
background-position: bottom;
|
|
97
|
+
background-repeat: no-repeat;
|
|
98
|
+
background-size: contain;
|
|
95
99
|
position: relative;
|
|
96
100
|
}
|
|
97
101
|
@media (max-aspect-ratio: .26) {
|
package/dist/types.d.ts
CHANGED