From 12f145d889d635e32ef5fa7c9b0b63d898cb0ba1 Mon Sep 17 00:00:00 2001 From: electrovir Date: Sat, 21 Oct 2023 17:24:51 +0000 Subject: [PATCH] add loadWait to NftFrameConfig for configurable loading time input --- package-lock.json | 12 ++++++------ package.json | 2 +- packages/demo/package.json | 2 +- packages/scripts/package.json | 2 +- packages/tests/package.json | 2 +- packages/tests/src/test-cases.ts | 2 -- packages/toniq-nft-frame/package.json | 2 +- packages/toniq-nft-frame/src/iframe/iframe-html.ts | 3 +-- packages/toniq-nft-frame/src/nft-frame-config.ts | 2 ++ 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1acad3b..09c4f68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@toniq-labs/toniq-nft-frame-mono-repo-root", - "version": "1.0.10", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@toniq-labs/toniq-nft-frame-mono-repo-root", - "version": "1.0.10", + "version": "1.1.0", "license": "MIT", "workspaces": [ "packages/*" @@ -15447,7 +15447,7 @@ }, "packages/demo": { "name": "@toniq-labs/toniq-nft-frame-demo", - "version": "1.0.10", + "version": "1.1.0", "license": "MIT", "dependencies": { "@augment-vir/browser": "^21.3.6", @@ -15489,7 +15489,7 @@ }, "packages/scripts": { "name": "@toniq-labs/toniq-nft-frame-scripts", - "version": "1.0.10", + "version": "1.1.0", "dependencies": { "@augment-vir/common": "^21.3.6", "@augment-vir/node-js": "^21.3.6" @@ -15532,7 +15532,7 @@ }, "packages/tests": { "name": "@toniq-labs/toniq-nft-frame-tests", - "version": "1.0.10", + "version": "1.1.0", "license": "MIT", "dependencies": { "@augment-vir/common": "^21.3.6", @@ -15581,7 +15581,7 @@ }, "packages/toniq-nft-frame": { "name": "@toniq-labs/toniq-nft-frame", - "version": "1.0.10", + "version": "1.1.0", "license": "MIT", "dependencies": { "@augment-vir/browser": "^21.3.6", diff --git a/package.json b/package.json index 41e1313..bef1899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/toniq-nft-frame-mono-repo-root", - "version": "1.0.10", + "version": "1.1.0", "private": true, "license": "MIT", "author": { diff --git a/packages/demo/package.json b/packages/demo/package.json index d953a8a..429a105 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/toniq-nft-frame-demo", - "version": "1.0.10", + "version": "1.1.0", "private": true, "license": "MIT", "author": { diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 7f11bcd..7dce587 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/toniq-nft-frame-scripts", - "version": "1.0.10", + "version": "1.1.0", "private": true, "scripts": { "compile": "virmator compile && npm run execute", diff --git a/packages/tests/package.json b/packages/tests/package.json index dce48d1..3ce4675 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/toniq-nft-frame-tests", - "version": "1.0.10", + "version": "1.1.0", "private": true, "license": "MIT", "author": { diff --git a/packages/tests/src/test-cases.ts b/packages/tests/src/test-cases.ts index 833f302..94ba5cd 100644 --- a/packages/tests/src/test-cases.ts +++ b/packages/tests/src/test-cases.ts @@ -61,13 +61,11 @@ export const testCases: ReadonlyArray = rawTestCases .map((rawTestCase) => { return [ { - ...rawTestCase, ...mediumSize, nftUrl: joinUrlParts(nftURlBase || testIframeUrl, rawTestCase.nftId), childFrameUrl: testIframeUrl, }, { - ...rawTestCase, ...largeSize, nftUrl: joinUrlParts(nftURlBase || testIframeUrl, rawTestCase.nftId), childFrameUrl: testIframeUrl, diff --git a/packages/toniq-nft-frame/package.json b/packages/toniq-nft-frame/package.json index a4baa2f..276b530 100644 --- a/packages/toniq-nft-frame/package.json +++ b/packages/toniq-nft-frame/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/toniq-nft-frame", - "version": "1.0.10", + "version": "1.1.0", "homepage": "https://github.com/Toniq-Labs/nft-frame", "bugs": { "url": "https://github.com/Toniq-Labs/nft-frame/issues" diff --git a/packages/toniq-nft-frame/src/iframe/iframe-html.ts b/packages/toniq-nft-frame/src/iframe/iframe-html.ts index e3dcd01..7a4b9c0 100644 --- a/packages/toniq-nft-frame/src/iframe/iframe-html.ts +++ b/packages/toniq-nft-frame/src/iframe/iframe-html.ts @@ -1,4 +1,3 @@ -import {waitForAnimationFrame} from '@augment-vir/browser'; import {awaitedForEach, isTruthy, wait} from '@augment-vir/common'; import {convertTemplateToString, html} from 'element-vir'; import {NftConfigForChildIframe} from '../nft-frame-config'; @@ -216,7 +215,7 @@ export async function setTemplateHtml( } } - await waitForAnimationFrame(10); + await wait(nftConfig.loadWait?.milliseconds ?? 500); return htmlElement; } diff --git a/packages/toniq-nft-frame/src/nft-frame-config.ts b/packages/toniq-nft-frame/src/nft-frame-config.ts index bb0377e..0547012 100644 --- a/packages/toniq-nft-frame/src/nft-frame-config.ts +++ b/packages/toniq-nft-frame/src/nft-frame-config.ts @@ -14,6 +14,8 @@ const nftConfigConst = { max: undefined as Dimensions | undefined, /** The min NFT size constraints which the NFT will be resized to fit within. */ min: undefined as Dimensions | undefined, + /** How long to wait for the nft to load before calculating size. Defaults to 500 milliseconds. */ + loadWait: undefined as {milliseconds: number} | undefined, /** For hard-coding the final NFT size. Setting this can cause distortions. */ forcedFinalNftSize: undefined as Dimensions | undefined, /**