From 109746acefd5b262d8004eb6bbbe4bf1959c9d9f Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Sun, 7 Apr 2024 23:08:39 -0400 Subject: [PATCH 1/6] refactor: gitignore add history --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d8b9e23e..ba7855d8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build /packages/inula-router/connectRouter /packages/inula-router/router dist +.history \ No newline at end of file -- Gitee From 627a8b7785b9ecf753ac95693d65d027fb9406e8 Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Sun, 7 Apr 2024 23:08:50 -0400 Subject: [PATCH 2/6] feat: init benchmark demo --- demos/benchmark/index.html | 12 ++++ demos/benchmark/package.json | 25 ++++++++ demos/benchmark/src/main.jsx | 102 +++++++++++++++++++++++++++++++++ demos/benchmark/vite.config.js | 13 +++++ 4 files changed, 152 insertions(+) create mode 100644 demos/benchmark/index.html create mode 100644 demos/benchmark/package.json create mode 100644 demos/benchmark/src/main.jsx create mode 100644 demos/benchmark/vite.config.js diff --git a/demos/benchmark/index.html b/demos/benchmark/index.html new file mode 100644 index 00000000..4bf97680 --- /dev/null +++ b/demos/benchmark/index.html @@ -0,0 +1,12 @@ + + + + + Dlight.JS + + + +
+ + + diff --git a/demos/benchmark/package.json b/demos/benchmark/package.json new file mode 100644 index 00000000..63425f3a --- /dev/null +++ b/demos/benchmark/package.json @@ -0,0 +1,25 @@ +{ + "name": "dev", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@babel/standalone": "^7.22.4", + "@inula/next": "workspace:*", + "@iandx/easy-css": "^0.10.14", + "babel-preset-inula-next": "workspace:*" + }, + "devDependencies": { + "typescript": "^5.2.2", + "vite": "^4.4.9", + "vite-plugin-inula-next": "workspace:*" + }, + "keywords": [ + "dlight.js" + ] +} diff --git a/demos/benchmark/src/main.jsx b/demos/benchmark/src/main.jsx new file mode 100644 index 00000000..599e008c --- /dev/null +++ b/demos/benchmark/src/main.jsx @@ -0,0 +1,102 @@ +import { createSignal, createSelector, batch } from 'solid-js'; +import { render } from 'solid-js/web'; + +let idCounter = 1; +const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy'], + colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange'], + nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']; + +function _random (max) { + return Math.round(Math.random() * 1000) % max; +} + +function buildData(count) { + let data = new Array(count); + for (let i = 0; i < count; i++) { + const [label, setLabel] = createSignal(`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`); + data[i] = { + id: idCounter++, + label, setLabel + }; + } + return data; +} + +function Button ({ id, text, fn }) { + return ( +
+ +
+ ); +} + +function App () { + let data = []; + let selected = null; + function run() { + data = buildData(1000); + } + function runLots() { + data = buildData(10000); + } + function add() { + data.push(...buildData(1000)); + } + function update() { + for (let i = 0; i < data.length; i += 10) { + data[i].label += ' !!!'; + } + } + function swapRows() { + if (data.length > 998) { + [data[1], data[998]] = [data[998], data[1]]; + } + } + function clear() { + data = []; + } + function remove(id) { + data = data.filter(d => d.id !== id); + } + function select(id) { + selected = id; + } + + return ( +
+
+

SolidJS Keyed

+
+
+
+ + + + + + + + {/*for const { id, label } of data*/} + + + + + + +
+ +
+ +
+
+ ); +} + +render('main', App); diff --git a/demos/benchmark/vite.config.js b/demos/benchmark/vite.config.js new file mode 100644 index 00000000..0531be34 --- /dev/null +++ b/demos/benchmark/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite'; +import inula from 'vite-plugin-inula-next'; + +export default defineConfig({ + server: { + port: 4320, + }, + base: '', + optimizeDeps: { + disabled: true, + }, + plugins: [inula({ files: '**/*.{tsx,jsx}' })], +}); -- Gitee From 4467bdae73bcca6d16fa874fae472ceea263f4b8 Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Sun, 7 Apr 2024 23:09:21 -0400 Subject: [PATCH 3/6] feat: add for unit parsing --- packages/transpiler/jsx-parser/src/parser.ts | 45 ++++++++++++++++++- .../jsx-parser/src/test/ElementUnit.test.ts | 9 ---- .../jsx-parser/src/test/ForUnit.test.ts | 11 +++++ .../jsx-parser/src/test/TemplateUnit.test.ts | 16 +++---- packages/transpiler/jsx-parser/src/types.ts | 1 + 5 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 packages/transpiler/jsx-parser/src/test/ForUnit.test.ts diff --git a/packages/transpiler/jsx-parser/src/parser.ts b/packages/transpiler/jsx-parser/src/parser.ts index 83f5c158..da1f5517 100644 --- a/packages/transpiler/jsx-parser/src/parser.ts +++ b/packages/transpiler/jsx-parser/src/parser.ts @@ -536,6 +536,49 @@ export class ViewParser { } private pareFor(node: t.JSXElement) { - // TODO + // ---- Get array + const arrayContainer = this.findProp(node, "array") + if (!arrayContainer) throw new Error("Missing [array] prop in for loop") + if (!this.t.isJSXExpressionContainer(arrayContainer.value)) throw new Error("Expected expression container for [array] prop") + const array = arrayContainer.value.expression + if (this.t.isJSXEmptyExpression(array)) throw new Error("Expected [array] expression not empty") + + // ---- Get key + const keyProp = this.findProp(node, "key") + let key: t.Expression = this.t.nullLiteral() + if (keyProp) { + if (!( + this.t.isJSXExpressionContainer(keyProp.value) && + this.t.isFunction(keyProp.value.expression) + )) throw new Error("Expected expression container") + key = keyProp.value.expression + } + + // ---- Get Item + const itemProp = this.findProp(node, "item") + if (!itemProp) throw new Error("Missing [item] prop in for loop") + if (!this.t.isJSXExpressionContainer(itemProp.value)) throw new Error("Expected expression container for [item] prop") + const item = itemProp.value.expression + if (this.t.isJSXEmptyExpression(item)) throw new Error("Expected [item] expression not empty") + // ---- ObjectExpression to ObjectPattern / ArrayExpression to ArrayPattern + this.traverse(this.wrapWithFile(item), { + ObjectExpression: (path) => { + path.type = "ObjectPattern" as any + }, + ArrayExpression: (path) => { + path.type = "ArrayPattern" as any + } + }) + + // ---- Get children + const children = this.t.jsxFragment(this.t.jsxOpeningFragment(), this.t.jsxClosingFragment(), node.children) + + this.viewUnits.push({ + type: "for", + key, + item: item as t.LVal, + array, + children: this.parseView(children) + }) } } diff --git a/packages/transpiler/jsx-parser/src/test/ElementUnit.test.ts b/packages/transpiler/jsx-parser/src/test/ElementUnit.test.ts index 1e015ffe..09f082db 100644 --- a/packages/transpiler/jsx-parser/src/test/ElementUnit.test.ts +++ b/packages/transpiler/jsx-parser/src/test/ElementUnit.test.ts @@ -186,13 +186,4 @@ describe('ElementUnit', () => { const htmlUnit = viewUnits[0] as HTMLUnit; expect(htmlUnit.children!.length).toBe(4); }); - - it('should correctly parse the children', () => { - const viewUnits = parse('
ok
'); - const htmlUnit = viewUnits[0] as HTMLUnit; - const firstChild = htmlUnit.children![0]; - expect(firstChild.type).toBe('html'); - expect(t.isStringLiteral((firstChild as HTMLUnit).tag, { value: 'div' })).toBeTruthy(); - expect((firstChild as HTMLUnit).children![0].type).toBe('text'); - }); }); diff --git a/packages/transpiler/jsx-parser/src/test/ForUnit.test.ts b/packages/transpiler/jsx-parser/src/test/ForUnit.test.ts new file mode 100644 index 00000000..3fea384e --- /dev/null +++ b/packages/transpiler/jsx-parser/src/test/ForUnit.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from 'vitest'; +import { parse } from './mock'; + + +describe('ForUnit', () => { + it('should identify for unit', () => { + const viewUnits = parse('
{item}
'); + expect(viewUnits.length).toBe(1); + expect(viewUnits[0].type).toBe('for'); + }); +}); \ No newline at end of file diff --git a/packages/transpiler/jsx-parser/src/test/TemplateUnit.test.ts b/packages/transpiler/jsx-parser/src/test/TemplateUnit.test.ts index 671def94..ca8c79f0 100644 --- a/packages/transpiler/jsx-parser/src/test/TemplateUnit.test.ts +++ b/packages/transpiler/jsx-parser/src/test/TemplateUnit.test.ts @@ -17,7 +17,7 @@ describe('TemplateUnit', () => { expect(viewUnits[0].type).toBe('template'); }); - it("should correctly parse a nested HTMLUnit's structure into a template", () => { + it('should correctly parse a nested HTMLUnit\'s structure into a template', () => { const viewUnits = parse('
'); const template = (viewUnits[0] as TemplateUnit).template; @@ -28,7 +28,7 @@ describe('TemplateUnit', () => { }); // ---- Props - it("should correctly parse the path of TemplateUnit's dynamic props in root element", () => { + it('should correctly parse the path of TemplateUnit\'s dynamic props in root element', () => { const viewUnits = parse('
'); const dynamicProps = (viewUnits[0] as TemplateUnit).props; @@ -37,7 +37,7 @@ describe('TemplateUnit', () => { expect(prop.path).toHaveLength(0); }); - it("should correctly parse the path of TemplateUnit's dynamic props in nested element", () => { + it('should correctly parse the path of TemplateUnit\'s dynamic props in nested element', () => { const viewUnits = parse('
'); const dynamicProps = (viewUnits[0] as TemplateUnit).props!; @@ -47,17 +47,17 @@ describe('TemplateUnit', () => { expect(prop.path[0]).toBe(0); }); - it("should correctly parse the path of TemplateUnit's dynamic props with mutable particles ahead", () => { + it('should correctly parse the path of TemplateUnit\'s dynamic props with mutable particles ahead', () => { const viewUnits = parse('
'); const dynamicProps = (viewUnits[0] as TemplateUnit).props!; expect(dynamicProps).toHaveLength(1); const prop = dynamicProps[0]!; expect(prop.path).toHaveLength(1); - expect(prop.path[0]).toBe(1); + expect(prop.path[0]).toBe(0); }); - it("should correctly parse the path of TemplateUnit's mutableUnits", () => { + it('should correctly parse the path of TemplateUnit\'s mutableUnits', () => { const viewUnits = parse('
'); const mutableParticles = (viewUnits[0] as TemplateUnit).mutableUnits!; @@ -67,7 +67,7 @@ describe('TemplateUnit', () => { expect(particle.path[0]).toBe(0); }); - it("should correctly parse the path of multiple TemplateUnit's mutableUnits", () => { + it('should correctly parse the path of multiple TemplateUnit\'s mutableUnits', () => { const viewUnits = parse('
'); const mutableParticles = (viewUnits[0] as TemplateUnit).mutableUnits!; @@ -77,6 +77,6 @@ describe('TemplateUnit', () => { expect(firstParticle.path[0]).toBe(0); const secondParticle = mutableParticles[1]!; expect(secondParticle.path).toHaveLength(1); - expect(secondParticle.path[0]).toBe(2); + expect(secondParticle.path[0]).toBe(-1); }); }); diff --git a/packages/transpiler/jsx-parser/src/types.ts b/packages/transpiler/jsx-parser/src/types.ts index e860ad92..238335ea 100644 --- a/packages/transpiler/jsx-parser/src/types.ts +++ b/packages/transpiler/jsx-parser/src/types.ts @@ -59,6 +59,7 @@ export interface IfUnit { export interface ExpUnit { type: 'exp'; content: UnitProp; + props: Record; } export interface EnvUnit { -- Gitee From d6ba039445f79c1f13515a5b9607d860325c0f52 Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Sun, 7 Apr 2024 23:09:39 -0400 Subject: [PATCH 4/6] fix: import package from workspace --- packages/transpiler/vite-plugin-inula-next/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/transpiler/vite-plugin-inula-next/src/index.ts b/packages/transpiler/vite-plugin-inula-next/src/index.ts index 64042809..cb299115 100644 --- a/packages/transpiler/vite-plugin-inula-next/src/index.ts +++ b/packages/transpiler/vite-plugin-inula-next/src/index.ts @@ -1,5 +1,5 @@ import { transform } from '@babel/core'; -import dlight, { type DLightOption } from '../../babel-preset-inula-next'; +import dlight, { type DLightOption } from 'babel-preset-inula-next'; import { minimatch } from 'minimatch'; import { Plugin, TransformResult } from 'vite'; export default function (options: DLightOption = {}): Plugin { -- Gitee From 2f9d3737dbde49d2c4f5b28c67aa84aadcfe7abb Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Tue, 9 Apr 2024 03:28:10 -0400 Subject: [PATCH 5/6] feat: add changeset and changed package name --- .changeset/README.md | 8 +++ .changeset/config.json | 11 +++ .changeset/nice-hairs-promise.md | 5 ++ demos/benchmark/index.html | 3 +- demos/benchmark/package.json | 2 +- demos/benchmark/src/main.jsx | 29 +++----- demos/v2/package.json | 2 +- demos/v2/src/App.tsx | 35 +++++++++ demos/v2/src/App.view.tsx | 72 ++++++++++++++++++- package.json | 4 ++ packages/inula-cli/README.md | 6 +- packages/inula-next-store/package.json | 2 +- packages/inula-next/package.json | 8 +-- packages/inula-next/src/store.js | 2 +- .../inula-router/src/configs/package.json | 1 + packages/transpiler/README.md | 11 ++- .../babel-preset-inula-next/package.json | 8 +-- .../babel-preset-inula-next/src/const.ts | 2 +- .../babel-preset-inula-next/src/global.d.ts | 2 + .../babel-preset-inula-next/src/index.ts | 8 ++- .../src/pluginProvider.ts | 6 +- .../transpiler/class-transformer/package.json | 4 +- .../class-transformer/src/thisPatcher.ts | 2 +- .../transpiler/error-handler/package.json | 4 +- packages/transpiler/jsx-parser/package.json | 2 +- packages/transpiler/jsx-parser/src/parser.ts | 44 ++++++------ .../transpiler/reactivity-parser/package.json | 6 +- .../transpiler/reactivity-parser/src/error.ts | 2 +- .../transpiler/reactivity-parser/src/index.ts | 2 +- .../reactivity-parser/src/parser.ts | 2 +- .../reactivity-parser/src/test/mock.ts | 2 +- .../transpiler/view-generator/package.json | 6 +- .../src/HelperGenerators/BaseGenerator.ts | 2 +- .../src/HelperGenerators/PropViewGenerator.ts | 2 +- .../view-generator/src/MainViewGenerator.ts | 2 +- .../src/NodeGenerators/CompGenerator.ts | 2 +- .../src/NodeGenerators/EnvGenerator.ts | 2 +- .../src/NodeGenerators/ExpGenerator.ts | 2 +- .../src/NodeGenerators/ForGenerator.ts | 2 +- .../src/NodeGenerators/HTMLGenerator.ts | 2 +- .../src/NodeGenerators/IfGenerator.ts | 2 +- .../src/NodeGenerators/SnippetGenerator.ts | 2 +- .../src/NodeGenerators/SwitchGenerator.ts | 2 +- .../src/NodeGenerators/TemplateGenerator.ts | 2 +- .../src/NodeGenerators/TextGenerator.ts | 2 +- .../src/NodeGenerators/TryGenerator.ts | 2 +- .../view-generator/src/SnippetGenerator.ts | 2 +- .../view-generator/src/ViewGenerator.ts | 2 +- .../transpiler/view-generator/src/error.ts | 2 +- .../transpiler/view-generator/src/index.ts | 2 +- packages/transpiler/view-parser/package.json | 4 +- packages/transpiler/view-parser/src/error.ts | 6 +- 52 files changed, 240 insertions(+), 109 deletions(-) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .changeset/nice-hairs-promise.md create mode 100644 demos/v2/src/App.tsx diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 00000000..e5b6d8d6 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000..37ed01cf --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/nice-hairs-promise.md b/.changeset/nice-hairs-promise.md new file mode 100644 index 00000000..08fefbb1 --- /dev/null +++ b/.changeset/nice-hairs-promise.md @@ -0,0 +1,5 @@ +--- +"babel-preset-inula-next": patch +--- + +feat: change babel import diff --git a/demos/benchmark/index.html b/demos/benchmark/index.html index 4bf97680..bfe601bd 100644 --- a/demos/benchmark/index.html +++ b/demos/benchmark/index.html @@ -2,8 +2,7 @@ - Dlight.JS - + Inula-next
diff --git a/demos/benchmark/package.json b/demos/benchmark/package.json index 63425f3a..cfc37a65 100644 --- a/demos/benchmark/package.json +++ b/demos/benchmark/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@babel/standalone": "^7.22.4", - "@inula/next": "workspace:*", + "@openinula/next": "workspace:*", "@iandx/easy-css": "^0.10.14", "babel-preset-inula-next": "workspace:*" }, diff --git a/demos/benchmark/src/main.jsx b/demos/benchmark/src/main.jsx index 599e008c..033aa9ff 100644 --- a/demos/benchmark/src/main.jsx +++ b/demos/benchmark/src/main.jsx @@ -1,22 +1,22 @@ -import { createSignal, createSelector, batch } from 'solid-js'; -import { render } from 'solid-js/web'; +import { render, View } from '@openinula/next'; + let idCounter = 1; -const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy'], - colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange'], - nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']; -function _random (max) { +const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy']; +const colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange']; +const nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']; + +function _random(max) { return Math.round(Math.random() * 1000) % max; } function buildData(count) { - let data = new Array(count); + const data = new Array(count); for (let i = 0; i < count; i++) { - const [label, setLabel] = createSignal(`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`); data[i] = { id: idCounter++, - label, setLabel + label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}` }; } return data; @@ -65,7 +65,7 @@ function App () { return (
-

SolidJS Keyed

+

Inula-next Keyed

diff --git a/demos/v2/package.json b/demos/v2/package.json index 63425f3a..cfc37a65 100644 --- a/demos/v2/package.json +++ b/demos/v2/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@babel/standalone": "^7.22.4", - "@inula/next": "workspace:*", + "@openinula/next": "workspace:*", "@iandx/easy-css": "^0.10.14", "babel-preset-inula-next": "workspace:*" }, diff --git a/demos/v2/src/App.tsx b/demos/v2/src/App.tsx new file mode 100644 index 00000000..7e06b3c1 --- /dev/null +++ b/demos/v2/src/App.tsx @@ -0,0 +1,35 @@ +// @ts-nocheck +import { + Children, + Content, + Main, + Model, + Prop, + View, + Watch, + button, + div, + input, + insertChildren, + use, + render, +} from '@openinula/next'; + + +function MyComp() { + let count = 0; + const db = count * 2; + + return ( + <> +

Hello dlight fn comp

+
+ count: {count}, double is: {db} + +
+ + ); +} + + +render('main', MyComp); diff --git a/demos/v2/src/App.view.tsx b/demos/v2/src/App.view.tsx index 0e47914b..0c5587bf 100644 --- a/demos/v2/src/App.view.tsx +++ b/demos/v2/src/App.view.tsx @@ -13,7 +13,7 @@ import { insertChildren, use, render, -} from '@inula/next'; +} from '@openinula/next'; // @ts-ignore function Button({ children, onClick }) { @@ -35,7 +35,7 @@ function Button({ children, onClick }) { } function ArrayModification() { - let arr = []; + const arr = []; willMount(() => {}); return (
@@ -46,9 +46,75 @@ function ArrayModification() { ); } + +function Counter() { + let count = 0; + const doubleCount = count * 2; // 当count变化时,doubleCount自动更新 + + // 当count变化时,watch会自动执行 + watch(() => { + uploadToServer(count); + console.log(`count has changed: ${count}`); + }); + + // 只有在init的时候执行一次 + console.log(`Counter willMount with count ${count}`); + // 在elements被挂载到DOM之后执行 + didMount(() => { + console.log(`Counter didMount with count ${count}`); + }); + + return ( +
+ count: {count}, double is: {doubleCount} + +
+ ); +} + +function Counter() { + let count = 0; + const doubleCount = count * 2; // 当count变化时,doubleCount自动更新 + + uploadToServer(count); // 当count变化时,uploadToServer会自动执行 + console.log(`count has changed: ${count}`); // 当count变化时,console.log会自动执行 + + // 只有在init的时候执行一次 + willMount(() => { + console.log(`Counter willMount with count ${count}`); + }); + // 在elements被挂载到DOM之后执行 + didMount(() => { + console.log(`Counter didMount with count ${count}`); + }); + + return ( +
+ count: {count}, double is: {doubleCount} + +
+ ); +} + + + function MyComp() { let count = 0; - let db = count * 2; + + { + console.log(count); + const i = count * 2; + console.log(i); + } + + console.log(count); + const i = count * 2; + console.log(i); + + const XX = () => { + + }; + return ( <>

Hello dlight fn comp

diff --git a/package.json b/package.json index 4eaba18d..3d6b47e8 100644 --- a/package.json +++ b/package.json @@ -81,5 +81,9 @@ "engines": { "node": ">=10.x", "npm": ">=7.x" + }, + "dependencies": { + "@changesets/cli": "^2.27.1", + "changeset": "^0.2.6" } } diff --git a/packages/inula-cli/README.md b/packages/inula-cli/README.md index e60a1cd2..c119d321 100644 --- a/packages/inula-cli/README.md +++ b/packages/inula-cli/README.md @@ -178,10 +178,10 @@ inula-cli的所有功能都围绕插件展开,插件可以很方便地让用 inula-cli支持用户集成已发布在npm仓库的插件,用户可以按需安装并运行这些插件。 -安装可以通过npm安装,这里以插件@inula/add为例: +安装可以通过npm安装,这里以插件@openinula/add为例: ```shell -npm i --save-dev @inula/add +npm i --save-dev @openinula/add ``` 如果需要运行插件,需要在配置文件中配置对应的插件路径 @@ -191,7 +191,7 @@ npm i --save-dev @inula/add export default { ... - plugins:["@inula/add"] + plugins:["@openinula/add"] } ``` diff --git a/packages/inula-next-store/package.json b/packages/inula-next-store/package.json index cf40cc8e..880c3972 100644 --- a/packages/inula-next-store/package.json +++ b/packages/inula-next-store/package.json @@ -1,5 +1,5 @@ { - "name": "@inula/store", + "name": "@openinula/store", "version": "0.0.0", "description": "DLight shared store", "author": { diff --git a/packages/inula-next/package.json b/packages/inula-next/package.json index 9136e106..3d65fa54 100644 --- a/packages/inula-next/package.json +++ b/packages/inula-next/package.json @@ -1,12 +1,12 @@ { - "name": "@inula/next", - "version": "1.0.0-next.9", + "name": "@openinula/next", + "version": "0.0.1", "author": { "name": "IanDx", "email": "iandxssxx@gmail.com" }, "keywords": [ - "dlight.js" + "inula" ], "license": "MIT", "files": [ @@ -22,7 +22,7 @@ }, "dependencies": { "csstype": "^3.1.3", - "@inula/store": "workspace:*" + "@openinula/store": "workspace:*" }, "devDependencies": { "tsup": "^6.5.0" diff --git a/packages/inula-next/src/store.js b/packages/inula-next/src/store.js index 76aead7b..199a9899 100644 --- a/packages/inula-next/src/store.js +++ b/packages/inula-next/src/store.js @@ -1,4 +1,4 @@ -import { Store } from '@inula/store'; +import { Store } from '@openinula/store'; // ---- Using external Store to store global and document // Because Store is a singleton, it is safe to use it as a global variable diff --git a/packages/inula-router/src/configs/package.json b/packages/inula-router/src/configs/package.json index c0954f5d..22be92db 100644 --- a/packages/inula-router/src/configs/package.json +++ b/packages/inula-router/src/configs/package.json @@ -1,4 +1,5 @@ { + "name": "inula-router-config", "module": "./esm/connectRouter.js", "main": "./cjs/connectRouter.js", "types": "./@types/index.d.ts", diff --git a/packages/transpiler/README.md b/packages/transpiler/README.md index c47e708a..a6dd3632 100644 --- a/packages/transpiler/README.md +++ b/packages/transpiler/README.md @@ -27,7 +27,16 @@ This is a experimental package to implement [API2.0](https://gitee.com/openInula - [x] fragment - [ ] ref (to validate) - [ ] snippet - - [ ] for + - [x] for + +# 4.8 TODO +@YH +* Benchmark(result + comparison) +* Playground(@HQ publish) deploy +* PPT +* DEMO +* api2.1 compiled code + # function component syntax diff --git a/packages/transpiler/babel-preset-inula-next/package.json b/packages/transpiler/babel-preset-inula-next/package.json index c5e8a434..4f11f988 100644 --- a/packages/transpiler/babel-preset-inula-next/package.json +++ b/packages/transpiler/babel-preset-inula-next/package.json @@ -32,10 +32,10 @@ "@babel/core": "^7.23.3", "@babel/plugin-syntax-jsx": "7.16.7", "@babel/plugin-syntax-typescript": "^7.23.3", - "@inula/reactivity-parser": "workspace:*", - "@inula/view-generator": "workspace:*", - "@inula/view-parser": "workspace:*", - "@inula/class-transformer": "workspace:*", + "@openinula/reactivity-parser": "workspace:*", + "@openinula/view-generator": "workspace:*", + "@openinula/view-parser": "workspace:*", + "@openinula/class-transformer": "workspace:*", "jsx-view-parser": "workspace:*", "minimatch": "^9.0.3", "vitest": "^1.4.0" diff --git a/packages/transpiler/babel-preset-inula-next/src/const.ts b/packages/transpiler/babel-preset-inula-next/src/const.ts index eeba48df..461f7594 100644 --- a/packages/transpiler/babel-preset-inula-next/src/const.ts +++ b/packages/transpiler/babel-preset-inula-next/src/const.ts @@ -227,7 +227,7 @@ export const defaultHTMLTags = [ ]; export const availableDecoNames = ['Static', 'Prop', 'Env', 'Content', 'Children']; -export const dlightDefaultPackageName = '@inula/next'; +export const dlightDefaultPackageName = '@openinula/next'; export const importMap = Object.fromEntries( [ diff --git a/packages/transpiler/babel-preset-inula-next/src/global.d.ts b/packages/transpiler/babel-preset-inula-next/src/global.d.ts index 505ace20..e01cb60d 100644 --- a/packages/transpiler/babel-preset-inula-next/src/global.d.ts +++ b/packages/transpiler/babel-preset-inula-next/src/global.d.ts @@ -1,2 +1,4 @@ declare module '@babel/plugin-syntax-do-expressions'; declare module '@babel/plugin-syntax-decorators'; +declare module '@babel/plugin-syntax-jsx'; +declare module '@babel/plugin-syntax-typescript'; \ No newline at end of file diff --git a/packages/transpiler/babel-preset-inula-next/src/index.ts b/packages/transpiler/babel-preset-inula-next/src/index.ts index 3308173b..6dc09dbe 100644 --- a/packages/transpiler/babel-preset-inula-next/src/index.ts +++ b/packages/transpiler/babel-preset-inula-next/src/index.ts @@ -1,14 +1,16 @@ import syntaxDecorators from '@babel/plugin-syntax-decorators'; +import syntaxJSX from '@babel/plugin-syntax-jsx'; +import syntaxTypescript from '@babel/plugin-syntax-typescript'; import dlight from './plugin'; import { type DLightOption } from './types'; import { type ConfigAPI, type TransformOptions } from '@babel/core'; -import { plugin as fn2Class } from '@inula/class-transformer'; +import { plugin as fn2Class } from '@openinula/class-transformer'; export default function (_: ConfigAPI, options: DLightOption): TransformOptions { return { plugins: [ - ['@babel/plugin-syntax-jsx'], - ['@babel/plugin-syntax-typescript', { isTSX: true }], + syntaxJSX.default ?? syntaxJSX, + [syntaxTypescript.default ?? syntaxTypescript, { isTSX: true }], [syntaxDecorators.default ?? syntaxDecorators, { legacy: true }], fn2Class, [dlight, options], diff --git a/packages/transpiler/babel-preset-inula-next/src/pluginProvider.ts b/packages/transpiler/babel-preset-inula-next/src/pluginProvider.ts index 203b3ee6..386fec16 100644 --- a/packages/transpiler/babel-preset-inula-next/src/pluginProvider.ts +++ b/packages/transpiler/babel-preset-inula-next/src/pluginProvider.ts @@ -2,10 +2,10 @@ import type babel from '@babel/core'; import { type types as t, type NodePath } from '@babel/core'; import { type PropertyContainer, type HTMLTags, type SnippetPropSubDepMap } from './types'; import { minimatch } from 'minimatch'; -import { parseView, ViewUnit } from '@inula/view-parser'; +import { parseView, ViewUnit } from '@openinula/view-parser'; import { parseView as parseJSX } from 'jsx-view-parser'; -import { parseReactivity } from '@inula/reactivity-parser'; -import { generateSnippet, generateView } from '@inula/view-generator'; +import { parseReactivity } from '@openinula/reactivity-parser'; +import { generateSnippet, generateView } from '@openinula/view-generator'; import { alterAttributeMap, availableDecoNames, diff --git a/packages/transpiler/class-transformer/package.json b/packages/transpiler/class-transformer/package.json index 7d6c5690..bf0fb948 100644 --- a/packages/transpiler/class-transformer/package.json +++ b/packages/transpiler/class-transformer/package.json @@ -1,6 +1,6 @@ { - "name": "@inula/class-transformer", - "version": "0.0.0", + "name": "@openinula/class-transformer", + "version": "0.0.1", "description": "Inula view generator", "keywords": [ "inula" diff --git a/packages/transpiler/class-transformer/src/thisPatcher.ts b/packages/transpiler/class-transformer/src/thisPatcher.ts index aa88c121..654d30d7 100644 --- a/packages/transpiler/class-transformer/src/thisPatcher.ts +++ b/packages/transpiler/class-transformer/src/thisPatcher.ts @@ -19,7 +19,7 @@ export class ThisPatcher { (def): def is Exclude => !this.t.isTSIndexSignature(def) && !this.t.isStaticBlock(def) ) - .map(def => ('name' in def.key ? def.key.name : null)); + .map(def => (def?.key?.name ? def.key.name : null)); for (const memberOrMethod of classBodyNode.body) { classPath.scope.traverse(memberOrMethod, { diff --git a/packages/transpiler/error-handler/package.json b/packages/transpiler/error-handler/package.json index 3e34848f..c0437f0f 100644 --- a/packages/transpiler/error-handler/package.json +++ b/packages/transpiler/error-handler/package.json @@ -1,6 +1,6 @@ { - "name": "@inula/error-handler", - "version": "1.0.0-alpha.0", + "name": "@openinula/error-handler", + "version": "0.0.1", "author": { "name": "IanDx", "email": "iandxssxx@gmail.com" diff --git a/packages/transpiler/jsx-parser/package.json b/packages/transpiler/jsx-parser/package.json index 5fb1ac1b..b9c8f688 100644 --- a/packages/transpiler/jsx-parser/package.json +++ b/packages/transpiler/jsx-parser/package.json @@ -1,6 +1,6 @@ { "name": "jsx-view-parser", - "version": "0.0.0", + "version": "0.0.1", "description": "Inula jsx parser", "author": { "name": "IanDx", diff --git a/packages/transpiler/jsx-parser/src/parser.ts b/packages/transpiler/jsx-parser/src/parser.ts index da1f5517..14a49619 100644 --- a/packages/transpiler/jsx-parser/src/parser.ts +++ b/packages/transpiler/jsx-parser/src/parser.ts @@ -537,48 +537,46 @@ export class ViewParser { private pareFor(node: t.JSXElement) { // ---- Get array - const arrayContainer = this.findProp(node, "array") - if (!arrayContainer) throw new Error("Missing [array] prop in for loop") - if (!this.t.isJSXExpressionContainer(arrayContainer.value)) throw new Error("Expected expression container for [array] prop") - const array = arrayContainer.value.expression - if (this.t.isJSXEmptyExpression(array)) throw new Error("Expected [array] expression not empty") + const arrayContainer = this.findProp(node, 'array'); + if (!arrayContainer) throw new Error('Missing [array] prop in for loop'); + if (!this.t.isJSXExpressionContainer(arrayContainer.value)) throw new Error('Expected expression container for [array] prop'); + const array = arrayContainer.value.expression; + if (this.t.isJSXEmptyExpression(array)) throw new Error('Expected [array] expression not empty'); // ---- Get key - const keyProp = this.findProp(node, "key") - let key: t.Expression = this.t.nullLiteral() + const keyProp = this.findProp(node, 'key'); + let key: t.Expression = this.t.nullLiteral(); if (keyProp) { - if (!( - this.t.isJSXExpressionContainer(keyProp.value) && - this.t.isFunction(keyProp.value.expression) - )) throw new Error("Expected expression container") - key = keyProp.value.expression + if (!this.t.isJSXExpressionContainer(keyProp.value)) throw new Error('Expected expression container'); + if (this.t.isJSXEmptyExpression(keyProp.value.expression)) throw new Error('Expected expression not empty'); + key = keyProp.value.expression; } // ---- Get Item - const itemProp = this.findProp(node, "item") - if (!itemProp) throw new Error("Missing [item] prop in for loop") - if (!this.t.isJSXExpressionContainer(itemProp.value)) throw new Error("Expected expression container for [item] prop") - const item = itemProp.value.expression - if (this.t.isJSXEmptyExpression(item)) throw new Error("Expected [item] expression not empty") + const itemProp = this.findProp(node, 'item'); + if (!itemProp) throw new Error('Missing [item] prop in for loop'); + if (!this.t.isJSXExpressionContainer(itemProp.value)) throw new Error('Expected expression container for [item] prop'); + const item = itemProp.value.expression; + if (this.t.isJSXEmptyExpression(item)) throw new Error('Expected [item] expression not empty'); // ---- ObjectExpression to ObjectPattern / ArrayExpression to ArrayPattern this.traverse(this.wrapWithFile(item), { ObjectExpression: (path) => { - path.type = "ObjectPattern" as any + path.node.type = 'ObjectPattern' as any; }, ArrayExpression: (path) => { - path.type = "ArrayPattern" as any + path.node.type = 'ArrayPattern' as any; } - }) + }); // ---- Get children - const children = this.t.jsxFragment(this.t.jsxOpeningFragment(), this.t.jsxClosingFragment(), node.children) + const children = this.t.jsxFragment(this.t.jsxOpeningFragment(), this.t.jsxClosingFragment(), node.children); this.viewUnits.push({ - type: "for", + type: 'for', key, item: item as t.LVal, array, children: this.parseView(children) - }) + }); } } diff --git a/packages/transpiler/reactivity-parser/package.json b/packages/transpiler/reactivity-parser/package.json index 3fc66fa5..568297d3 100644 --- a/packages/transpiler/reactivity-parser/package.json +++ b/packages/transpiler/reactivity-parser/package.json @@ -1,5 +1,5 @@ { - "name": "@inula/reactivity-parser", + "name": "@openinula/reactivity-parser", "version": "0.0.1", "author": { "name": "IanDx", @@ -29,8 +29,8 @@ "vitest": "^0.34.5" }, "dependencies": { - "@inula/error-handler": "workspace:*", - "@inula/view-parser": "workspace:*" + "@openinula/error-handler": "workspace:*", + "@openinula/view-parser": "workspace:*" }, "tsup": { "entry": [ diff --git a/packages/transpiler/reactivity-parser/src/error.ts b/packages/transpiler/reactivity-parser/src/error.ts index 987b7efd..8a5b5695 100644 --- a/packages/transpiler/reactivity-parser/src/error.ts +++ b/packages/transpiler/reactivity-parser/src/error.ts @@ -1,4 +1,4 @@ -import { createErrorHandler } from '@inula/error-handler'; +import { createErrorHandler } from '@openinula/error-handler'; export const DLError = createErrorHandler('ReactivityParser', { 1: 'Invalid ViewUnit type', diff --git a/packages/transpiler/reactivity-parser/src/index.ts b/packages/transpiler/reactivity-parser/src/index.ts index 20cddd44..06076d17 100644 --- a/packages/transpiler/reactivity-parser/src/index.ts +++ b/packages/transpiler/reactivity-parser/src/index.ts @@ -1,4 +1,4 @@ -import { type ViewUnit } from '@inula/view-parser'; +import { type ViewUnit } from '@openinula/view-parser'; import { ReactivityParser } from './parser'; import { type ViewParticle, type ReactivityParserConfig } from './types'; diff --git a/packages/transpiler/reactivity-parser/src/parser.ts b/packages/transpiler/reactivity-parser/src/parser.ts index 336f9454..ce708123 100644 --- a/packages/transpiler/reactivity-parser/src/parser.ts +++ b/packages/transpiler/reactivity-parser/src/parser.ts @@ -30,7 +30,7 @@ import { type SnippetUnit, SwitchUnit, TryUnit, -} from '@inula/view-parser'; +} from '@openinula/view-parser'; import { DLError } from './error'; export class ReactivityParser { diff --git a/packages/transpiler/reactivity-parser/src/test/mock.ts b/packages/transpiler/reactivity-parser/src/test/mock.ts index 73a54b24..77e80c03 100644 --- a/packages/transpiler/reactivity-parser/src/test/mock.ts +++ b/packages/transpiler/reactivity-parser/src/test/mock.ts @@ -1,6 +1,6 @@ import babelApi, { parseSync, type types as t } from '@babel/core'; import { type ReactivityParserConfig } from '../types'; -import { parseView as pV, type ViewParserConfig } from '@inula/view-parser'; +import { parseView as pV, type ViewParserConfig } from '@openinula/view-parser'; import { parseReactivity as pR } from '../index'; const htmlTags = [ diff --git a/packages/transpiler/view-generator/package.json b/packages/transpiler/view-generator/package.json index 66817afb..45387188 100644 --- a/packages/transpiler/view-generator/package.json +++ b/packages/transpiler/view-generator/package.json @@ -1,5 +1,5 @@ { - "name": "@inula/view-generator", + "name": "@openinula/view-generator", "version": "0.0.1", "author": { "name": "IanDx", @@ -25,10 +25,10 @@ "@types/node": "^20.10.5", "tsup": "^6.7.0", "typescript": "^5.3.2", - "@inula/reactivity-parser": "workspace:*" + "@openinula/reactivity-parser": "workspace:*" }, "dependencies": { - "@inula/error-handler": "workspace:*" + "@openinula/error-handler": "workspace:*" }, "tsup": { "entry": [ diff --git a/packages/transpiler/view-generator/src/HelperGenerators/BaseGenerator.ts b/packages/transpiler/view-generator/src/HelperGenerators/BaseGenerator.ts index f66c62d7..05dbaf53 100644 --- a/packages/transpiler/view-generator/src/HelperGenerators/BaseGenerator.ts +++ b/packages/transpiler/view-generator/src/HelperGenerators/BaseGenerator.ts @@ -1,5 +1,5 @@ import { type types as t, type traverse } from '@babel/core'; -import { type ViewParticle } from '@inula/reactivity-parser'; +import { type ViewParticle } from '@openinula/reactivity-parser'; import { type SnippetPropMap, type ViewGeneratorConfig } from '../types'; import ViewGenerator from '../ViewGenerator'; diff --git a/packages/transpiler/view-generator/src/HelperGenerators/PropViewGenerator.ts b/packages/transpiler/view-generator/src/HelperGenerators/PropViewGenerator.ts index 0e5d4627..394b5c0a 100644 --- a/packages/transpiler/view-generator/src/HelperGenerators/PropViewGenerator.ts +++ b/packages/transpiler/view-generator/src/HelperGenerators/PropViewGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type DependencyProp, type ViewParticle } from '@inula/reactivity-parser'; +import { type DependencyProp, type ViewParticle } from '@openinula/reactivity-parser'; import LifecycleGenerator from './LifecycleGenerator'; export default class PropViewGenerator extends LifecycleGenerator { diff --git a/packages/transpiler/view-generator/src/MainViewGenerator.ts b/packages/transpiler/view-generator/src/MainViewGenerator.ts index 122b70fc..aae24879 100644 --- a/packages/transpiler/view-generator/src/MainViewGenerator.ts +++ b/packages/transpiler/view-generator/src/MainViewGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type ViewParticle } from '@inula/reactivity-parser'; +import { type ViewParticle } from '@openinula/reactivity-parser'; import ViewGenerator from './ViewGenerator'; export default class MainViewGenerator extends ViewGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/CompGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/CompGenerator.ts index 012a97f5..5397c0fc 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/CompGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/CompGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type DependencyProp, type CompParticle, type ViewParticle } from '@inula/reactivity-parser'; +import { type DependencyProp, type CompParticle, type ViewParticle } from '@openinula/reactivity-parser'; import ForwardPropGenerator from '../HelperGenerators/ForwardPropGenerator'; export default class CompGenerator extends ForwardPropGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/EnvGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/EnvGenerator.ts index ce2299ac..66819be8 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/EnvGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/EnvGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type ViewParticle, type DependencyProp, type EnvParticle } from '@inula/reactivity-parser'; +import { type ViewParticle, type DependencyProp, type EnvParticle } from '@openinula/reactivity-parser'; import PropViewGenerator from '../HelperGenerators/PropViewGenerator'; export default class EnvGenerator extends PropViewGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/ExpGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/ExpGenerator.ts index b9781b97..ece38f09 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/ExpGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/ExpGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type ExpParticle } from '@inula/reactivity-parser'; +import { type ExpParticle } from '@openinula/reactivity-parser'; import ElementGenerator from '../HelperGenerators/ElementGenerator'; import { DLError } from '../error'; diff --git a/packages/transpiler/view-generator/src/NodeGenerators/ForGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/ForGenerator.ts index 5daa289b..e172c703 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/ForGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/ForGenerator.ts @@ -1,6 +1,6 @@ import { type types as t } from '@babel/core'; import BaseGenerator from '../HelperGenerators/BaseGenerator'; -import { type ForParticle, type ViewParticle } from '@inula/reactivity-parser'; +import { type ForParticle, type ViewParticle } from '@openinula/reactivity-parser'; export default class ForGenerator extends BaseGenerator { run() { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/HTMLGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/HTMLGenerator.ts index ea8c4b99..d6ff33e8 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/HTMLGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/HTMLGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type HTMLParticle } from '@inula/reactivity-parser'; +import { type HTMLParticle } from '@openinula/reactivity-parser'; import HTMLPropGenerator from '../HelperGenerators/HTMLPropGenerator'; export default class HTMLGenerator extends HTMLPropGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/IfGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/IfGenerator.ts index 000b4f16..5ab4df35 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/IfGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/IfGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type IfParticle, type IfBranch } from '@inula/reactivity-parser'; +import { type IfParticle, type IfBranch } from '@openinula/reactivity-parser'; import CondGenerator from '../HelperGenerators/CondGenerator'; export default class IfGenerator extends CondGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/SnippetGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/SnippetGenerator.ts index bc024215..bfde45b7 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/SnippetGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/SnippetGenerator.ts @@ -1,4 +1,4 @@ -import { type DependencyProp, type SnippetParticle } from '@inula/reactivity-parser'; +import { type DependencyProp, type SnippetParticle } from '@openinula/reactivity-parser'; import type { types as t } from '@babel/core'; import PropViewGenerator from '../HelperGenerators/PropViewGenerator'; diff --git a/packages/transpiler/view-generator/src/NodeGenerators/SwitchGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/SwitchGenerator.ts index 47d1d549..e1d5dc01 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/SwitchGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/SwitchGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { SwitchBranch, SwitchParticle } from '@inula/reactivity-parser'; +import { SwitchBranch, SwitchParticle } from '@openinula/reactivity-parser'; import CondGenerator from '../HelperGenerators/CondGenerator'; export default class SwitchGenerator extends CondGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/TemplateGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/TemplateGenerator.ts index fcad6207..57096d47 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/TemplateGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/TemplateGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type HTMLParticle, type TemplateParticle } from '@inula/reactivity-parser'; +import { type HTMLParticle, type TemplateParticle } from '@openinula/reactivity-parser'; import HTMLPropGenerator from '../HelperGenerators/HTMLPropGenerator'; export default class TemplateGenerator extends HTMLPropGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/TextGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/TextGenerator.ts index 1b3d6d5c..b9fa1aa3 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/TextGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/TextGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type TextParticle } from '@inula/reactivity-parser'; +import { type TextParticle } from '@openinula/reactivity-parser'; import BaseGenerator from '../HelperGenerators/BaseGenerator'; export default class TextGenerator extends BaseGenerator { diff --git a/packages/transpiler/view-generator/src/NodeGenerators/TryGenerator.ts b/packages/transpiler/view-generator/src/NodeGenerators/TryGenerator.ts index 5d412e47..222bbda4 100644 --- a/packages/transpiler/view-generator/src/NodeGenerators/TryGenerator.ts +++ b/packages/transpiler/view-generator/src/NodeGenerators/TryGenerator.ts @@ -1,6 +1,6 @@ import { type types as t } from '@babel/core'; import BaseGenerator from '../HelperGenerators/BaseGenerator'; -import { TryParticle, type ViewParticle } from '@inula/reactivity-parser'; +import { TryParticle, type ViewParticle } from '@openinula/reactivity-parser'; export default class TryGenerator extends BaseGenerator { run() { diff --git a/packages/transpiler/view-generator/src/SnippetGenerator.ts b/packages/transpiler/view-generator/src/SnippetGenerator.ts index 708125d0..cb38013f 100644 --- a/packages/transpiler/view-generator/src/SnippetGenerator.ts +++ b/packages/transpiler/view-generator/src/SnippetGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type ViewParticle } from '@inula/reactivity-parser'; +import { type ViewParticle } from '@openinula/reactivity-parser'; import ViewGenerator from './ViewGenerator'; export default class SnippetGenerator extends ViewGenerator { diff --git a/packages/transpiler/view-generator/src/ViewGenerator.ts b/packages/transpiler/view-generator/src/ViewGenerator.ts index 9276bd7c..0f456148 100644 --- a/packages/transpiler/view-generator/src/ViewGenerator.ts +++ b/packages/transpiler/view-generator/src/ViewGenerator.ts @@ -1,5 +1,5 @@ import { type types as t } from '@babel/core'; -import { type ViewParticle } from '@inula/reactivity-parser'; +import { type ViewParticle } from '@openinula/reactivity-parser'; import { type ViewGeneratorConfig } from './types'; import BaseGenerator, { prefixMap } from './HelperGenerators/BaseGenerator'; import CompGenerator from './NodeGenerators/CompGenerator'; diff --git a/packages/transpiler/view-generator/src/error.ts b/packages/transpiler/view-generator/src/error.ts index 8c036f3e..e40b20a8 100644 --- a/packages/transpiler/view-generator/src/error.ts +++ b/packages/transpiler/view-generator/src/error.ts @@ -1,4 +1,4 @@ -import { createErrorHandler } from '@inula/error-handler'; +import { createErrorHandler } from '@openinula/error-handler'; export const DLError = createErrorHandler( 'ViewGenerator', diff --git a/packages/transpiler/view-generator/src/index.ts b/packages/transpiler/view-generator/src/index.ts index f1a52ed9..10e12c4b 100644 --- a/packages/transpiler/view-generator/src/index.ts +++ b/packages/transpiler/view-generator/src/index.ts @@ -1,4 +1,4 @@ -import { type ViewParticle } from '@inula/reactivity-parser'; +import { type ViewParticle } from '@openinula/reactivity-parser'; import { type ViewGeneratorConfig } from './types'; import { type types as t } from '@babel/core'; import MainViewGenerator from './MainViewGenerator'; diff --git a/packages/transpiler/view-parser/package.json b/packages/transpiler/view-parser/package.json index d5617a59..720518dc 100644 --- a/packages/transpiler/view-parser/package.json +++ b/packages/transpiler/view-parser/package.json @@ -1,5 +1,5 @@ { - "name": "@inula/view-parser", + "name": "@openinula/view-parser", "version": "0.0.1", "author": { "name": "IanDx", @@ -29,7 +29,7 @@ "vitest": "^0.34.5" }, "dependencies": { - "@inula/error-handler": "workspace:*" + "@openinula/error-handler": "workspace:*" }, "tsup": { "entry": [ diff --git a/packages/transpiler/view-parser/src/error.ts b/packages/transpiler/view-parser/src/error.ts index 0e80994d..b6557776 100644 --- a/packages/transpiler/view-parser/src/error.ts +++ b/packages/transpiler/view-parser/src/error.ts @@ -1,11 +1,11 @@ -import { createErrorHandler } from '@inula/error-handler'; +import { createErrorHandler } from '@openinula/error-handler'; export const DLError = createErrorHandler( 'ViewParser', { - 1: "Invalid syntax in DLight's View, only accepts dot chain call expression", + 1: 'Invalid syntax in DLight\'s View, only accepts dot chain call expression', 2: 'First argument of $0() must be an expression', - 3: "Invalid syntax in DLight's View, only accepts expression as props", + 3: 'Invalid syntax in DLight\'s View, only accepts expression as props', 4: 'Invalid Snippet calling, only accepts static snippet calling like `this.Snippet()`', }, { -- Gitee From 1f4b16495248227ab0efb91238a3a04af9c5c09e Mon Sep 17 00:00:00 2001 From: iandxssxx Date: Tue, 9 Apr 2024 21:58:08 -0400 Subject: [PATCH 6/6] refactor: publish new version --- .changeset/config.json | 2 +- .changeset/nice-hairs-promise.md | 5 ----- demos/v2/CHANGELOG.md | 8 ++++++++ demos/v2/index.html | 2 +- demos/v2/package.json | 2 +- demos/v2/src/App.tsx | 20 +------------------ demos/v2/vite.config.ts | 2 +- .../babel-preset-inula-next/CHANGELOG.md | 7 +++++++ .../babel-preset-inula-next/package.json | 2 +- .../vite-plugin-inula-next/CHANGELOG.md | 8 ++++++++ .../vite-plugin-inula-next/package.json | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 .changeset/nice-hairs-promise.md create mode 100644 demos/v2/CHANGELOG.md create mode 100644 packages/transpiler/babel-preset-inula-next/CHANGELOG.md create mode 100644 packages/transpiler/vite-plugin-inula-next/CHANGELOG.md diff --git a/.changeset/config.json b/.changeset/config.json index 37ed01cf..4369ffef 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "restricted", "baseBranch": "master", "updateInternalDependencies": "patch", - "ignore": [] + "ignore": ["create-inula", "openinula", "inula-cli", "inula-dev-tools", "inula-intl", "inula-request", "inula-router", "inula-vite-app", "inula-webpack-app"] } diff --git a/.changeset/nice-hairs-promise.md b/.changeset/nice-hairs-promise.md deleted file mode 100644 index 08fefbb1..00000000 --- a/.changeset/nice-hairs-promise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"babel-preset-inula-next": patch ---- - -feat: change babel import diff --git a/demos/v2/CHANGELOG.md b/demos/v2/CHANGELOG.md new file mode 100644 index 00000000..03fce107 --- /dev/null +++ b/demos/v2/CHANGELOG.md @@ -0,0 +1,8 @@ +# dev + +## 0.0.1 + +### Patch Changes + +- Updated dependencies [2f9d373] + - babel-preset-inula-next@0.0.2 diff --git a/demos/v2/index.html b/demos/v2/index.html index 28fb9622..31a50a25 100644 --- a/demos/v2/index.html +++ b/demos/v2/index.html @@ -7,6 +7,6 @@
- + diff --git a/demos/v2/package.json b/demos/v2/package.json index cfc37a65..49f310fd 100644 --- a/demos/v2/package.json +++ b/demos/v2/package.json @@ -1,7 +1,7 @@ { "name": "dev", "private": true, - "version": "0.0.0", + "version": "0.0.1", "type": "module", "scripts": { "dev": "vite", diff --git a/demos/v2/src/App.tsx b/demos/v2/src/App.tsx index 7e06b3c1..e59b4882 100644 --- a/demos/v2/src/App.tsx +++ b/demos/v2/src/App.tsx @@ -1,20 +1,4 @@ -// @ts-nocheck -import { - Children, - Content, - Main, - Model, - Prop, - View, - Watch, - button, - div, - input, - insertChildren, - use, - render, -} from '@openinula/next'; - +import { View, render } from '@openinula/next'; function MyComp() { let count = 0; @@ -30,6 +14,4 @@ function MyComp() { ); } - - render('main', MyComp); diff --git a/demos/v2/vite.config.ts b/demos/v2/vite.config.ts index 7029d548..b1f901d0 100644 --- a/demos/v2/vite.config.ts +++ b/demos/v2/vite.config.ts @@ -9,5 +9,5 @@ export default defineConfig({ optimizeDeps: { disabled: true, }, - plugins: [inula({ files: '**/*.{view,model}.{ts,js,tsx,jsx}', enableDevTools: true })], + plugins: [inula({ files: '**/*.{ts,js,tsx,jsx}' })], }); diff --git a/packages/transpiler/babel-preset-inula-next/CHANGELOG.md b/packages/transpiler/babel-preset-inula-next/CHANGELOG.md new file mode 100644 index 00000000..4ba791fd --- /dev/null +++ b/packages/transpiler/babel-preset-inula-next/CHANGELOG.md @@ -0,0 +1,7 @@ +# babel-preset-inula-next + +## 0.0.2 + +### Patch Changes + +- 2f9d373: feat: change babel import diff --git a/packages/transpiler/babel-preset-inula-next/package.json b/packages/transpiler/babel-preset-inula-next/package.json index 4f11f988..91a14b05 100644 --- a/packages/transpiler/babel-preset-inula-next/package.json +++ b/packages/transpiler/babel-preset-inula-next/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-inula-next", - "version": "0.0.1", + "version": "0.0.2", "author": { "name": "IanDx", "email": "iandxssxx@gmail.com" diff --git a/packages/transpiler/vite-plugin-inula-next/CHANGELOG.md b/packages/transpiler/vite-plugin-inula-next/CHANGELOG.md new file mode 100644 index 00000000..4571c28b --- /dev/null +++ b/packages/transpiler/vite-plugin-inula-next/CHANGELOG.md @@ -0,0 +1,8 @@ +# vite-plugin-inula-next + +## 0.0.2 + +### Patch Changes + +- Updated dependencies [2f9d373] + - babel-preset-inula-next@0.0.2 diff --git a/packages/transpiler/vite-plugin-inula-next/package.json b/packages/transpiler/vite-plugin-inula-next/package.json index b83d65bd..233837aa 100644 --- a/packages/transpiler/vite-plugin-inula-next/package.json +++ b/packages/transpiler/vite-plugin-inula-next/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-inula-next", - "version": "0.0.1", + "version": "0.0.2", "author": { "name": "IanDx", "email": "iandxssxx@gmail.com" -- Gitee