From a536958ad48a82801efc6c870127fa14861d19e2 Mon Sep 17 00:00:00 2001
From: Hoikan <30694822+HoikanChan@users.noreply.github.com>
Date: Mon, 15 Apr 2024 20:59:31 +0800
Subject: [PATCH] feat(fn2cls): env
---
demos/v2/src/App.tsx | 2 +-
demos/v2/src/App.view.tsx | 138 -----------
.../transpiler => docs/inula-next}/README.md | 35 +--
packages/inula-next/test/props.test.tsx | 5 +-
.../class-transformer/src/pluginProvider.ts | 87 ++++---
.../src/test/component-composition.test.ts | 132 ++++++----
.../src/test/lifecycle.test.ts | 114 +++++++++
.../{fn2Class.test.ts => reactivity.test.ts} | 234 ++++++++----------
8 files changed, 371 insertions(+), 376 deletions(-)
delete mode 100644 demos/v2/src/App.view.tsx
rename {packages/transpiler => docs/inula-next}/README.md (82%)
create mode 100644 packages/transpiler/class-transformer/src/test/lifecycle.test.ts
rename packages/transpiler/class-transformer/src/test/{fn2Class.test.ts => reactivity.test.ts} (55%)
diff --git a/demos/v2/src/App.tsx b/demos/v2/src/App.tsx
index e59b4882..4be9e284 100644
--- a/demos/v2/src/App.tsx
+++ b/demos/v2/src/App.tsx
@@ -14,4 +14,4 @@ function MyComp() {
>
);
}
-render('main', MyComp);
+render(MyComp, 'main');
diff --git a/demos/v2/src/App.view.tsx b/demos/v2/src/App.view.tsx
deleted file mode 100644
index b048a67d..00000000
--- a/demos/v2/src/App.view.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-// @ts-nocheck
-import {
- Children,
- Content,
- Main,
- Model,
- Prop,
- View,
- Watch,
- button,
- div,
- input,
- insertChildren,
- use,
- render,
-} from '@openinula/next';
-
-// @ts-ignore
-function Button({ children, onClick }) {
- return (
-
- );
-}
-
-function ArrayModification() {
- const arr = [];
- willMount(() => {});
- return (
- ArrayModification
- {arr.join(',')}
-
-
My name is {name}!
-My age is {age}!
-My favourite colors are {favouriteColors.join(', ')}!
-I am {isAvailable ? 'available' : 'not available'}
- > - ); - }`), + function UserProfile({ + name = '', + age = null, + favouriteColors: [{r, g, b}, color2], + isAvailable = false, + }) { + return ( + <> +My name is {name}!
+My age is {age}!
+My favourite colors are {favouriteColors.join(', ')}!
+I am {isAvailable ? 'available' : 'not available'}
+ > + ); + }`), ` class UserProfile { @Prop name = ''; @@ -86,7 +86,7 @@ describe('component-composition', () => { g; b; xx = (() => { - const [{r, g, b},color2] = this.favouriteColors; + const [{r, g, b}, color2] = this.favouriteColors; this.r = r this.g = g this.b = b @@ -108,31 +108,64 @@ describe('component-composition', () => { //language=JSX expect( transform(` - function Card({ children }) { - return ( -