@combos-fun/engine 0.1.21 → 0.1.23
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/engine.cjs.js +70 -12
- package/dist/engine.cjs.js.map +1 -1
- package/dist/engine.cjs.prod.js +1 -1
- package/dist/engine.d.ts +39 -8
- package/dist/engine.esm.js +69 -13
- package/dist/engine.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/engine.cjs.js
CHANGED
|
@@ -891,11 +891,12 @@ class Scene extends GameObject {
|
|
|
891
891
|
}
|
|
892
892
|
|
|
893
893
|
/** Generated at build from package.json */
|
|
894
|
-
const version = "0.1.
|
|
894
|
+
const version = "0.1.23";
|
|
895
895
|
|
|
896
896
|
/**
|
|
897
|
-
* Sent
|
|
898
|
-
*
|
|
897
|
+
* Sent after each `System.init` completes during `Game.addSystem`.
|
|
898
|
+
* An iframe posts to `window.parent`. A top-level page hands the same payload
|
|
899
|
+
* to the native runtime bridge as a string.
|
|
899
900
|
*/
|
|
900
901
|
const COMBOS_GAME_PLUGIN_INIT_SUCCESS = "combos-game:plugin-init-success";
|
|
901
902
|
/**
|
|
@@ -934,13 +935,28 @@ function setParentNotifyTargetOrigin(targetOrigin) {
|
|
|
934
935
|
function postToParent(payload, targetOrigin) {
|
|
935
936
|
if (typeof window === "undefined")
|
|
936
937
|
return;
|
|
937
|
-
|
|
938
|
+
const parent = window.parent;
|
|
939
|
+
if (parent && parent !== window) {
|
|
940
|
+
try {
|
|
941
|
+
parent.postMessage(payload, targetOrigin);
|
|
942
|
+
}
|
|
943
|
+
catch {
|
|
944
|
+
/* ignore cross-origin or detached frame */
|
|
945
|
+
}
|
|
938
946
|
return;
|
|
947
|
+
}
|
|
939
948
|
try {
|
|
940
|
-
|
|
949
|
+
const body = JSON.stringify(payload);
|
|
950
|
+
const host = window;
|
|
951
|
+
const bridge = host.CombosRuntimeBridge;
|
|
952
|
+
if (typeof bridge?.postMessage === "function") {
|
|
953
|
+
bridge.postMessage(body);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
host.webkit?.messageHandlers?.combosRuntime?.postMessage(body);
|
|
941
957
|
}
|
|
942
958
|
catch {
|
|
943
|
-
/*
|
|
959
|
+
/* no native bridge */
|
|
944
960
|
}
|
|
945
961
|
}
|
|
946
962
|
/**
|
|
@@ -2442,25 +2458,25 @@ const ADAPTIVE_SLOW_FRAME_COUNT = 30;
|
|
|
2442
2458
|
const ADAPTIVE_FAST_FRAME_COUNT = 120;
|
|
2443
2459
|
const ADAPTIVE_STEP = 0.5;
|
|
2444
2460
|
const MIN_PIXEL_RATIO = 1;
|
|
2445
|
-
function isPositive(value) {
|
|
2461
|
+
function isPositive$1(value) {
|
|
2446
2462
|
return typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
2447
2463
|
}
|
|
2448
2464
|
function roundToHalf(value) {
|
|
2449
2465
|
return Math.round(value * 2) / 2;
|
|
2450
2466
|
}
|
|
2451
2467
|
function readDevicePixelRatio(devicePixelRatio) {
|
|
2452
|
-
if (isPositive(devicePixelRatio))
|
|
2468
|
+
if (isPositive$1(devicePixelRatio))
|
|
2453
2469
|
return devicePixelRatio;
|
|
2454
|
-
if (typeof window !== 'undefined' && isPositive(window.devicePixelRatio)) {
|
|
2470
|
+
if (typeof window !== 'undefined' && isPositive$1(window.devicePixelRatio)) {
|
|
2455
2471
|
return window.devicePixelRatio;
|
|
2456
2472
|
}
|
|
2457
2473
|
return 1;
|
|
2458
2474
|
}
|
|
2459
2475
|
function resolveRenderQuality(input = {}, defaults = {}) {
|
|
2460
|
-
const maxPixelRatio = isPositive(input.maxPixelRatio) ? input.maxPixelRatio : DEFAULT_MAX_PIXEL_RATIO;
|
|
2461
|
-
const explicit = isPositive(input.resolution)
|
|
2476
|
+
const maxPixelRatio = isPositive$1(input.maxPixelRatio) ? input.maxPixelRatio : DEFAULT_MAX_PIXEL_RATIO;
|
|
2477
|
+
const explicit = isPositive$1(input.resolution)
|
|
2462
2478
|
? input.resolution
|
|
2463
|
-
: isPositive(input.pixelRatio)
|
|
2479
|
+
: isPositive$1(input.pixelRatio)
|
|
2464
2480
|
? input.pixelRatio
|
|
2465
2481
|
: undefined;
|
|
2466
2482
|
const devicePixelRatio = readDevicePixelRatio(input.devicePixelRatio ?? defaults.devicePixelRatio);
|
|
@@ -2535,6 +2551,46 @@ class AdaptivePixelRatio {
|
|
|
2535
2551
|
}
|
|
2536
2552
|
}
|
|
2537
2553
|
|
|
2554
|
+
function isPositive(value) {
|
|
2555
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
2556
|
+
}
|
|
2557
|
+
/** Backing store for the canvas box, using the caller-supplied pixel ratio. */
|
|
2558
|
+
function displayBufferSize(box, resolution) {
|
|
2559
|
+
if (!isPositive(box.width) || !isPositive(box.height) || !isPositive(resolution))
|
|
2560
|
+
return null;
|
|
2561
|
+
if (box.width < 1 || box.height < 1)
|
|
2562
|
+
return null;
|
|
2563
|
+
const bufferWidth = Math.round(box.width * resolution);
|
|
2564
|
+
const bufferHeight = Math.round(box.height * resolution);
|
|
2565
|
+
if (bufferWidth < 1 || bufferHeight < 1)
|
|
2566
|
+
return null;
|
|
2567
|
+
return { bufferWidth, bufferHeight };
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Unity orthographic camera: vertical extent stays `height`, the view stays
|
|
2571
|
+
* centered on `(width / 2, height / 2)`, and the horizontal extent follows the
|
|
2572
|
+
* backing-store aspect.
|
|
2573
|
+
*/
|
|
2574
|
+
function fitOrthographicDisplay(input) {
|
|
2575
|
+
if (!isPositive(input.width) || !isPositive(input.height))
|
|
2576
|
+
return null;
|
|
2577
|
+
const buffer = displayBufferSize(input.box, input.resolution);
|
|
2578
|
+
if (!buffer)
|
|
2579
|
+
return null;
|
|
2580
|
+
const visibleHeight = input.height;
|
|
2581
|
+
const pixelRatio = buffer.bufferHeight / visibleHeight;
|
|
2582
|
+
const visibleWidth = buffer.bufferWidth / pixelRatio;
|
|
2583
|
+
return {
|
|
2584
|
+
bufferWidth: buffer.bufferWidth,
|
|
2585
|
+
bufferHeight: buffer.bufferHeight,
|
|
2586
|
+
visibleWidth,
|
|
2587
|
+
visibleHeight,
|
|
2588
|
+
pixelRatio,
|
|
2589
|
+
originX: input.width / 2 - visibleWidth / 2,
|
|
2590
|
+
originY: 0,
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2538
2594
|
/** Decorators util */
|
|
2539
2595
|
const decorators = {
|
|
2540
2596
|
IDEProp,
|
|
@@ -2561,6 +2617,8 @@ exports.applyCompressedImagePreference = applyCompressedImagePreference;
|
|
|
2561
2617
|
exports.componentObserver = componentObserver;
|
|
2562
2618
|
exports.compressedTextureUrl = compressedTextureUrl;
|
|
2563
2619
|
exports.decorators = decorators;
|
|
2620
|
+
exports.displayBufferSize = displayBufferSize;
|
|
2621
|
+
exports.fitOrthographicDisplay = fitOrthographicDisplay;
|
|
2564
2622
|
exports.gpuSupportsCompressedTexture = gpuSupportsCompressedTexture;
|
|
2565
2623
|
exports.imageFallbackUrl = imageFallbackUrl;
|
|
2566
2624
|
exports.isAllowedMessageOrigin = isAllowedMessageOrigin;
|