Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
release: v2.0.0-beta.10
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Aug 14, 2024
1 parent 41a881d commit 93c91b1
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 85 deletions.
35 changes: 7 additions & 28 deletions examples/scene1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,24 @@ import TextEditor from "@newcar/mod-text-editor"
import { Table } from "@newcar/mod-table";
import {importScene} from "newcar";
import * as nc from 'newcar'
import * as mt from '@newcar/mod-math'

await useFont('./default.ttf')

export default importScene(

`{
"root": {
"type": "Circle",
"arguments": [150],
"type": "MathFunction",
"arguments": ["fn((x) => Math.sin(x))", [-2, 2]],
"options": {
"style": {
"border": true,
"fill": false,
"borderColor": [144, 144, 144, 1]
},
"x": 800,
"y": 450
},
"animations": [
{
"type": "stroke",
"parameters": {
"duration": 4
}
},
{
"custom": "change-property",
"target": "radius",
"parameters": {
"from": 1,
"to": 100,
"duration": 2
}
}
]
"x": "calc(200)",
"y": 100
}
}
}
`,
nc as any,
{...(nc as any), ...mt},
nc as any,
nc as any,
)
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-geometry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-geometry",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-layout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-layout",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-markdown",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-math/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/mod-math",
"type": "module",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-skottie/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/mod-skottie",
"type": "module",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/basic",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "The basic objects, animations and interpolators of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/core",
"type": "module",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "The core of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/json",
"type": "module",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "The core of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
42 changes: 14 additions & 28 deletions packages/json/src/import-widget.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Widget, WidgetOptions } from '@newcar/core'
import { changeProperty, parallel } from '@newcar/core'
import { changeProperty, parallel, useFont, useImage } from '@newcar/core'
import { Color, Shader, isString } from '@newcar/utils'
import { linear } from '@newcar/basic'
import type { WidgetFormat } from './format'
import { processAction } from './process-action'
import { processResource } from './process-resource'

export function processItem(color: string | Array<number>) {
if (Array.isArray(color)) {
Expand All @@ -20,28 +19,27 @@ export function processItem(color: string | Array<number>) {
// eslint-disable-next-line no-new-func
return Function(`return ${color.replace(/fn\(/, '').replace(/\)$/, '')}`)()
}
else if (isString(color) && /image\(.+\)/.test(color)) {
return useImage(color.replace(/image\(/, '').replace(/\)$/, ''))
}
else if (isString(color) && /font\(.+\)/.test(color)) {
return useFont(color.replace(/font\(/, '').replace(/\)$/, ''))
}
else if (isString(color) && /calc\(.+\)/.test(color)) {
// eslint-disable-next-line no-new-func
return Function(`return ${color.replace(/calc\(/, '').replace(/\)$/, '')}`)()
}
else {
return color
}
}

export function processOptions(options: WidgetOptions) {
for (const key in options) {
if (typeof (options as Record<string, any>)[key] === 'object')
if (typeof (options as Record<string, any>)[key] === 'object') {
(options as Record<string, any>)[key] = processOptions((options as Record<string, any>)[key])
const result1 = processResource((options as Record<string, any>)[key])
const result2 = processItem((options as Record<string, any>)[key])
if (isString(result2)) {
if (isString(result1)) {
(options as Record<string, any>)[key] = (options as Record<string, any>)[key]
}
else {
(options as Record<string, any>)[key] = result1
}
}
else {
(options as Record<string, any>)[key] = result2
}
(options as Record<string, any>)[key] = processItem((options as Record<string, any>)[key])
}
return options
}
Expand All @@ -50,19 +48,7 @@ export function processArguments(args: unknown[]) {
const result = []
for (const arg of args) {
if (isString(arg)) {
const result1 = processResource(arg as string)
const result2 = processItem(arg as string)
if (isString(result1)) {
if (isString(result2)) {
result.push(arg)
}
else {
result.push(result2)
}
}
else {
result.push(result1)
}
result.push(processItem(arg as string))
}
else {
result.push(arg)
Expand Down
16 changes: 0 additions & 16 deletions packages/json/src/process-resource.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/newcar/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "newcar",
"type": "module",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "A Highly configurable universal advanced engine, Born for creating animation rapidly.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/recorder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/recorder",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/utils",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/plugin-debug",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-timeview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/plugin-timeview",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down

0 comments on commit 93c91b1

Please sign in to comment.