Skip to content

Commit

Permalink
去掉了Ui前缀;修复了无法在ap中导入的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tobylai-toby committed Sep 21, 2024
1 parent 0e7b006 commit 3373960
Show file tree
Hide file tree
Showing 14 changed files with 13,108 additions and 62 deletions.
1 change: 1 addition & 0 deletions dist/cjs/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions dist/index.cjs → dist/cjs/index.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/components.cjs

This file was deleted.

8 changes: 4 additions & 4 deletions dist/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ interface UiTextOpt extends UiRenderableOpt {
autoWordWrap?: boolean | string;
textLineHeight?: number | string;
}
export declare function UiText(opt: UiTextOpt & {
export declare function Text(opt: UiTextOpt & {
children?: any;
}): any;
interface UiBoxOpt extends UiRenderableOpt {
}
export declare function UiBox(opt: UiBoxOpt & {
export declare function Box(opt: UiBoxOpt & {
children?: any;
}): any;
interface UiImageOpt extends UiRenderableOpt {
image?: string;
imageOpacity?: number | string;
}
export declare function UiImage(opt: UiImageOpt & {
export declare function Image(opt: UiImageOpt & {
children?: any;
}): any;
interface UiInputOpt extends UiTextOpt {
Expand All @@ -44,7 +44,7 @@ interface UiInputOpt extends UiTextOpt {
focus?: string | boolean;
onInput?: (e: any) => void;
}
export declare function UiInput(opt: UiInputOpt & {
export declare function Input(opt: UiInputOpt & {
children?: any;
}): any;
export {};
1 change: 0 additions & 1 deletion dist/components.mjs

This file was deleted.

1 change: 1 addition & 0 deletions dist/esm/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions dist/index.mjs → dist/esm/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h } from "preact";
export declare const html: (strings: TemplateStringsArray, ...values: any[]) => import("preact").VNode<import("preact").Attributes> | import("preact").VNode<import("preact").Attributes>[];
export declare const document: Document;
export declare const document: any;
export declare class AreactApp {
root: HTMLElement;
uiNode: UiNode;
Expand Down
5 changes: 3 additions & 2 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const defaults = {
minify: true,
outdir: "dist/",
platform: "browser",
treeShaking: true,
}
async function build(opt) {
for (let i = 0; i < entryPoints.length; i++) {
Expand All @@ -36,12 +37,12 @@ async function build(opt) {
console.log("Building CommonJS");
await build({
format: "cjs",
outExtension: { ".js": ".cjs" }
outdir: "dist/cjs",
});
console.log("Building ESM");
await build({
format: "esm",
outExtension: { ".js": ".mjs" }
outdir: "dist/esm",
});
console.log("Building CommonJS DTS")
buildDts(entryPoints, "dist/");
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
"version": "0.0.1-alpha",
"description": "React-like UI programming in Dao3.fun(Arena)",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"

"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./components": {
"types": "./dist/components.d.ts",
"import": "./dist/components.mjs",
"require": "./dist/components.cjs"
"import": "./dist/esm/components.js",
"require": "./dist/cjs/components.js"
},
"./*": [
"./*",
Expand Down Expand Up @@ -57,4 +56,4 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}
}
10 changes: 5 additions & 5 deletions src/components.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AreactApp } from ".";
import { AreactApp } from "./index.js";

let ui_case_switch_props:Record<string,Record<string,string>>={};
let comp_prop_dat=AreactApp.initUiComponents();
Expand Down Expand Up @@ -59,13 +59,13 @@ interface UiTextOpt extends UiRenderableOpt {
textLineHeight?: number | string;
}

export function UiText(opt:UiTextOpt&{children?:any}){
export function Text(opt:UiTextOpt&{children?:any}){
// @ts-ignore
return <ui-text {...toArgs(opt,"text")}>{toChildren(opt)}</ui-text>
}

interface UiBoxOpt extends UiRenderableOpt {}
export function UiBox(opt:UiBoxOpt&{children?:any}){
export function Box(opt:UiBoxOpt&{children?:any}){
// @ts-ignore
return <ui-box {...toArgs(opt,"box")}>{toChildren(opt)}</ui-box>
}
Expand All @@ -75,7 +75,7 @@ interface UiImageOpt extends UiRenderableOpt {
imageOpacity?: number | string;
}

export function UiImage(opt:UiImageOpt&{children?:any}){
export function Image(opt:UiImageOpt&{children?:any}){
// @ts-ignore
return <ui-image {...toArgs(opt,"image")}>{toChildren(opt)}</ui-image>
}
Expand All @@ -88,7 +88,7 @@ interface UiInputOpt extends UiTextOpt {
onInput?: (e:any)=>void;
}

export function UiInput(opt:UiInputOpt&{children?:any}){
export function Input(opt:UiInputOpt&{children?:any}){
// @ts-ignore
return <ui-input {...toArgs(opt,"input")}>{toChildren(opt)}</ui-input>
}
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
globalThis.global = globalThis;
import { h, Fragment, render } from "preact";
globalThis.global = globalThis;import { h, Fragment, render } from "preact";
import Color from "color";
// @ts-ignore
import { parseHTML,Event } from "../mod-linkedom";
import { parseHTML } from "../mod-linkedom/esm";
import htm from 'htm';
export const html = htm.bind(h);

const parsed = parseHTML("<html><body></body></html>");
const {window}=parsed;
const {window,Event}=parsed;
export const { document } = parsed;
// @ts-ignore
globalThis.document = document;
globalThis.window = window;
// globalThis.window = window;
// @ts-ignore
if (globalThis.screenWidth === undefined) globalThis.screenWidth = 1200;
// @ts-ignore
Expand Down
12 changes: 6 additions & 6 deletions test.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { AreactApp, hooks } from "./src/index";
import { UiText,UiInput,UiBox,UiImage } from "./src/components";
import { Text,Input,Box,Image } from "./src/components";
let app = new AreactApp();

function App() {
const [name,setName]=hooks.useState("");
return (<>
<UiText x="0px" y="0px" height="50px" width="200px" text={"showing " + (name==""?"nothing":name)}
<Text x="0px" y="0px" height="50px" width="200px" text={"showing " + (name==""?"nothing":name)}
backgroundColor="#000000"
textColor="#ffffff"
backgroundOpacity="100%"
></UiText>
<UiInput x="0px" y="50px" width="200px" height="50px" placeholder="输入avatar.png"
></Text>
<Input x="0px" y="50px" width="200px" height="50px" placeholder="输入avatar.png"
onInput={(e)=>setName(e.target.getAttribute("text"))}
text={name}
></UiInput>
<UiImage x="0px" y="100px" width="200px" height="200px" image={"picture/"+name}></UiImage>
></Input>
<Image x="0px" y="100px" width="200px" height="200px" image={"picture/"+name}></Image>
</>);
}
app.mount(<App />, ui);
13,080 changes: 13,064 additions & 16 deletions testout.js

Large diffs are not rendered by default.

0 comments on commit 3373960

Please sign in to comment.