nesquick 0.0.9 → 0.0.11

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.
package/lib/For/For.js CHANGED
@@ -11,7 +11,7 @@ function renderChild(child, item, render) {
11
11
  child.setI = iState[1];
12
12
  return iState[0]();
13
13
  };
14
- child.element = render(item, () => getI());
14
+ child.component = render(item, () => getI());
15
15
  return child;
16
16
  }
17
17
  ;
@@ -94,18 +94,18 @@ function For(props) {
94
94
  id: id,
95
95
  i: i,
96
96
  setI: null,
97
- element: null,
97
+ component: null,
98
98
  cycle: cycle,
99
99
  childs: null
100
100
  }, item, props.children);
101
101
  map.pushChild(id, child);
102
102
  children.push(child);
103
- fragment.appendElement(child.element);
103
+ fragment.appendComponent(child.component);
104
104
  }
105
105
  }
106
106
  else if (each.length === 0) {
107
107
  for (let i = 0; i < children.length; i++) {
108
- fragment.removeElement(i);
108
+ fragment.removeComponent(i);
109
109
  }
110
110
  map.clearChilds();
111
111
  children.splice(0);
@@ -129,7 +129,7 @@ function For(props) {
129
129
  const oldChild = children[i];
130
130
  if (!map.equalsId(oldChild.id, id)) {
131
131
  if (oldChild.cycle !== cycle) {
132
- fragment.removeElement(i);
132
+ fragment.removeComponent(i);
133
133
  children.splice(i--, 1);
134
134
  map.popChild(oldChild);
135
135
  if (children.length < each.length) {
@@ -145,11 +145,11 @@ function For(props) {
145
145
  id: id,
146
146
  i: i,
147
147
  setI: null,
148
- element: null,
148
+ component: null,
149
149
  cycle: cycle,
150
150
  childs: null
151
151
  }, item, props.children);
152
- fragment.spliceElement(i, child.element);
152
+ fragment.spliceComponent(i, child.component);
153
153
  map.pushChild(id, child);
154
154
  children.splice(i, 0, child);
155
155
  if (children.length <= each.length) {
@@ -163,7 +163,7 @@ function For(props) {
163
163
  oldChild.i = child.i;
164
164
  child.i = i;
165
165
  child.setI?.(i);
166
- fragment.swapElements(oldChild.i + offset, child.i);
166
+ fragment.swapComponents(oldChild.i + offset, child.i);
167
167
  }
168
168
  }
169
169
  }
@@ -182,18 +182,18 @@ function For(props) {
182
182
  id: id,
183
183
  i: i,
184
184
  setI: null,
185
- element: null,
185
+ component: null,
186
186
  cycle: cycle,
187
187
  childs: null
188
188
  }, item, props.children);
189
189
  map.pushChild(id, child);
190
190
  children.push(child);
191
- fragment.appendElement(child.element);
191
+ fragment.appendComponent(child.component);
192
192
  }
193
193
  if (each.length < children.length) {
194
194
  for (let i = children.length - 1; i >= each.length; i--) {
195
195
  const oldChild = children[i];
196
- fragment.removeElement(i);
196
+ fragment.removeComponent(i);
197
197
  map.popChild(oldChild);
198
198
  }
199
199
  children.splice(each.length);
package/lib/Nesquick.js CHANGED
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Nesquick = void 0;
4
4
  var Nesquick;
5
5
  (function (Nesquick) {
6
- function render(element, parent) {
6
+ function render(component, parent) {
7
7
  if (parent != null) {
8
- parent.appendChild(element.render(parent.ownerDocument));
8
+ parent.appendChild(component.render(parent.ownerDocument));
9
9
  }
10
10
  else {
11
- document.body.appendChild(element.render(document));
11
+ document.body.appendChild(component.render(document));
12
12
  }
13
13
  }
14
14
  Nesquick.render = render;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NesquickElement = void 0;
3
+ exports.NesquickComponent = void 0;
4
4
  const State_1 = require("./State");
5
5
  function functionizeProps(props) {
6
6
  for (const k in props) {
@@ -10,7 +10,7 @@ function functionizeProps(props) {
10
10
  }
11
11
  }
12
12
  }
13
- class NesquickElement {
13
+ class NesquickComponent {
14
14
  constructor(_render, props) {
15
15
  this._render = _render;
16
16
  this.props = props;
@@ -60,7 +60,7 @@ class NesquickElement {
60
60
  children = [children];
61
61
  }
62
62
  for (const child of children) {
63
- if (child instanceof NesquickElement) {
63
+ if (child instanceof NesquickComponent) {
64
64
  this._renderChild(document, parent, this._pushChild(), child);
65
65
  }
66
66
  else if (typeof child === "function") {
@@ -78,7 +78,7 @@ class NesquickElement {
78
78
  _pushChild() {
79
79
  const nesquickChild = {
80
80
  node: null,
81
- element: null,
81
+ component: null,
82
82
  fragment: null
83
83
  };
84
84
  this._children.push(nesquickChild);
@@ -87,7 +87,7 @@ class NesquickElement {
87
87
  _spliceChild(i) {
88
88
  const nesquickChild = {
89
89
  node: null,
90
- element: null,
90
+ component: null,
91
91
  fragment: null
92
92
  };
93
93
  this._children.splice(i, 0, nesquickChild);
@@ -118,8 +118,8 @@ class NesquickElement {
118
118
  if (ch.node) {
119
119
  ch.node.parentNode?.removeChild(ch.node);
120
120
  }
121
- if (ch.element != null) {
122
- ch.element.dispose();
121
+ if (ch.component != null) {
122
+ ch.component.dispose();
123
123
  }
124
124
  else if (ch.fragment != null) {
125
125
  ch.fragment.dispose();
@@ -127,14 +127,14 @@ class NesquickElement {
127
127
  }
128
128
  }
129
129
  _renderChild(document, parent, nesquickChild, child) {
130
- if (nesquickChild.element != null) {
131
- nesquickChild.element.dispose();
130
+ if (nesquickChild.component != null) {
131
+ nesquickChild.component.dispose();
132
132
  }
133
133
  else if (nesquickChild.fragment != null) {
134
134
  nesquickChild.fragment.clear();
135
135
  }
136
136
  if (child instanceof NesquickFragment_1.NesquickFragment || Array.isArray(child)) {
137
- nesquickChild.element = null;
137
+ nesquickChild.component = null;
138
138
  nesquickChild.fragment = Array.isArray(child) ? new NesquickFragment_1.NesquickFragment(child) : child;
139
139
  const node = nesquickChild.fragment.render(document);
140
140
  const lastChild = node.lastChild;
@@ -146,8 +146,8 @@ class NesquickElement {
146
146
  }
147
147
  nesquickChild.node = lastChild;
148
148
  }
149
- else if (child instanceof NesquickElement) {
150
- nesquickChild.element = child;
149
+ else if (child instanceof NesquickComponent) {
150
+ nesquickChild.component = child;
151
151
  nesquickChild.fragment = null;
152
152
  const node = child.render(document);
153
153
  if (nesquickChild.node) {
@@ -160,8 +160,8 @@ class NesquickElement {
160
160
  }
161
161
  else {
162
162
  const value = child == null ? "" : String(child);
163
- if (nesquickChild.node == null || nesquickChild.element != null || nesquickChild.fragment != null) {
164
- nesquickChild.element = null;
163
+ if (nesquickChild.node == null || nesquickChild.component != null || nesquickChild.fragment != null) {
164
+ nesquickChild.component = null;
165
165
  nesquickChild.fragment = null;
166
166
  const node = document.createTextNode(value);
167
167
  if (nesquickChild.node) {
@@ -180,11 +180,11 @@ class NesquickElement {
180
180
  dispose() {
181
181
  this._subscriptions.dispose();
182
182
  for (const child of this._children) {
183
- if (child.element) {
184
- child.element.dispose();
183
+ if (child.component) {
184
+ child.component.dispose();
185
185
  }
186
186
  }
187
187
  }
188
188
  }
189
- exports.NesquickElement = NesquickElement;
189
+ exports.NesquickComponent = NesquickComponent;
190
190
  const NesquickFragment_1 = require("./NesquickFragment");
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NesquickFragment = void 0;
4
- const NesquickElement_1 = require("./NesquickElement");
5
- class NesquickFragment extends NesquickElement_1.NesquickElement {
4
+ const NesquickComponent_1 = require("./NesquickComponent");
5
+ class NesquickFragment extends NesquickComponent_1.NesquickComponent {
6
6
  constructor(children) {
7
7
  super("", { children });
8
8
  this._lastNode = null;
@@ -40,7 +40,7 @@ class NesquickFragment extends NesquickElement_1.NesquickElement {
40
40
  parent.insertBefore(node, child || this._lastNode);
41
41
  }
42
42
  }
43
- appendElement(child) {
43
+ appendComponent(child) {
44
44
  const document = this.getDocument();
45
45
  const parent = this.getParent();
46
46
  if (document && parent) {
@@ -51,16 +51,16 @@ class NesquickFragment extends NesquickElement_1.NesquickElement {
51
51
  this.props.children.push(child);
52
52
  }
53
53
  }
54
- swapElements(i1, i2) {
54
+ swapComponents(i1, i2) {
55
55
  const parent = this.getParent();
56
56
  if (parent) {
57
57
  this._swapChilds(parent, i1, i2);
58
58
  }
59
59
  }
60
- removeElement(i) {
60
+ removeComponent(i) {
61
61
  this._removeChild(i);
62
62
  }
63
- spliceElement(i, child) {
63
+ spliceComponent(i, child) {
64
64
  const document = this.getDocument();
65
65
  const parent = this.getParent();
66
66
  if (document && parent) {
package/lib/index.js CHANGED
@@ -19,4 +19,4 @@ __exportStar(require("./For/For"), exports);
19
19
  __exportStar(require("./cli/transformer"), exports);
20
20
  __exportStar(require("./State"), exports);
21
21
  __exportStar(require("./NesquickFragment"), exports);
22
- __exportStar(require("./NesquickElement"), exports);
22
+ __exportStar(require("./NesquickComponent"), exports);
@@ -17,10 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.jsxDEV = jsxDEV;
18
18
  const jsx_runtime_1 = require("./jsx-runtime");
19
19
  __exportStar(require("./jsx-runtime"), exports);
20
- function jsxDEV(type, props, key, _isStaticChildren, source, self) {
21
- return (0, jsx_runtime_1.jsx)(type, {
22
- ...props,
23
- __source: source,
24
- __self: self
25
- }, key);
20
+ function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
21
+ return (0, jsx_runtime_1.jsx)(type, props, key);
26
22
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JSX = exports.jsx = exports.Fragment = void 0;
4
4
  exports.jsxs = jsxs;
5
- const NesquickElement_1 = require("./NesquickElement");
5
+ const NesquickComponent_1 = require("./NesquickComponent");
6
6
  const NesquickFragment_1 = require("./NesquickFragment");
7
7
  exports.Fragment = Symbol();
8
8
  function jsxs(type, props, key) {
@@ -12,7 +12,7 @@ function jsxs(type, props, key) {
12
12
  if (key !== undefined) {
13
13
  props.key = key;
14
14
  }
15
- return new NesquickElement_1.NesquickElement(type, props);
15
+ return new NesquickComponent_1.NesquickComponent(type, props);
16
16
  }
17
17
  exports.jsx = jsxs;
18
18
  var JSX;
@@ -1,6 +1,6 @@
1
- import { NesquickElement, Children, Child } from "./NesquickElement";
1
+ import { NesquickComponent, Children, Child } from "./NesquickComponent";
2
2
  export declare namespace Nesquick {
3
- function render(element: NesquickElement<any>, parent?: HTMLElement | null): void;
3
+ function render(component: NesquickComponent<any>, parent?: HTMLElement | null): void;
4
4
  }
5
5
  export { Children, Child };
6
6
  export default Nesquick;
@@ -1,15 +1,15 @@
1
- export type Child = NesquickElement<any> | NesquickFragment | string | boolean | number | null | undefined | ChildFunc;
1
+ export type Child = NesquickComponent<any> | NesquickFragment | string | boolean | number | null | undefined | ChildFunc;
2
2
  export type Children = Child | Child[];
3
3
  export type ChildFunc = () => Exclude<Child, ChildFunc> | Exclude<Child, ChildFunc>[];
4
- export type Props = Record<string, any>;
5
- export type FunctionComponent<P extends Props = {}> = (props: P) => NesquickElement<P>;
4
+ export type ComponentProps = Record<string, any>;
5
+ export type FunctionComponent<P extends ComponentProps = {}> = (props: P) => NesquickComponent<P>;
6
6
  type NesquickChild = {
7
7
  node: Node | null;
8
8
  } & ({
9
- element: NesquickElement | null;
9
+ component: NesquickComponent | null;
10
10
  fragment: null;
11
11
  } | {
12
- element: null;
12
+ component: null;
13
13
  fragment: NesquickFragment | null;
14
14
  });
15
15
  export type NesquickParent = {
@@ -17,7 +17,7 @@ export type NesquickParent = {
17
17
  replaceChild(newChild: Node, oldChild: Node): void;
18
18
  insertBefore(node: Node, child: Node | null): void;
19
19
  };
20
- export declare class NesquickElement<P extends Props = {}> {
20
+ export declare class NesquickComponent<P extends ComponentProps = {}> {
21
21
  private _render;
22
22
  protected props: P;
23
23
  private _subscriptions;
@@ -1,6 +1,6 @@
1
1
  import { JSX } from "./jsx-runtime";
2
- import { NesquickElement, NesquickParent } from "./NesquickElement";
3
- export declare class NesquickFragment extends NesquickElement<{
2
+ import { NesquickComponent, NesquickParent } from "./NesquickComponent";
3
+ export declare class NesquickFragment extends NesquickComponent<{
4
4
  children: any[];
5
5
  }> implements NesquickParent {
6
6
  private _lastNode;
@@ -12,9 +12,9 @@ export declare class NesquickFragment extends NesquickElement<{
12
12
  appendChild(child: Node): void;
13
13
  replaceChild(newChild: Node, oldChild: Node): void;
14
14
  insertBefore(node: Node, child: Node | null): void;
15
- appendElement(child: JSX.Element): void;
16
- swapElements(i1: number, i2: number): void;
17
- removeElement(i: number): void;
18
- spliceElement(i: number, child: JSX.Element): void;
15
+ appendComponent(child: JSX.Element): void;
16
+ swapComponents(i1: number, i2: number): void;
17
+ removeComponent(i: number): void;
18
+ spliceComponent(i: number, child: JSX.Element): void;
19
19
  clear(): void;
20
20
  }
@@ -3,4 +3,4 @@ export * from "./For/For";
3
3
  export * from "./cli/transformer";
4
4
  export * from "./State";
5
5
  export * from "./NesquickFragment";
6
- export * from "./NesquickElement";
6
+ export * from "./NesquickComponent";
@@ -1,9 +1,9 @@
1
1
  import { Fragment } from "./jsx-runtime";
2
- import { FunctionComponent, Props } from "./NesquickElement";
2
+ import { FunctionComponent, ComponentProps } from "./NesquickComponent";
3
3
  export * from "./jsx-runtime";
4
4
  type JsxSource = {
5
5
  fileName: string;
6
6
  lineNumber: number;
7
7
  columnNumber?: number;
8
8
  };
9
- export declare function jsxDEV<P extends Props>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key: string | number | null, _isStaticChildren: boolean, source: JsxSource, self: any): import("./NesquickFragment").NesquickFragment | import("./NesquickElement").NesquickElement<P>;
9
+ export declare function jsxDEV<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key: string | number | null, _isStaticChildren: boolean, _source: JsxSource, _self: any): import("./NesquickFragment").NesquickFragment | import("./NesquickComponent").NesquickComponent<P>;
@@ -1,7 +1,7 @@
1
- import { FunctionComponent, Props, NesquickElement } from "./NesquickElement";
1
+ import { FunctionComponent, ComponentProps, NesquickComponent } from "./NesquickComponent";
2
2
  import { NesquickFragment } from "./NesquickFragment";
3
3
  export declare const Fragment: unique symbol;
4
- export declare function jsxs<P extends Props>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickElement<P>;
4
+ export declare function jsxs<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickComponent<P>;
5
5
  export declare const jsx: typeof jsxs;
6
6
  declare const WrappedFunctionType: unique symbol;
7
7
  type WrappedFunction<T> = (() => T) & {
@@ -17,7 +17,7 @@ type UnFunction<T> = T extends {
17
17
  type UserProps<T> = {
18
18
  [K in keyof T]: K extends "children" ? T[K] : UserProp<T[K]>;
19
19
  };
20
- type ComponentProps<T> = keyof T extends never ? {} : {
20
+ type JSXProps<T> = keyof T extends never ? {} : {
21
21
  [K in keyof T]: K extends "children" ? UnFunction<T[K]> : ComponentProp<T[K]>;
22
22
  };
23
23
  export type Generic<T> = T extends (...args: any) => infer R ? R : T;
@@ -47,10 +47,10 @@ export declare namespace JSX {
47
47
  } & {
48
48
  [K in keyof SVGElementTagNameMap]: SVGProps<SVGElementTagNameMap[K]>;
49
49
  };
50
- export type Element = NesquickElement<any>;
50
+ export type Element = NesquickComponent<any>;
51
51
  export interface IntrinsicElements extends JSXElements {
52
52
  }
53
- export type ElementType = keyof IntrinsicElements | Component<any> | typeof NesquickElement<any>;
53
+ export type ElementType = keyof IntrinsicElements | Component<any> | typeof NesquickComponent<any>;
54
54
  const NotEmptyObject: unique symbol;
55
55
  export type IntrinsicAttributes = {
56
56
  [NotEmptyObject]?: typeof NotEmptyObject;
@@ -61,6 +61,6 @@ export declare namespace JSX {
61
61
  export interface ElementChildrenAttribute {
62
62
  children: {};
63
63
  }
64
- export type LibraryManagedAttributes<_, P> = ComponentProps<P>;
64
+ export type LibraryManagedAttributes<_, P> = JSXProps<P>;
65
65
  export {};
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nesquick",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "React-like library with focus on drawing performance",
5
5
  "types": "./lib/types",
6
6
  "main": "./lib",