Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
416 commits
Select commit Hold shift + click to select a range
8ff3fde
fix(next-runtime): fix type
HoikanChan Feb 12, 2025
f473817
chore: release babel-inula-next-core v0.0.5
HoikanChan Feb 12, 2025
aff3f23
feat: add inula-next template
HoikanChan Feb 12, 2025
89d0dc6
feat: add inula-next loader
HoikanChan Feb 12, 2025
1fb5d08
chore(view-generator): fix index access issues
HoikanChan Feb 12, 2025
aeb6df7
chore: remove transpiler-dev
HoikanChan Feb 12, 2025
dcbcb33
feat(API-2.1): support untrack
HoikanChan Feb 21, 2025
f9792e4
fix: fix compiler test
HoikanChan Feb 21, 2025
1de7aa0
chore: remove the useless
HoikanChan Feb 21, 2025
082e623
chore: bump inula-next
HoikanChan Feb 21, 2025
5ef1b20
chore: remove the useless
HoikanChan Feb 21, 2025
0d00bad
chore: replace 2.1 to 2.0
HoikanChan Feb 21, 2025
e352d5a
chore: simplify next dev
HoikanChan Feb 21, 2025
3b566e2
test: fix jsx-parser test
HoikanChan Feb 22, 2025
f80d79b
fix: compiler type error
HoikanChan Feb 22, 2025
c105c2e
fix: else if in early return
HoikanChan Feb 28, 2025
b071550
feat: support return expression in component
HoikanChan Feb 28, 2025
1bc33ea
feat: inula-router-next
HoikanChan Feb 28, 2025
291cc0c
feat: inula-router-next babel config
HoikanChan Feb 28, 2025
1bcab0f
feat: inula-router-next demo
HoikanChan Feb 28, 2025
af1037a
feat: better error report in self mutation
HoikanChan Mar 2, 2025
b5defb6
feat: inula uni plugin for build tools
HoikanChan Mar 4, 2025
ccf2acb
fix: unplugin type
HoikanChan Mar 6, 2025
ea5b24d
fix: unplugin can't resolve id with question mark
HoikanChan Mar 6, 2025
821c178
fix: lifecycle bug
HoikanChan Mar 18, 2025
972351d
feat: support spread props in context provider
HoikanChan Mar 18, 2025
ee1c6bc
fix: reactivity errror in memberExpr
HoikanChan Mar 19, 2025
6a6a811
feat: sync code
HoikanChan Mar 10, 2025
6a8ffb0
feat: update package.json
HoikanChan Mar 10, 2025
ab4c6e3
chore: add license in pkg.json
HoikanChan Mar 11, 2025
2484512
test: remove testing-library from router and intl
HoikanChan Mar 13, 2025
619285c
test: add test container type
HoikanChan Mar 13, 2025
f334b29
chore: sync code
HoikanChan Mar 13, 2025
333c7df
chore: init ci
HoikanChan Mar 13, 2025
40a5881
fix: build and test
HoikanChan Mar 13, 2025
59f91f5
chore: ci add ai code review
HoikanChan Mar 14, 2025
0b90bd6
chore: delete code-review.yml
HoikanChan Mar 14, 2025
3dba678
chore: add lock file for ci
HoikanChan Mar 14, 2025
221c1b9
fix: continuous-release
HoikanChan Mar 14, 2025
a193c72
chore: remove useless blank space
HoikanChan Mar 17, 2025
6a815ea
chore: use workspace
HoikanChan Mar 18, 2025
37ea286
fix: type error
HoikanChan Mar 18, 2025
ae6d2ef
fix: type error
HoikanChan Mar 18, 2025
01f51b4
fix(ci): release
HoikanChan Mar 19, 2025
78e87e8
feat: rebase API2.0 into main
HoikanChan Mar 19, 2025
d4a2b74
fix: add dependency for build
HoikanChan Mar 20, 2025
76a2290
Merge remote-tracking branch 'origin/master' into feat/next
HoikanChan Mar 20, 2025
0c63a57
fix: build
HoikanChan Mar 20, 2025
b5426ef
chore: remove next-router
HoikanChan Mar 20, 2025
894ce3c
chore: fix test
HoikanChan Mar 20, 2025
3c5d92a
chore: fix test for next-core and bridge
HoikanChan Mar 20, 2025
3fa4b8a
chore: remove useless file
HoikanChan Mar 20, 2025
6ee7bbb
chore: reset missing function
HoikanChan Mar 20, 2025
06c49f6
chore: sync with master
HoikanChan Mar 21, 2025
9f46fa0
chore: update lock file
HoikanChan Mar 21, 2025
0d5e212
chore: fix conflict
HoikanChan Mar 21, 2025
18e7d6c
!168 inula api2.0
HoikanChan Apr 3, 2024
b60fd5b
!169 feat: inula 2.0 init
HoikanChan Apr 3, 2024
91f01c2
refactor: add this with thisPatcher.ts
HoikanChan Apr 7, 2024
040b474
!172 Add for support and benchmark
IanDxSSXX Apr 10, 2024
233a439
feat: test
HoikanChan Apr 10, 2024
59eeb5f
feat(watch): switch to label watch
HoikanChan Apr 11, 2024
4b2f5e2
feat: cls2fn
HoikanChan Apr 10, 2024
f699b43
feat(watch): switch to label watch
HoikanChan Apr 11, 2024
f62ca30
feat: add changeset and changed package name
IanDxSSXX Apr 9, 2024
dfdd129
refactor: publish new version
IanDxSSXX Apr 10, 2024
6373c56
feat: publish (feat: add lifecycles and watch)
IanDxSSXX Apr 11, 2024
34d8fa8
test(inula-next): add test
HoikanChan Apr 15, 2024
6a64547
feat(fn2cls): env
HoikanChan Apr 15, 2024
36cd27f
feat: init
HoikanChan Apr 19, 2024
6e2e7eb
feat: analyze watch lifeCycle properties
HoikanChan Apr 24, 2024
1901405
feat: sub component
HoikanChan Apr 25, 2024
9471caf
feat: viewNode as child
HoikanChan Apr 25, 2024
9791034
refactor(proposal): use bitmap instead of dependency map
HoikanChan Apr 28, 2024
048b833
refactor(parse): use bitmap instead of dependency map
HoikanChan Apr 29, 2024
d58147e
refactor(parse): use bitmap instead of dependency map
HoikanChan May 8, 2024
41b31dc
fix(reactivity): fix for dependency
HoikanChan May 10, 2024
fe1fa3a
feat: autoNaming, autoReturn, deconstructing, jsxSlice and props
HoikanChan May 14, 2024
ffb31f6
fix(reactivity): fix for view analyze
HoikanChan May 15, 2024
2d317c6
fix(reactivity): remove used bit
HoikanChan May 17, 2024
acce301
refactor(parser): prune unused bit
HoikanChan May 22, 2024
eb2078c
docs(parser): docs
HoikanChan May 22, 2024
e43586e
fix(reactivity): fix for
HoikanChan May 24, 2024
8c65732
fix(props): rename the prop without alias and deconstruction
HoikanChan May 24, 2024
b4469d6
feat: add basic generator
IanDxSSXX May 27, 2024
49a14ca
fix: fix props
HoikanChan May 25, 2024
0016101
fix(parser): turn the unused reactive into plain variable
HoikanChan May 25, 2024
c1811e4
fix(parser): add variable declaration kind
HoikanChan May 25, 2024
39fb340
fix(destructuring): revert handle destructuring in props plugins
HoikanChan May 27, 2024
83cd7bd
chore: rename onMount to didMount
HoikanChan May 28, 2024
392b54a
fix(ut): rename onMount to didMount
HoikanChan May 28, 2024
573d9b2
fix: parser
HoikanChan May 29, 2024
51438d7
chore: remove unused dir
HoikanChan May 29, 2024
fcb7ff1
refactor: add traverse for babel-api
HoikanChan May 29, 2024
5fbd692
feat(compiler): view generator
HoikanChan May 30, 2024
a7152d6
fix(compiler): parse for
HoikanChan May 31, 2024
cb0fdc0
feat(compiler): add file filter and auto import
HoikanChan May 31, 2024
cb3fdf0
chore(compiler): set main to js in dist
HoikanChan May 31, 2024
016b313
fix(compiler): file allow
HoikanChan May 31, 2024
d72a6e2
fix(compiler): fix compile mutil times
HoikanChan Jun 3, 2024
312225a
fix(compiler): fix generator test
HoikanChan Jun 3, 2024
5effaba
fix(compiler): add props
HoikanChan Jun 5, 2024
80009e6
chore(compiler): adjust test file
HoikanChan Jun 6, 2024
7edea9c
chore(compiler): move willMount to fn body
HoikanChan Jun 7, 2024
a91908e
fix(compiler): destructing error
HoikanChan Jun 7, 2024
75d695b
feat(compiler): `updateViews` change to `getUpdateViews`
HoikanChan Jun 12, 2024
85a583d
fix(compiler): fix vitest entry issues
HoikanChan Jun 17, 2024
086f3b8
fix(compiler): fix propViews can't generate update func
HoikanChan Jun 17, 2024
80d9550
fix(compiler): put the dom node initialization in getUpdateViews func
HoikanChan Jun 18, 2024
17ea7a4
test(compiler): update snapshot
HoikanChan Jun 18, 2024
0cfd050
test(runtime): fix test
HoikanChan Jun 18, 2024
726af16
test(runtime): fix failed test
HoikanChan Jun 18, 2024
c8b25be
feat(runtime): adapt runtime to link up the whole workflow
HoikanChan Jun 18, 2024
d976a24
fix(compiler): move core to last
HoikanChan Jun 20, 2024
5e70323
chore(compiler): rename
HoikanChan Jun 21, 2024
509ff2b
feat: add demo
HoikanChan Jun 21, 2024
4fb777f
fix(compiler): static value should not be reactive
HoikanChan Jun 21, 2024
f2bd368
fix(compiler): put second param as for index
HoikanChan Jun 21, 2024
78cd056
!174 feat: add for sub component plugin
Jun 26, 2024
ebd19b0
!175 feat: Add mapping to for plugin
Jul 3, 2024
1faf846
!176 feat: condition plugin
Jul 8, 2024
c975e08
feat(compiler): support ref
HoikanChan Jun 25, 2024
add3b5d
feat(compiler): support env
HoikanChan Jun 25, 2024
1de0c04
fix(compiler): fix test
HoikanChan Jun 25, 2024
fe96a49
chore(runtime): remove unused code
HoikanChan Jun 26, 2024
2a809f5
feat(context): implement context to replace env
HoikanChan Jul 4, 2024
0b26337
refactor(context): make code clean
HoikanChan Jul 5, 2024
02b8c3b
feat(hook): compiler part
HoikanChan Jul 5, 2024
df1615a
feat(hook): support custom hook from end to end
HoikanChan Jul 11, 2024
fda0144
fix: fix test
HoikanChan Jul 11, 2024
aaa4d90
chore: remove useless pkg
HoikanChan Jul 11, 2024
976f740
chore: modify pkg.json
HoikanChan Jul 11, 2024
69f5124
fix: fix ts errors
HoikanChan Jul 11, 2024
fb249f6
chore: add organ prefix
HoikanChan Jul 12, 2024
1f3ab8d
fix: fix pkg renaming error
HoikanChan Jul 15, 2024
c805d03
fix: fix pkg renaming error II
HoikanChan Jul 15, 2024
6e294f8
feat: modify condition plugin add tests
Jul 15, 2024
edb6b63
!179 feat: add examples and tests
Jul 19, 2024
4f30e80
!181 fix: support update expression and member expression
Jul 26, 2024
7c6d84c
feat(compiler): support sub component
HoikanChan Jul 18, 2024
1a4698e
feat(compiler): support sub component
HoikanChan Jul 19, 2024
8d2bd77
feat(compiler): hoist template node to program
HoikanChan Jul 23, 2024
762ff1c
fix: fix cache
HoikanChan Jul 24, 2024
0268420
fix: support inline function update and remove the old useless style …
HoikanChan Jul 25, 2024
d6a13cf
fix: import the runtime api in need
HoikanChan Jul 25, 2024
9e18d45
refactor: use builder pattern for analyze
HoikanChan Jul 26, 2024
55ca8d4
refactor: remove temp _fullDepMask
HoikanChan Jul 26, 2024
25f1789
refactor: handle non-id
HoikanChan Jul 26, 2024
38fbfbe
test: add API2.0 for computed and fragment
HoikanChan Jul 26, 2024
dbf2175
test: fix error
HoikanChan Jul 26, 2024
fcc2afc
fix: support async function in lifecycle
HoikanChan Jul 26, 2024
e62cb80
fix: fix generator ts error
HoikanChan Jul 26, 2024
6f14cea
!182 fix: fix forSubComponentPlugin bug and modify tests
Aug 5, 2024
cda24a0
!183 fix: fix template literal state compute bug and add tests
Aug 9, 2024
a18577d
!184 test: add watch and jsx test cases
Aug 19, 2024
75ddcca
!185 test: add API-2.0 tests
Aug 26, 2024
a10cb6a
fix: fix jsx and text mix rendering bug
Aug 31, 2024
90d8aad
fix: fix props bug
Sep 6, 2024
ccd5426
!188 fix: fix props bugs
Sep 18, 2024
c7b04d8
!189 fix: fix event and rendering bug
Sep 23, 2024
863c499
feat: update inula-next runtime
IanDxSSXX Sep 25, 2024
fc011d5
Revert "feat: update inula-next runtime"
IanDxSSXX Sep 30, 2024
d90b9fe
feat: update inula-next runtime
IanDxSSXX Sep 30, 2024
b650d0f
fix: fix jsx slice bugs
Sep 30, 2024
91db0b2
!195 fix: fix event, prop, render bugs
Oct 15, 2024
d31d1e0
fix: early return
HoikanChan Nov 4, 2024
2bbf54f
fix: hook call expression should work
HoikanChan Nov 5, 2024
4bb7559
fix: should support null component
HoikanChan Nov 5, 2024
d6a0001
feat: inula-next-type
HoikanChan Nov 14, 2024
c89f970
refactor: fix
HoikanChan Nov 15, 2024
3a58c5a
feat: bit
HoikanChan Nov 17, 2024
88cd253
refactor: parser
HoikanChan Nov 20, 2024
5d539c0
chore: tmp
HoikanChan Nov 20, 2024
fa7b70b
fix: 1122
HoikanChan Nov 22, 2024
b5a5dac
refactor: generator
HoikanChan Nov 26, 2024
d1ac6d0
feat: view generator
HoikanChan Nov 29, 2024
5232bb3
feat: view generator
HoikanChan Nov 30, 2024
fbbe254
feat: generators
HoikanChan Dec 4, 2024
70df2e7
feat: for generator
HoikanChan Dec 4, 2024
a63b43e
refactor: view generator
HoikanChan Dec 11, 2024
53a123d
fix: fix jsx render error
Nov 6, 2024
2717fb4
feat: add api2.1
IanDxSSXX Dec 4, 2024
f8b8a87
refactor: runtime
HoikanChan Dec 13, 2024
e277395
refactor: generator
HoikanChan Dec 18, 2024
edc0760
feat: subComponent
HoikanChan Dec 18, 2024
4b222f0
fix: addContext should pass context
HoikanChan Dec 20, 2024
49c8cec
fix: props
HoikanChan Dec 20, 2024
7040608
refactor: runtime
HoikanChan Dec 20, 2024
da1579e
fix: compiler issues
HoikanChan Dec 23, 2024
f6aed38
fix: init mutable node's children in node creating
HoikanChan Dec 24, 2024
6bba939
fix(generator): shadow name issues
HoikanChan Dec 24, 2024
ed13a7a
fix(generator): import name issues
HoikanChan Dec 25, 2024
17ac133
test(API-2.1): add ut
HoikanChan Dec 25, 2024
123beef
fix(API-2.1): fix update derived
HoikanChan Dec 25, 2024
00c24b1
feat(API-2.1): support ref
HoikanChan Dec 27, 2024
93b50a1
refactor: complete
HoikanChan Jan 3, 2025
fd29bfb
feat: suspense
HoikanChan Jan 10, 2025
513a229
feat: portal component
HoikanChan Jan 24, 2025
82f31e0
feat: better error report
HoikanChan Jan 24, 2025
3d280a8
feat: better error reports in vite
HoikanChan Jan 24, 2025
9408777
feat: suspense
HoikanChan Jan 24, 2025
39c6a93
feat: hook
HoikanChan Jan 24, 2025
b01353b
test: add test
HoikanChan Jan 24, 2025
f1b161f
feat: inula-bridge
HoikanChan Jan 24, 2025
53b07ac
fix(next-runtime): fix type
HoikanChan Feb 12, 2025
2d10751
chore: release babel-inula-next-core v0.0.5
HoikanChan Feb 12, 2025
20fb4e5
feat: add inula-next template
HoikanChan Feb 12, 2025
ce58007
feat: add inula-next loader
HoikanChan Feb 12, 2025
6b41f3c
chore(view-generator): fix index access issues
HoikanChan Feb 12, 2025
c45576b
chore: remove transpiler-dev
HoikanChan Feb 12, 2025
06f09da
feat(API-2.1): support untrack
HoikanChan Feb 21, 2025
15a920d
fix: fix compiler test
HoikanChan Feb 21, 2025
8518ccf
chore: remove the useless
HoikanChan Feb 21, 2025
c2e3aa8
chore: bump inula-next
HoikanChan Feb 21, 2025
015b218
chore: remove the useless
HoikanChan Feb 21, 2025
97bc0bf
chore: replace 2.1 to 2.0
HoikanChan Feb 21, 2025
ae081f0
chore: simplify next dev
HoikanChan Feb 21, 2025
2ccbb14
test: fix jsx-parser test
HoikanChan Feb 22, 2025
0193d80
fix: compiler type error
HoikanChan Feb 22, 2025
4ee78f6
fix: else if in early return
HoikanChan Feb 28, 2025
acfdef5
feat: support return expression in component
HoikanChan Feb 28, 2025
bd63744
feat: inula-router-next
HoikanChan Feb 28, 2025
133e266
feat: inula-router-next babel config
HoikanChan Feb 28, 2025
cb8ad31
feat: inula-router-next demo
HoikanChan Feb 28, 2025
f17a90e
feat: better error report in self mutation
HoikanChan Mar 2, 2025
1346c48
feat: inula uni plugin for build tools
HoikanChan Mar 4, 2025
4b7417c
fix: unplugin type
HoikanChan Mar 6, 2025
175f6a3
fix: unplugin can't resolve id with question mark
HoikanChan Mar 6, 2025
ec2ba02
fix: lifecycle bug
HoikanChan Mar 18, 2025
f68348c
feat: support spread props in context provider
HoikanChan Mar 18, 2025
ff1b336
fix: reactivity errror in memberExpr
HoikanChan Mar 19, 2025
5dcab8c
feat: sync code
HoikanChan Mar 10, 2025
77f88ff
chore: add license in pkg.json
HoikanChan Mar 11, 2025
323200e
test: remove testing-library from router and intl
HoikanChan Mar 13, 2025
95fe070
chore: init ci
HoikanChan Mar 13, 2025
1c047da
chore: ci add ai code review
HoikanChan Mar 14, 2025
1da71d7
chore: delete code-review.yml
HoikanChan Mar 14, 2025
4f1af54
chore: use workspace
HoikanChan Mar 18, 2025
7b43a34
feat: rebase API2.0 into main
HoikanChan Mar 19, 2025
6e6f046
fix: add dependency for build
HoikanChan Mar 20, 2025
2ad19e4
fix: build
HoikanChan Mar 20, 2025
10c5c7d
chore: remove next-router
HoikanChan Mar 20, 2025
b233267
chore: fix test
HoikanChan Mar 20, 2025
b88bfca
chore: fix test for next-core and bridge
HoikanChan Mar 20, 2025
9b71c8a
chore: remove useless file
HoikanChan Mar 20, 2025
3f55f35
chore: reset missing function
HoikanChan Mar 20, 2025
1430123
chore: sync with master
HoikanChan Mar 21, 2025
9d9067d
chore: update lock file
HoikanChan Mar 21, 2025
f767764
chore: rebase next into master
HoikanChan Mar 21, 2025
2b6f2e8
chore: rebase next into master
HoikanChan Mar 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/node_modules
node_modules
.idea
.vscode
package-lock.json
/packages/**/node_modules
/packages/inula-cli/lib
build
dist
/packages/inula-router/connectRouter
/packages/inula-router/router
.turbo
Expand Down
7 changes: 7 additions & 0 deletions next-packages/compiler/babel-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @openinula/babel-api

## 0.0.2

### Patch Changes

- refactor: minimize compilied code
24 changes: 24 additions & 0 deletions next-packages/compiler/babel-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @openinlua/babel-api
A package that encapsulates the babel API for use in the transpiler.

To implement the dependency injection pattern, the package exports a function that registers the babel API in the
transpiler.

```ts
import { registerBabelAPI } from '@openinlua/babel-api';

function plugin(api: typeof babel) {
registerBabelAPI(api);

// Your babel plugin code here.
}
```

And then you can import to use it.
> types can use as a `type` or as a `namespace` for the babel API.

```ts
import { types as t } from '@openinlua/babel-api';

t.isIdentifier(node as t.Node);
```
19 changes: 19 additions & 0 deletions next-packages/compiler/babel-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@openinula/babel-api",
"version": "0.0.2",
"description": "",
"type": "module",
"main": "src/index.mjs",
"typings": "src/index.d.ts",
"files": [
"src"
],
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.23.3",
"@babel/types": "^7.24.0",
"@types/babel__core": "^7.20.5"
}
}
10 changes: 10 additions & 0 deletions next-packages/compiler/babel-api/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type babel from '@babel/core';

// use .d.ts to satisfy the type check
export * as types from '@babel/types';

export declare function register(api: typeof babel): void;

export declare function getBabelApi(): typeof babel;

export { traverse } from '@babel/core';
42 changes: 42 additions & 0 deletions next-packages/compiler/babel-api/src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @type {null | typeof import('@babel/core').types} */
let _t = null;
/** @type {null | typeof import('@babel/core')} */
let babelApi = null;

/**
* @param {import('@babel/core')} api
*/
export const register = api => {
babelApi = api;
_t = api.types;
};

/**
* @returns {typeof import('@babel/core')}
*/
export const getBabelApi = () => {
if (!babelApi) {
throw new Error('Please call register() before using the babel api');
}
return babelApi;
};

export function traverse(node, visitor) {
getBabelApi().traverse(node, visitor);
}

export const types = new Proxy(
{},
{
get: (_, p, receiver) => {
if (!_t) {
throw new Error('Please call register() before using the babel types');
}

if (p in _t) {
return Reflect.get(_t, p, receiver);
}
return undefined;
},
}
);
62 changes: 62 additions & 0 deletions next-packages/compiler/babel-inula-next-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# babel-preset-inula-next

## 0.0.5

### Patch Changes

- fix: index access issues
- @openinula/babel-preset-inula-next@0.0.4
-
## 0.0.4

### Patch Changes

- Updated dependencies
- @openinula/view-generator@0.0.5

## 0.0.3

### Patch Changes

- fix: build issues
- Updated dependencies
- @openinula/reactivity-parser@0.0.4
- @openinula/view-generator@0.0.4
- @openinula/error-handler@0.0.4
- @openinula/jsx-view-parser@0.0.4

## 0.0.2

### Patch Changes

- refactor: minimize compilied code
- Updated dependencies
- @openinula/babel-api@0.0.2
- @openinula/error-handler@0.0.3
- @openinula/jsx-view-parser@0.0.3
- @openinula/reactivity-parser@0.0.3
- @openinula/view-generator@0.0.3

## 0.0.4

### Patch Changes

- support hook
- Updated dependencies
- @openinula/reactivity-parser@0.0.2
- @openinula/view-generator@1.0.0
- @openinula/jsx-view-parser@0.0.2
- @openinula/babel-api@1.0.1

## 0.0.3

### Patch Changes

- Updated dependencies
- @openinula/class-transformer@0.0.2

## 0.0.2

### Patch Changes

- 2f9d373: feat: change babel import
63 changes: 63 additions & 0 deletions next-packages/compiler/babel-inula-next-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "@openinula/babel-preset-inula-next",
"version": "0.0.5",
"keywords": [
"Inula-Next",
"babel-preset"
],
"license": "MIT",
"files": [
"dist"
],
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "tsup --sourcemap",
"type-check": "tsc --noEmit",
"test": "vitest run"
},
"devDependencies": {
"@types/babel__core": "^7.20.5",
"@types/node": "^20.10.5",
"@vitest/coverage-v8": "^1.6.0",
"sinon": "^18.0.0",
"tsup": "^6.7.0",
"typescript": "^5.3.2"
},
"dependencies": {
"@babel/core": "^7.23.3",
"@babel/generator": "^7.23.6",
"@babel/parser": "^7.24.4",
"@babel/plugin-syntax-decorators": "^7.23.3",
"@babel/plugin-syntax-jsx": "7.23.3",
"@babel/plugin-syntax-typescript": "^7.23.3",
"@babel/traverse": "^7.24.1",
"@babel/types": "^7.24.0",
"@openinula/babel-api": "workspace:*",
"@openinula/jsx-view-parser": "workspace:*",
"@openinula/reactivity-parser": "workspace:*",
"@openinula/view-generator": "workspace:*",
"@openinula/error-handler": "workspace:*",
"@types/babel-types": "^7.0.15",
"@types/babel__generator": "^7.6.8",
"@types/babel__traverse": "^7.6.8",
"minimatch": "^9.0.3",
"vitest": "^1.4.0"
},
"tsup": {
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"clean": true,
"dts": true
},
"publishConfig": {
"access": "public"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
*
* openInula is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

import { NodePath } from '@babel/core';
import { LifeCycle, Visitor } from '../types';
import { types as t } from '@openinula/babel-api';
import { DID_MOUNT, DID_UNMOUNT, WATCH, WILL_MOUNT, WILL_UNMOUNT } from '../../constants';
import { extractFnFromMacro } from '../../utils';

function isLifeCycleName(name: string): name is LifeCycle {
return [WILL_MOUNT, DID_MOUNT, WILL_UNMOUNT, DID_UNMOUNT].includes(name);
}

/**
* Analyze the functional macro in the function component
* 1. lifecycle
* 1. willMount
* 2. didMount
* 3. willUnMount
* 4. didUnmount
* 2. watch
*/
export function functionalMacroAnalyze(): Visitor {
return {
ExpressionStatement(path: NodePath<t.ExpressionStatement>, { builder }) {
const expression = path.get('expression');
if (expression.isCallExpression()) {
const callee = expression.get('callee');
if (callee.isIdentifier()) {
const calleeName = callee.node.name;
// lifecycle
if (isLifeCycleName(calleeName)) {
const fnPath = extractFnFromMacro(expression, calleeName);
builder.addLifecycle(calleeName, fnPath);
return;
}

// watch
if (calleeName === WATCH) {
const fnPath = extractFnFromMacro(expression, WATCH);
const depsPath = getWatchDeps(expression);

const dependency = builder.getDependency((depsPath ?? fnPath).node);
builder.addWatch(fnPath, dependency);
return;
}
}
}

builder.addRawStmt(path.node);
},
};
}

function getWatchDeps(callExpression: NodePath<t.CallExpression>) {
const args = callExpression.get('arguments');
if (!args[1]) {
return null;
}

let deps: null | NodePath<t.ArrayExpression> = null;
if (args[1].isArrayExpression()) {
deps = args[1];
} else {
console.error('watch deps should be an array expression');
}
return deps;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
*
* openInula is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

import { Visitor } from '../types';
import { type NodePath } from '@babel/core';
import { types as t } from '@openinula/babel-api';

/**
* Analyze the return in the hook
*/
export function hookReturnAnalyze(): Visitor {
return {
ReturnStatement(path: NodePath<t.ReturnStatement>, { builder }) {
const returnedNode = path.node.argument;
if (returnedNode) {
builder.setReturnValue(returnedNode);
}
},
};
}
Loading
Loading