oxiui-lib 0.2.3 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write # VERY IMPORTANT
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ environment: production
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - uses: oven-sh/setup-bun@v1
21
+ with:
22
+ bun-version: latest
23
+
24
+ - uses: actions/setup-node@v4
25
+ with:
26
+ node-version: "24"
27
+ registry-url: "https://registry.npmjs.org"
28
+
29
+ - run: bun install
30
+ - run: bun run build
31
+ - run: npm publish
@@ -1,4 +1,4 @@
1
- declare const DivContainer_base: {
1
+ declare const ContainerState_base: {
2
2
  new (props?: import("../types/html.js").CommonProps | undefined): {
3
3
  "__#private@#__states": Map<string | symbol, import("../signals.js").Signal<unknown>>;
4
4
  type: "div";
@@ -16,6 +16,6 @@ declare const DivContainer_base: {
16
16
  withState(): /*elided*/ any;
17
17
  };
18
18
  };
19
- export declare class DivContainer extends DivContainer_base {
19
+ export declare class ContainerState extends ContainerState_base {
20
20
  }
21
21
  export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DivContainer = void 0;
3
+ exports.ContainerState = void 0;
4
4
  const OxiComponent_js_1 = require("./OxiComponent.js");
5
- class DivContainer extends (0, OxiComponent_js_1.intrinsic)("div") {
5
+ class ContainerState extends (0, OxiComponent_js_1.intrinsicState)("div") {
6
6
  }
7
- exports.DivContainer = DivContainer;
7
+ exports.ContainerState = ContainerState;
@@ -1,8 +1,8 @@
1
- import type { DivContainer } from "./elements";
1
+ import type { ContainerState } from "./elements";
2
2
  import type { IComponent } from "./types/component";
3
3
  import type { IntrinsicElements } from "./types/html";
4
4
  type RenderCallback = (stateId: string, readers: Set<string>, root: IComponent<keyof IntrinsicElements>) => void;
5
- export declare function initScheduler(App: new () => DivContainer, renderer: RenderCallback): void;
5
+ export declare function initScheduler(App: new () => ContainerState, renderer: RenderCallback): void;
6
6
  export declare function scheduleEffect(fn: () => void): void;
7
7
  export declare function rerender(stateId: string, readers: Set<string>): void;
8
8
  export declare function startImmediateMode(): void;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "oxiui-lib",
3
- "version": "0.2.3",
3
+ "version": "0.2.16",
4
4
  "module": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
+ "repository": "https://github.com/pedromigueldev/oxiui-lib",
8
9
  "scripts": {
9
10
  "build": "tsc",
10
11
  "biome": "biome format . --write"
@@ -1,3 +1,3 @@
1
- import { intrinsic } from "./OxiComponent.js";
1
+ import { intrinsicState } from "./OxiComponent.js";
2
2
 
3
- export class DivContainer extends intrinsic("div") {}
3
+ export class ContainerState extends intrinsicState("div") {}
@@ -1,4 +1,4 @@
1
- import type { DivContainer } from "./elements";
1
+ import type { ContainerState } from "./elements";
2
2
  import { resetCursor } from "./renderer";
3
3
  import type { IComponent } from "./types/component";
4
4
  import type { IntrinsicElements } from "./types/html";
@@ -10,7 +10,7 @@ type RenderCallback = (
10
10
  ) => void;
11
11
 
12
12
  let running = false;
13
- let app: DivContainer | null = null;
13
+ let app: ContainerState | null = null;
14
14
  let renderCallback: RenderCallback | null = null;
15
15
  const postRenderQueue: (() => void)[] = [];
16
16
  const resetTree = () => {
@@ -20,7 +20,7 @@ const resetTree = () => {
20
20
  };
21
21
 
22
22
  export function initScheduler(
23
- App: new () => DivContainer,
23
+ App: new () => ContainerState,
24
24
  renderer: RenderCallback,
25
25
  ) {
26
26
  app = new App();
@@ -1,36 +0,0 @@
1
- import { Signal } from "../signals.js";
2
- import type { IComponent, StyleProp } from "../types/component.js";
3
- import { type IntrinsicElements } from "../types/html.js";
4
- export declare abstract class AbaComponent<K extends keyof IntrinsicElements> implements IComponent<K> {
5
- #private;
6
- type: K;
7
- props: IntrinsicElements[K];
8
- up?: IComponent<keyof IntrinsicElements>;
9
- down: IComponent<keyof IntrinsicElements>[];
10
- cursors: Set<string>;
11
- index: string;
12
- view?: (() => void) | undefined;
13
- constructor(type: K, props?: IntrinsicElements[K]);
14
- body(fn?: (component: this) => void): this;
15
- onAppear(fn: (component: this) => void): this;
16
- withProps<T extends Partial<IntrinsicElements[K]>>(newProps: T): this;
17
- withStyle(style: StyleProp<IntrinsicElements[K]>): this;
18
- withExtension(extension: (component: this) => void): this;
19
- }
20
- export declare function intrinsic<K extends keyof IntrinsicElements>(type: K): {
21
- new (props?: IntrinsicElements[K]): {
22
- "__#private@#__states": Map<string | symbol, Signal<any>>;
23
- type: K;
24
- props: IntrinsicElements[K];
25
- up?: IComponent<keyof IntrinsicElements>;
26
- down: IComponent<keyof IntrinsicElements>[];
27
- cursors: Set<string>;
28
- index: string;
29
- view?: (() => void) | undefined;
30
- body(fn?: ((component: /*elided*/ any) => void) | undefined): /*elided*/ any;
31
- onAppear(fn: (component: /*elided*/ any) => void): /*elided*/ any;
32
- withProps<T extends Partial<IntrinsicElements[K]>>(newProps: T): /*elided*/ any;
33
- withStyle(style: StyleProp<IntrinsicElements[K]>): /*elided*/ any;
34
- withExtension(extension: (component: /*elided*/ any) => void): /*elided*/ any;
35
- };
36
- };
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var _AbaComponent___states;
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AbaComponent = void 0;
10
- exports.intrinsic = intrinsic;
11
- const scheduler_js_1 = require("../scheduler.js");
12
- const signals_js_1 = require("../signals.js");
13
- const tree_js_1 = require("../tree.js");
14
- class AbaComponent {
15
- constructor(type, props) {
16
- _AbaComponent___states.set(this, new Map());
17
- this.down = [];
18
- this.cursors = new Set();
19
- const parent = (0, tree_js_1.current)();
20
- this.type = type;
21
- this.props = props !== null && props !== void 0 ? props : {};
22
- this.up = parent;
23
- const position = parent ? parent.down.length : 0;
24
- this.index = parent ? `${parent.index}.${position}` : "0";
25
- parent === null || parent === void 0 ? void 0 : parent.down.push(this);
26
- return new Proxy(this, {
27
- get: (target, prop, receiver) => {
28
- if (prop.toString().startsWith("$")) {
29
- let signal = __classPrivateFieldGet(target, _AbaComponent___states, "f").get(prop);
30
- if (!signal) {
31
- (0, tree_js_1.open)(target);
32
- signal = new signals_js_1.Signal(Reflect.get(target, prop, receiver));
33
- __classPrivateFieldGet(target, _AbaComponent___states, "f").set(prop, signal);
34
- (0, tree_js_1.close)();
35
- }
36
- return signal.value;
37
- }
38
- return Reflect.get(target, prop, receiver);
39
- },
40
- set: (target, prop, value, receiver) => {
41
- if (prop.toString().startsWith("$")) {
42
- let signal = __classPrivateFieldGet(target, _AbaComponent___states, "f").get(prop);
43
- (0, tree_js_1.open)(target);
44
- if (!signal) {
45
- signal = new signals_js_1.Signal(value);
46
- __classPrivateFieldGet(target, _AbaComponent___states, "f").set(prop, signal);
47
- }
48
- else {
49
- signal.value = value;
50
- }
51
- (0, tree_js_1.close)();
52
- return true;
53
- }
54
- return Reflect.set(target, prop, value, receiver);
55
- },
56
- });
57
- }
58
- body(fn) {
59
- (0, tree_js_1.open)(this);
60
- if (this.view) {
61
- this.view();
62
- }
63
- else {
64
- fn === null || fn === void 0 ? void 0 : fn(this);
65
- }
66
- (0, tree_js_1.close)();
67
- return this;
68
- }
69
- onAppear(fn) {
70
- (0, tree_js_1.open)(this);
71
- (0, scheduler_js_1.scheduleEffect)(() => fn(this));
72
- (0, tree_js_1.close)();
73
- return this;
74
- }
75
- withProps(newProps) {
76
- (0, tree_js_1.open)(this);
77
- this.props = { ...this.props, ...newProps };
78
- (0, tree_js_1.close)();
79
- return this;
80
- }
81
- withStyle(style) {
82
- (0, tree_js_1.open)(this);
83
- const currentStyle = this.props.style;
84
- if (typeof style === "object" && typeof currentStyle === "object") {
85
- this.props = {
86
- ...this.props,
87
- style: { ...currentStyle, ...style },
88
- };
89
- }
90
- else {
91
- this.props = {
92
- ...this.props,
93
- style,
94
- };
95
- }
96
- (0, tree_js_1.close)();
97
- return this;
98
- }
99
- withExtension(extension) {
100
- (0, tree_js_1.open)(this);
101
- extension(this);
102
- (0, tree_js_1.close)();
103
- return this;
104
- }
105
- }
106
- exports.AbaComponent = AbaComponent;
107
- _AbaComponent___states = new WeakMap();
108
- function intrinsic(type) {
109
- return class extends AbaComponent {
110
- constructor(props) {
111
- super(type, props);
112
- }
113
- };
114
- }
@@ -1,20 +0,0 @@
1
- declare const DivContainer_base: {
2
- new (props?: import("../types/html.js").CommonProps | undefined): {
3
- "__#private@#__states": Map<string | symbol, import("../signals.js").Signal<any>>;
4
- type: "div";
5
- props: import("../types/html.js").CommonProps;
6
- up?: import("../types/component.js").IComponent<keyof import("../types/html.js").IntrinsicElements>;
7
- down: import("../types/component.js").IComponent<keyof import("../types/html.js").IntrinsicElements>[];
8
- cursors: Set<string>;
9
- index: string;
10
- view?: (() => void) | undefined;
11
- body(fn?: ((component: /*elided*/ any) => void) | undefined): /*elided*/ any;
12
- onAppear(fn: (component: /*elided*/ any) => void): /*elided*/ any;
13
- withProps<T extends Partial<import("../types/html.js").CommonProps>>(newProps: T): /*elided*/ any;
14
- withStyle(style: Partial<CSSStyleDeclaration>): /*elided*/ any;
15
- withExtension(extension: (component: /*elided*/ any) => void): /*elided*/ any;
16
- };
17
- };
18
- export declare class DivContainer extends DivContainer_base {
19
- }
20
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DivContainer = void 0;
4
- const AbaComponent_js_1 = require("./AbaComponent.js");
5
- class DivContainer extends (0, AbaComponent_js_1.intrinsic)("div") {
6
- }
7
- exports.DivContainer = DivContainer;