From 5e3fcb7f13415e451f933d8ef49bd41d1564072d Mon Sep 17 00:00:00 2001 From: Acbox liu <850625057@qq.com> Date: Sat, 17 Aug 2024 14:23:25 +0800 Subject: [PATCH] release: v2.0.0-beta.14 --- examples/scene1.ts | 49 ++++++++++++++++++++-------- mods/mod-geometry/package.json | 2 +- mods/mod-layout/package.json | 2 +- mods/mod-markdown/package.json | 2 +- mods/mod-math/package.json | 2 +- mods/mod-skottie/package.json | 2 +- packages/basic/package.json | 2 +- packages/core/package.json | 2 +- packages/json/package.json | 2 +- packages/json/src/import-widget.ts | 23 ++++++------- packages/newcar/package.json | 2 +- packages/recorder/package.json | 2 +- packages/utils/package.json | 2 +- plugins/plugin-debug/package.json | 2 +- plugins/plugin-timeview/package.json | 2 +- pnpm-lock.yaml | 31 ++++-------------- 16 files changed, 67 insertions(+), 62 deletions(-) diff --git a/examples/scene1.ts b/examples/scene1.ts index 4ea34588f..033776fb8 100644 --- a/examples/scene1.ts +++ b/examples/scene1.ts @@ -7,28 +7,47 @@ import * as mt from '@newcar/mod-math' await useFont('./default.ttf') -export default importScene( +const scene = importScene( - `{ + ` + { "root": { "type": "Widget", + "arguments": [], "children": [ { - "type": "MathFunction", - "arguments": [ - "fn((x) => Math.sin(x))", - [-3.14, 3.14] - ], + "type": "Rect", + "arguments": [400, 400], "options": { "style": { - "color": [255, 0, 0, 1] + "border": true, + "fill": false, + "borderColor": [255, 255, 255, 1] }, - "lineWidth": 2, - "divisionY": 200, - "divisionX": 400, - "x": 100, - "y": 200 + "x": 300, + "y": 150 } + }, + { + "type": "Circle", + "arguments": [10], + "options": { + "style": { + "fill": true, + "fillColor": [255, 255, 255, 1] + }, + "x": 300, + "y": 150 + }, + "animations": [ + { + "type": "move", + "parameters": { + "duration": 1, + "to": [400, 400] + } + } + ] } ] } @@ -38,6 +57,10 @@ export default importScene( nc as any, nc as any, ) + +console.log(scene) + +export default scene // // export default createScene( // new Circle(100, { diff --git a/mods/mod-geometry/package.json b/mods/mod-geometry/package.json index 29f93337c..1250c7ca6 100644 --- a/mods/mod-geometry/package.json +++ b/mods/mod-geometry/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/mod-geometry", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/mods/mod-layout/package.json b/mods/mod-layout/package.json index 3aa24250e..687efa45c 100644 --- a/mods/mod-layout/package.json +++ b/mods/mod-layout/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/mod-layout", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/mods/mod-markdown/package.json b/mods/mod-markdown/package.json index 9ff960bcf..553a21876 100644 --- a/mods/mod-markdown/package.json +++ b/mods/mod-markdown/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/mod-markdown", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/mods/mod-math/package.json b/mods/mod-math/package.json index 0f9f7df90..3e40cbc81 100644 --- a/mods/mod-math/package.json +++ b/mods/mod-math/package.json @@ -1,7 +1,7 @@ { "name": "@newcar/mod-math", "type": "module", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/mods/mod-skottie/package.json b/mods/mod-skottie/package.json index 218c9daa9..a9331e456 100644 --- a/mods/mod-skottie/package.json +++ b/mods/mod-skottie/package.json @@ -1,7 +1,7 @@ { "name": "@newcar/mod-skottie", "type": "module", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/basic/package.json b/packages/basic/package.json index 3a639e64b..5abac78dc 100644 --- a/packages/basic/package.json +++ b/packages/basic/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/basic", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "The basic objects, animations and interpolators of newcar.", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/core/package.json b/packages/core/package.json index 711bb833f..acb7e74ac 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@newcar/core", "type": "module", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "The core of newcar.", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/json/package.json b/packages/json/package.json index 9a8c15daf..3a9e2a723 100644 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -1,7 +1,7 @@ { "name": "@newcar/json", "type": "module", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "The core of newcar.", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/json/src/import-widget.ts b/packages/json/src/import-widget.ts index f72830300..5071b2bcb 100644 --- a/packages/json/src/import-widget.ts +++ b/packages/json/src/import-widget.ts @@ -16,9 +16,12 @@ export function processItem( return importWidget(item as WidgetFormat, widgets, anims, easingFunctions) } } - if (Array.isArray(item)) { + if (Array.isArray(item) && item.length === 4) { return Color.rgba(item[0], item[1], item[2], item[3] ?? 1) } + else if (!isString(item)) { + return item + } else if (isString(item as string) && /color\(.+\)/.test(item as string)) { return Color.parse((item as string).replace(/color\(/, '').replace(/\)$/, '')) } @@ -39,9 +42,6 @@ export function processItem( // eslint-disable-next-line no-new-func return Function(`return ${(item as string).replace(/calc\(/, '').replace(/\)$/, '')}`)() } - else { - return item - } } export function processOptions( @@ -88,12 +88,7 @@ export function importWidget( widgetData = JSON.parse(widgetData) as WidgetFormat } const widget = new widgets[widgetData.type](...processArguments(widgetData.arguments ?? [], widgets, anims, easingFunctions), processOptions(widgetData.options, widgets, anims, easingFunctions)) - if (widgetData.children) { - widget.add(...widgetData.children.map((child) => { - return importWidget(child, widgets, anims, easingFunctions) - })) - } - if (widgetData.animations) { + if (Array.isArray(widgetData.animations)) { widgetData.animations.forEach((animation) => { if (Array.isArray(animation)) { widget.animate( @@ -114,7 +109,7 @@ export function importWidget( ) } else { - if (animation.custom) { + if (typeof animation.custom === 'string') { if (animation.custom === 'change-property') { widget.animate(changeProperty(() => (widget as Record)[animation.target]) .withAttr({ @@ -146,5 +141,11 @@ export function importWidget( }) } + if (widgetData.children) { + widget.add(...widgetData.children.map((child) => { + return importWidget(child, widgets, anims, easingFunctions) + })) + } + return widget } diff --git a/packages/newcar/package.json b/packages/newcar/package.json index ff5ec5f3a..05f0fbe62 100644 --- a/packages/newcar/package.json +++ b/packages/newcar/package.json @@ -1,7 +1,7 @@ { "name": "newcar", "type": "module", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "A Highly configurable universal advanced engine, Born for creating animation rapidly.", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/recorder/package.json b/packages/recorder/package.json index 53228aaeb..9351d913e 100644 --- a/packages/recorder/package.json +++ b/packages/recorder/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/recorder", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "The utils of newcar", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index 28496f7de..ca184d753 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/utils", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "The utils of newcar", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/plugins/plugin-debug/package.json b/plugins/plugin-debug/package.json index 2672733dd..2ad6b6f8a 100644 --- a/plugins/plugin-debug/package.json +++ b/plugins/plugin-debug/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/plugin-debug", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/plugins/plugin-timeview/package.json b/plugins/plugin-timeview/package.json index 5fde339c9..2a8ef071c 100644 --- a/plugins/plugin-timeview/package.json +++ b/plugins/plugin-timeview/package.json @@ -1,6 +1,6 @@ { "name": "@newcar/plugin-timeview", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "", "author": "BugDuck Team", "license": "Apache-2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f84d0579..8269a7955 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,17 +25,14 @@ importers: specifier: ^9.2.0 version: 9.9.0(jiti@1.21.6) husky: - specifier: ^9.1.4 - version: 9.1.4 + specifier: ^8.0.0 + version: 8.0.3 lint-staged: specifier: ^15.2.2 version: 15.2.8 pnpm: specifier: ^9.1.0 version: 9.7.0 - prettier: - specifier: 3.3.3 - version: 3.3.3 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1508,55 +1505,46 @@ packages: resolution: {integrity: sha512-jMYvxZwGmoHFBTbr12Xc6wOdc2xA5tF5F2q6t7Rcfab68TT0n+r7dgawD4qhPEvasDsVpQi+MgDzj2faOLsZjA==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.20.0': resolution: {integrity: sha512-1asSTl4HKuIHIB1GcdFHNNZhxAYEdqML/MW4QmPS4G0ivbEcBr1JKlFLKsIRqjSwOBkdItn3/ZDlyvZ/N6KPlw==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.20.0': resolution: {integrity: sha512-COBb8Bkx56KldOYJfMf6wKeYJrtJ9vEgBRAOkfw6Ens0tnmzPqvlpjZiLgkhg6cA3DGzCmLmmd319pmHvKWWlQ==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.20.0': resolution: {integrity: sha512-+it+mBSyMslVQa8wSPvBx53fYuZK/oLTu5RJoXogjk6x7Q7sz1GNRsXWjn6SwyJm8E/oMjNVwPhmNdIjwP135Q==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.20.0': resolution: {integrity: sha512-yAMvqhPfGKsAxHN8I4+jE0CpLWD8cv4z7CK7BMmhjDuz606Q2tFKkWRY8bHR9JQXYcoLfopo5TTqzxgPUjUMfw==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.20.0': resolution: {integrity: sha512-qmuxFpfmi/2SUkAw95TtNq/w/I7Gpjurx609OOOV7U4vhvUhBcftcmXwl3rqAek+ADBwSjIC4IVNLiszoj3dPA==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.20.0': resolution: {integrity: sha512-I0BtGXddHSHjV1mqTNkgUZLnS3WtsqebAXv11D5BZE/gfw5KoyXSAXVqyJximQXNvNzUo4GKlCK/dIwXlz+jlg==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.20.0': resolution: {integrity: sha512-y+eoL2I3iphUg9tN9GB6ku1FA8kOfmF4oUEWhztDJ4KXJy1agk/9+pejOuZkNFhRwHAOxMsBPLbXPd6mJiCwew==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.20.0': resolution: {integrity: sha512-hM3nhW40kBNYUkZb/r9k2FKK+/MnKglX7UYd4ZUy5DJs8/sMsIbqWK2piZtVGE3kcXVNj3B2IrUYROJMMCikNg==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.20.0': resolution: {integrity: sha512-psegMvP+Ik/Bg7QRJbv8w8PAytPA7Uo8fpFjXyCRHWm6Nt42L+JtoqH8eDQ5hRP7/XW2UiIriy1Z46jf0Oa1kA==} @@ -3155,9 +3143,9 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} - husky@9.1.4: - resolution: {integrity: sha512-bho94YyReb4JV7LYWRWxZ/xr6TtOTt8cMfmQ39MQYJ7f/YE268s3GdghGwi+y4zAeqewE5zYLvuhV0M0ijsDEA==} - engines: {node: '>=18'} + husky@8.0.3: + resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} + engines: {node: '>=14'} hasBin: true iconv-lite@0.4.24: @@ -4050,11 +4038,6 @@ packages: engines: {node: '>=10.13.0'} hasBin: true - prettier@3.3.3: - resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} - engines: {node: '>=14'} - hasBin: true - pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -8075,7 +8058,7 @@ snapshots: human-signals@5.0.0: {} - husky@9.1.4: {} + husky@8.0.3: {} iconv-lite@0.4.24: dependencies: @@ -8930,8 +8913,6 @@ snapshots: prettier@2.8.8: {} - prettier@3.3.3: {} - pretty-format@29.7.0: dependencies: '@jest/schemas': 29.6.3