@potok-web-framework/core 0.6.0 → 0.9.0
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/dist/block.d.ts +12 -7
- package/dist/client/hydrate.d.ts +6 -0
- package/dist/client/potok-preload.d.ts +6 -0
- package/dist/client/utils/dom.d.ts +4 -0
- package/dist/client.mjs +108 -116
- package/dist/constants-Bxn0R4hW.mjs +34 -0
- package/dist/constants.d.ts +4 -2
- package/dist/css-BercB0Kp.mjs +8 -0
- package/dist/escape-from-script-tag-CRT2evI1.mjs +4 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/hmr.d.ts +2 -0
- package/dist/exports/index.d.ts +3 -3
- package/dist/exports/jsx-runtime.d.ts +2 -1
- package/dist/exports/server.d.ts +2 -1
- package/dist/exports/store.d.ts +2 -0
- package/dist/footer-scripts.d.ts +2 -0
- package/dist/fragment-CXNEPBWB.mjs +18 -0
- package/dist/get-component-instance-id-CP6LDtpX.mjs +97 -0
- package/dist/header-scripts.d.ts +2 -0
- package/dist/hmr/constants.d.ts +12 -0
- package/dist/hmr/register-component.d.ts +4 -0
- package/dist/hmr/register-style.d.ts +1 -0
- package/dist/hmr/registered-component.d.ts +1 -6
- package/dist/hmr/remove-style.d.ts +1 -0
- package/dist/hmr/utils.d.ts +0 -2
- package/dist/hmr.mjs +13 -41
- package/dist/html-element-DBut4UCf.mjs +31 -0
- package/dist/html-element.d.ts +9 -1
- package/dist/index.mjs +203 -130
- package/dist/is-pure-object-s_MkQp1w.mjs +4 -0
- package/dist/jsx-runtime.mjs +4 -4
- package/dist/lib-node-DyXPvvVQ.mjs +192 -0
- package/dist/lib-node.d.ts +6 -0
- package/dist/list.d.ts +3 -0
- package/dist/normalize-children-BWrn16R7.mjs +48 -0
- package/dist/prop-types.d.ts +232 -253
- package/dist/register-component-B92kGFqC.mjs +67 -0
- package/dist/serialization-qOayQbjE.mjs +108 -0
- package/dist/{bootstrap-app.d.ts → server/bootstrap-app.d.ts} +3 -4
- package/dist/{render-to-string.d.ts → server/render-to-string.d.ts} +1 -1
- package/dist/server-node.d.ts +1 -1
- package/dist/server.mjs +82 -1150
- package/dist/signals.d.ts +5 -0
- package/dist/store/create-store.d.ts +2 -0
- package/dist/store/http-extension.d.ts +26 -0
- package/dist/store/types.d.ts +40 -0
- package/dist/store.mjs +137 -0
- package/dist/text-node.d.ts +12 -0
- package/dist/types.d.ts +12 -18
- package/dist/utils/css.d.ts +2 -0
- package/dist/utils/deep-assign-object.d.ts +1 -0
- package/dist/utils/escape-from-script-tag.d.ts +1 -0
- package/dist/utils/escape-html.d.ts +1 -0
- package/dist/utils/get-component-instance-id.d.ts +2 -0
- package/dist/utils/is-pure-object.d.ts +1 -0
- package/dist/utils/merge-context.d.ts +2 -0
- package/dist/utils/normalize-array.d.ts +2 -0
- package/dist/utils/normalize-children.d.ts +2 -0
- package/dist/utils/serialization.d.ts +2 -0
- package/package.json +6 -5
- package/dist/constants-BOAOReQ3.mjs +0 -26
- package/dist/fragment-BahmURhz.mjs +0 -17
- package/dist/hmr/hmr-dev.d.ts +0 -9
- package/dist/html-element-Cm0RtMkT.mjs +0 -42
- package/dist/lib-scripts.d.ts +0 -2
- package/dist/lifecycle-4vjEuXGy.mjs +0 -57
- package/dist/portal-CbcYOHLv.mjs +0 -44
- package/dist/render-to-dom.d.ts +0 -8
- package/dist/store.d.ts +0 -26
- package/dist/text.d.ts +0 -5
- package/dist/utils-CAe_kbSH.mjs +0 -345
- package/dist/utils.d.ts +0 -11
package/dist/signals.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export type Disposer = {
|
|
|
22
22
|
effects: Set<Effect>;
|
|
23
23
|
dispose(): void;
|
|
24
24
|
};
|
|
25
|
+
export type Batch = {
|
|
26
|
+
effects: Set<Effect>;
|
|
27
|
+
add(effect: Effect): void;
|
|
28
|
+
run(): void;
|
|
29
|
+
};
|
|
25
30
|
export declare function getSignal<Value extends SignalValue>(value: Value): Signal<Value> | undefined;
|
|
26
31
|
export declare function isSignal<Value extends SignalValue>(value: Value): boolean;
|
|
27
32
|
export declare function createSignal<Value extends SignalValue>(value: Value): Value;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type HttpRequest<Params, Data> = {
|
|
2
|
+
execute(options: HttpRequestExecutionOptions<Params, Data>): void;
|
|
3
|
+
controller: AbortController;
|
|
4
|
+
isPending: boolean;
|
|
5
|
+
defaultData: Data;
|
|
6
|
+
data: Data;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
};
|
|
9
|
+
export type DefineRequestOptions<Params, Data> = {
|
|
10
|
+
getRequestInfo(params: Params): {
|
|
11
|
+
url: string;
|
|
12
|
+
} & RequestInit;
|
|
13
|
+
defaultData: Data;
|
|
14
|
+
};
|
|
15
|
+
type HttpRequestExecutionOptions<Params, Data> = {
|
|
16
|
+
params: Params;
|
|
17
|
+
onFulfilled?(data: Data): void;
|
|
18
|
+
onError?(error: Error): void;
|
|
19
|
+
};
|
|
20
|
+
export declare const httpExtension: () => {
|
|
21
|
+
api: {
|
|
22
|
+
defineRequest<Params, Data>(defineRequestOptions: DefineRequestOptions<Params, Data>): HttpRequest<Params, Data>;
|
|
23
|
+
};
|
|
24
|
+
onUnmounted: () => void;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PotokElement, WithChildren } from '../types';
|
|
2
|
+
export type State = Record<string, any>;
|
|
3
|
+
type StateOptions<P extends Props, E extends Extensions> = {
|
|
4
|
+
props: P;
|
|
5
|
+
extensions: ResolvedExtensions<E>;
|
|
6
|
+
};
|
|
7
|
+
export type Actions = Record<string, (...args: any[]) => any>;
|
|
8
|
+
type ActionsOptions<P extends Props, S extends State> = {
|
|
9
|
+
props: P;
|
|
10
|
+
state: S;
|
|
11
|
+
};
|
|
12
|
+
export type StoreExtensionOptions<P extends Props, S extends State, A extends Actions> = {
|
|
13
|
+
props: P;
|
|
14
|
+
state: S;
|
|
15
|
+
actions: A;
|
|
16
|
+
};
|
|
17
|
+
export type StoreExtension<A> = () => {
|
|
18
|
+
api: A;
|
|
19
|
+
onUnmounted?: () => void;
|
|
20
|
+
};
|
|
21
|
+
export type Extensions = Record<string, StoreExtension<any>>;
|
|
22
|
+
export type ResolvedExtensions<E extends Extensions> = {
|
|
23
|
+
[K in keyof E]: ReturnType<E[K]>["api"];
|
|
24
|
+
};
|
|
25
|
+
export type Props = Record<string, any>;
|
|
26
|
+
export type StoreInitiator<P extends Props, S extends State, E extends Extensions, A extends Actions> = {
|
|
27
|
+
state: (options: StateOptions<P, E>) => S;
|
|
28
|
+
extensions: E;
|
|
29
|
+
actions: (options: ActionsOptions<P, S>) => A;
|
|
30
|
+
};
|
|
31
|
+
export type Store<P extends Props, S extends State, A extends Actions> = {
|
|
32
|
+
provider(props: WithChildren<P>): PotokElement;
|
|
33
|
+
reader(props: {
|
|
34
|
+
children: (options: {
|
|
35
|
+
state: S;
|
|
36
|
+
actions: A;
|
|
37
|
+
}) => PotokElement;
|
|
38
|
+
}): PotokElement;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
package/dist/store.mjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { a as deepTrack, i as createSignal, l as LibBlock, n as batch, r as createEffect } from "./lib-node-DyXPvvVQ.mjs";
|
|
2
|
+
import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-BWrn16R7.mjs";
|
|
3
|
+
import { a as Lifecycle, o as LibContextReader, r as HMR_STATE_CACHE, t as getComponentInstanceId } from "./get-component-instance-id-CP6LDtpX.mjs";
|
|
4
|
+
import { t as isPureObject } from "./is-pure-object-s_MkQp1w.mjs";
|
|
5
|
+
var ContextProvider = class extends LibBlock {
|
|
6
|
+
constructor(e, t, n) {
|
|
7
|
+
super(), this.props = e, this.context = n, normalizeChildren(e.children).forEach((r, i) => {
|
|
8
|
+
this.children.push(r(mergeContext(n, {
|
|
9
|
+
parentBlock: this,
|
|
10
|
+
index: i,
|
|
11
|
+
contexts: { [t]: e.value }
|
|
12
|
+
})));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}, ContextConsumer = class extends LibBlock {
|
|
16
|
+
constructor(e, t, n) {
|
|
17
|
+
super(), this.props = e, this.context = n;
|
|
18
|
+
let r = n.contexts[t];
|
|
19
|
+
if (!r) throw Error("Контекст не найден");
|
|
20
|
+
normalizeArray(e.children).forEach((e, t) => {
|
|
21
|
+
this.children.push(e(r)(mergeContext(n, {
|
|
22
|
+
parentBlock: this,
|
|
23
|
+
index: t
|
|
24
|
+
})));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function createContext() {
|
|
29
|
+
let e = Symbol("context");
|
|
30
|
+
return {
|
|
31
|
+
provider(t) {
|
|
32
|
+
return function(n) {
|
|
33
|
+
return new ContextProvider(t, e, n);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
reader(t) {
|
|
37
|
+
return function(n) {
|
|
38
|
+
return new ContextConsumer(t, e, n);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function deepAssignObject(e, t) {
|
|
44
|
+
for (let n in t) {
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(t, n)) continue;
|
|
46
|
+
let r = t[n];
|
|
47
|
+
isPureObject(r) ? (isPureObject(e[n]) || (e[n] = {}), deepAssignObject(e[n], r)) : Array.isArray(r) ? (Array.isArray(e[n]) || (e[n] = []), e[n] = deepAssignObject(e[n], r)) : e[n] = r;
|
|
48
|
+
}
|
|
49
|
+
return e;
|
|
50
|
+
}
|
|
51
|
+
function createStore() {
|
|
52
|
+
return function(n) {
|
|
53
|
+
let a = createContext();
|
|
54
|
+
return {
|
|
55
|
+
provider(o) {
|
|
56
|
+
return LibContextReader({ children: (s) => {
|
|
57
|
+
let c = getComponentInstanceId(s), l = [], u = Object.entries(n.extensions).reduce((e, [t, n]) => {
|
|
58
|
+
let r = n();
|
|
59
|
+
return r.onUnmounted && l.push(r.onUnmounted), e[t] = r.api, e;
|
|
60
|
+
}, {}), d = s.states[c] ?? {}, f;
|
|
61
|
+
process.env.NODE_ENV === "development" && HMR_STATE_CACHE.has(c) ? f = HMR_STATE_CACHE.get(c).value : (f = createSignal(deepAssignObject(n.state({
|
|
62
|
+
props: o,
|
|
63
|
+
extensions: u
|
|
64
|
+
}), d)), process.env.NODE_ENV === "development" && HMR_STATE_CACHE.set(c, {
|
|
65
|
+
value: f,
|
|
66
|
+
isRemovable: !1
|
|
67
|
+
}));
|
|
68
|
+
let p = n.actions({
|
|
69
|
+
props: o,
|
|
70
|
+
state: f
|
|
71
|
+
}), m = Object.entries(p).reduce((e, [t, n]) => (e[t] = (...e) => batch(() => n.apply(p, e)), e), {});
|
|
72
|
+
return Lifecycle({
|
|
73
|
+
onMounted() {
|
|
74
|
+
if (process.env.NODE_ENV === "development") {
|
|
75
|
+
let e = HMR_STATE_CACHE.get(c);
|
|
76
|
+
e && (e.isRemovable = !1);
|
|
77
|
+
}
|
|
78
|
+
if (s.isServer) return createEffect(() => {
|
|
79
|
+
deepTrack(f), s.states[c] = f;
|
|
80
|
+
}, !0).dispose;
|
|
81
|
+
},
|
|
82
|
+
onUnmounted() {
|
|
83
|
+
if (l.forEach((e) => e()), process.env.NODE_ENV === "development") {
|
|
84
|
+
let e = HMR_STATE_CACHE.get(c);
|
|
85
|
+
e && (e.isRemovable = !0, setTimeout(() => {
|
|
86
|
+
e.isRemovable && HMR_STATE_CACHE.delete(c);
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
children: a.provider({
|
|
91
|
+
value: {
|
|
92
|
+
state: f,
|
|
93
|
+
actions: m
|
|
94
|
+
},
|
|
95
|
+
children: o.children
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
} });
|
|
99
|
+
},
|
|
100
|
+
reader(e) {
|
|
101
|
+
return a.reader({ children: (t) => e.children(t) });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const httpExtension = () => {
|
|
107
|
+
let e = [];
|
|
108
|
+
return {
|
|
109
|
+
api: { defineRequest(n) {
|
|
110
|
+
let r = createSignal({
|
|
111
|
+
execute(e) {
|
|
112
|
+
r.isPending = !0;
|
|
113
|
+
let t = n.getRequestInfo(e.params);
|
|
114
|
+
fetch(t.url, t).then((e) => e.json()).then((t) => {
|
|
115
|
+
e.onFulfilled?.(t), r.data = t;
|
|
116
|
+
}).catch((t) => {
|
|
117
|
+
e.onError?.(t), r.error = t;
|
|
118
|
+
}).finally(() => {
|
|
119
|
+
r.isPending = !1;
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
controller: new AbortController(),
|
|
123
|
+
isPending: !1,
|
|
124
|
+
defaultData: n.defaultData,
|
|
125
|
+
data: n.defaultData,
|
|
126
|
+
error: null
|
|
127
|
+
});
|
|
128
|
+
return e.push(r), r;
|
|
129
|
+
} },
|
|
130
|
+
onUnmounted: () => {
|
|
131
|
+
e.forEach((e) => {
|
|
132
|
+
e.controller.abort();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
export { createStore, httpExtension };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LibNode } from './lib-node';
|
|
2
|
+
import { LibContext, PotokElement } from './types';
|
|
3
|
+
export type LibTextNodeProps = {
|
|
4
|
+
text: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare class LibTextNode extends LibNode {
|
|
7
|
+
readonly props: LibTextNodeProps;
|
|
8
|
+
readonly context: LibContext;
|
|
9
|
+
constructor(props: LibTextNodeProps, context: LibContext);
|
|
10
|
+
isTextNode(): this is LibTextNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function text(props: LibTextNodeProps): PotokElement;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
import { LibBlock } from './block';
|
|
2
|
-
import {
|
|
3
|
-
import { LibHTMLElementEventMap, LibHTMLElementTagNameMap } from './prop-types';
|
|
4
|
-
import { LibTextProps } from './text';
|
|
2
|
+
import { LibNode } from './lib-node';
|
|
5
3
|
export type LibProps = Record<string, any>;
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
props: LibTextProps;
|
|
4
|
+
export type ModuleScript = {
|
|
5
|
+
path: string;
|
|
6
|
+
isLoaded: boolean;
|
|
10
7
|
};
|
|
11
|
-
export type LibHtmlElementNode<Tag extends keyof LibHTMLElementTagNameMap = keyof LibHTMLElementTagNameMap> = {
|
|
12
|
-
type: 'html-element';
|
|
13
|
-
context: LibContext;
|
|
14
|
-
props: LibHTMLElementProps<Tag>;
|
|
15
|
-
};
|
|
16
|
-
export type LibNode = LibTextNode | LibHtmlElementNode;
|
|
17
8
|
export type LibContext = {
|
|
18
9
|
parentBlock: LibBlock | null;
|
|
19
10
|
index: number;
|
|
20
|
-
insertNode(
|
|
21
|
-
updateTextNode(node: LibTextNode): void;
|
|
22
|
-
updateHtmlElementNodeProp(node: LibHtmlElementNode, key: string, value: unknown): void;
|
|
11
|
+
insertNode(node: LibNode): void;
|
|
23
12
|
removeNode(node: LibNode): void;
|
|
24
|
-
portals: Record<string, WithChildren<{}>[
|
|
13
|
+
portals: Record<string, WithChildren<{}>["children"]>;
|
|
14
|
+
preload: {
|
|
15
|
+
scripts: ModuleScript[];
|
|
16
|
+
addScripts(path: string[]): void;
|
|
17
|
+
};
|
|
18
|
+
states: Record<string, unknown>;
|
|
25
19
|
contexts: Record<symbol, Record<string, unknown>>;
|
|
26
|
-
listeners: Record<keyof LibHTMLElementEventMap, Map<HTMLElement, LibHTMLElementEventMap[keyof LibHTMLElementEventMap]>>;
|
|
27
20
|
isServer: boolean;
|
|
28
21
|
promises: Promise<unknown>[];
|
|
29
22
|
isHydrating: boolean;
|
|
30
23
|
};
|
|
31
24
|
export type PotokElement = (context: LibContext) => LibBlock;
|
|
32
25
|
export type MaybeArray<T> = T | T[];
|
|
26
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
33
27
|
export type Child = PotokElement | Child[] | string | number | null | undefined;
|
|
34
28
|
export type Children = MaybeArray<Child> | undefined;
|
|
35
29
|
export type WithChildren<Props extends Record<string, unknown>> = Props & {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepAssignObject<T extends Record<string, any>>(first: T, second: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeFromScriptTag(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeHtml(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPureObject(input: any): input is Record<string, any>;
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@potok-web-framework/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/exports/index.d.ts"
|
|
8
8
|
},
|
|
9
|
+
"./store": {
|
|
10
|
+
"import": "./dist/store.mjs",
|
|
11
|
+
"types": "./dist/exports/store.d.ts"
|
|
12
|
+
},
|
|
9
13
|
"./server": {
|
|
10
14
|
"import": "./dist/server.mjs",
|
|
11
15
|
"types": "./dist/exports/server.d.ts"
|
|
@@ -32,10 +36,7 @@
|
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/bun": "^1.3.6",
|
|
35
|
-
"
|
|
36
|
-
"fetch-to-node": "^2.1.0",
|
|
37
|
-
"klona": "^2.0.6",
|
|
38
|
-
"vite": "8.0.0-beta.10",
|
|
39
|
+
"vite": "8.0.0-beta.13",
|
|
39
40
|
"vite-plugin-dts": "^4.5.4"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const HTML_ELEMENT_STYLE_PX_PROPERTIES = new Set([
|
|
2
|
-
"width",
|
|
3
|
-
"height",
|
|
4
|
-
"top",
|
|
5
|
-
"left",
|
|
6
|
-
"right",
|
|
7
|
-
"bottom",
|
|
8
|
-
"margin",
|
|
9
|
-
"marginTop",
|
|
10
|
-
"marginBottom",
|
|
11
|
-
"marginLeft",
|
|
12
|
-
"marginRight",
|
|
13
|
-
"padding",
|
|
14
|
-
"paddingTop",
|
|
15
|
-
"paddingBottom",
|
|
16
|
-
"paddingLeft",
|
|
17
|
-
"paddingRight",
|
|
18
|
-
"fontSize",
|
|
19
|
-
"borderWidth",
|
|
20
|
-
"borderRadius",
|
|
21
|
-
"maxWidth",
|
|
22
|
-
"minWidth",
|
|
23
|
-
"maxHeight",
|
|
24
|
-
"minHeight"
|
|
25
|
-
]), CLIENT_ENTRY_FILE_NAME = "client";
|
|
26
|
-
export { HTML_ELEMENT_STYLE_PX_PROPERTIES as n, CLIENT_ENTRY_FILE_NAME as t };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { _ as LibBlock, i as normalizeChildren, n as mergeContext } from "./utils-CAe_kbSH.mjs";
|
|
2
|
-
var FragmentClass = class extends LibBlock {
|
|
3
|
-
constructor(e, n) {
|
|
4
|
-
super(), this.props = e, this.context = n, normalizeChildren(e.children).forEach((e, t) => {
|
|
5
|
-
this.children.push(e(mergeContext(n, {
|
|
6
|
-
parentBlock: this,
|
|
7
|
-
index: t
|
|
8
|
-
})));
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function fragment(e) {
|
|
13
|
-
return function(t) {
|
|
14
|
-
return new FragmentClass(e, t);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export { fragment as t };
|
package/dist/hmr/hmr-dev.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { _ as LibBlock, a as objectKeys, c as createEffect, i as normalizeChildren, n as mergeContext, t as extractListenersFromProps } from "./utils-CAe_kbSH.mjs";
|
|
2
|
-
var LibHTMLElement = class extends LibBlock {
|
|
3
|
-
constructor(e, t) {
|
|
4
|
-
super(), this.props = e, this.context = t;
|
|
5
|
-
let a = {
|
|
6
|
-
type: "html-element",
|
|
7
|
-
context: t,
|
|
8
|
-
props: e
|
|
9
|
-
};
|
|
10
|
-
this.node = a;
|
|
11
|
-
let o = Object.getOwnPropertyDescriptors(e);
|
|
12
|
-
for (let [e, r] of Object.entries(o)) {
|
|
13
|
-
if ([
|
|
14
|
-
"tag",
|
|
15
|
-
"children",
|
|
16
|
-
"ref"
|
|
17
|
-
].includes(e)) continue;
|
|
18
|
-
r.value && t.updateHtmlElementNodeProp(a, e, r.value);
|
|
19
|
-
let i = r.get;
|
|
20
|
-
i && this.addEffect(createEffect(() => {
|
|
21
|
-
t.updateHtmlElementNodeProp(a, e, i());
|
|
22
|
-
}, !0));
|
|
23
|
-
}
|
|
24
|
-
t.isHydrating && this.insertNode(), normalizeChildren(e.children).forEach((e, n) => {
|
|
25
|
-
this.children.push(e(mergeContext(t, {
|
|
26
|
-
parentBlock: this,
|
|
27
|
-
index: n
|
|
28
|
-
})));
|
|
29
|
-
}), t.isHydrating || this.insertNode();
|
|
30
|
-
}
|
|
31
|
-
unmount() {
|
|
32
|
-
this.node && objectKeys(extractListenersFromProps(this.props)).forEach((e) => {
|
|
33
|
-
this.context.listeners[e]?.delete(this.node);
|
|
34
|
-
}), this.props.ref && (this.props.ref.element = null), super.unmount();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function htmlElement(e) {
|
|
38
|
-
return function(t) {
|
|
39
|
-
return new LibHTMLElement(e, t);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export { htmlElement as t };
|
package/dist/lib-scripts.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { _ as LibBlock, c as createEffect, i as normalizeChildren, n as mergeContext, p as untrack, r as normalizeArray } from "./utils-CAe_kbSH.mjs";
|
|
2
|
-
var LibContextReaderClass = class extends LibBlock {
|
|
3
|
-
constructor(e, t) {
|
|
4
|
-
super(), this.props = e, this.context = t, normalizeArray(e.children).forEach((e, n) => {
|
|
5
|
-
this.children.push(e(t)(mergeContext(t, {
|
|
6
|
-
parentBlock: this,
|
|
7
|
-
index: n
|
|
8
|
-
})));
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function LibContextReader(e) {
|
|
13
|
-
return function(t) {
|
|
14
|
-
return new LibContextReaderClass(e, t);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
var ShowClass = class extends LibBlock {
|
|
18
|
-
constructor(e, r) {
|
|
19
|
-
super(), this.props = e, this.context = r;
|
|
20
|
-
let i = normalizeChildren(e.children);
|
|
21
|
-
this.addEffect(createEffect(() => {
|
|
22
|
-
e.when ? untrack(() => {
|
|
23
|
-
i.forEach((e, t) => {
|
|
24
|
-
this.children.push(e(mergeContext(r, {
|
|
25
|
-
parentBlock: this,
|
|
26
|
-
index: t
|
|
27
|
-
})));
|
|
28
|
-
});
|
|
29
|
-
}) : this.unmountChildren();
|
|
30
|
-
}, !0));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
function Show(e) {
|
|
34
|
-
return function(t) {
|
|
35
|
-
return new ShowClass(e, t);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
var LifecycleClass = class extends LibBlock {
|
|
39
|
-
onMountedReturn;
|
|
40
|
-
constructor(e, t) {
|
|
41
|
-
super(), this.props = e, this.context = t, normalizeChildren(e.children).forEach((e, n) => {
|
|
42
|
-
this.children.push(e(mergeContext(t, {
|
|
43
|
-
parentBlock: this,
|
|
44
|
-
index: n
|
|
45
|
-
})));
|
|
46
|
-
}), this.onMountedReturn = e.onMounted?.();
|
|
47
|
-
}
|
|
48
|
-
unmount() {
|
|
49
|
-
super.unmount(), this.onMountedReturn?.(), this.props.onUnmounted?.();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
function Lifecycle(e) {
|
|
53
|
-
return function(t) {
|
|
54
|
-
return new LifecycleClass(e, t);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export { Show as n, LibContextReader as r, Lifecycle as t };
|
package/dist/portal-CbcYOHLv.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { _ as LibBlock, c as createEffect, i as normalizeChildren, n as mergeContext, p as untrack } from "./utils-CAe_kbSH.mjs";
|
|
2
|
-
var PortalInClass = class extends LibBlock {
|
|
3
|
-
constructor(e, n) {
|
|
4
|
-
super(), this.props = e, this.context = n;
|
|
5
|
-
let r;
|
|
6
|
-
n.portals[e.name] ? console.warn(`Портал ${e.name} уже существует`) : this.addEffect(createEffect(() => {
|
|
7
|
-
let t = e.name;
|
|
8
|
-
t !== r && untrack(() => {
|
|
9
|
-
delete n.portals[t], n.portals[t] = e.children;
|
|
10
|
-
}), r = t;
|
|
11
|
-
}));
|
|
12
|
-
}
|
|
13
|
-
unmount() {
|
|
14
|
-
super.unmount(), delete this.context.portals[this.props.name];
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function PortalIn(e) {
|
|
18
|
-
return function(t) {
|
|
19
|
-
return new PortalInClass(e, t);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
var PortalOutClass = class extends LibBlock {
|
|
23
|
-
constructor(e, i) {
|
|
24
|
-
super(), this.props = e, this.context = i;
|
|
25
|
-
let a;
|
|
26
|
-
this.addEffect(createEffect(() => {
|
|
27
|
-
let t = e.name, o = normalizeChildren(i.portals[t]);
|
|
28
|
-
o ? o !== a && (this.unmountChildren(), untrack(() => {
|
|
29
|
-
o.forEach((e, t) => {
|
|
30
|
-
this.children.push(e(mergeContext(i, {
|
|
31
|
-
parentBlock: this,
|
|
32
|
-
index: t
|
|
33
|
-
})));
|
|
34
|
-
});
|
|
35
|
-
}), a = o) : (this.unmountChildren(), a = null);
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
function PortalOut(e) {
|
|
40
|
-
return function(t) {
|
|
41
|
-
return new PortalOutClass(e, t);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export { PortalOut as n, PortalIn as t };
|
package/dist/render-to-dom.d.ts
DELETED
package/dist/store.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { PotokElement, WithChildren } from './types';
|
|
2
|
-
type State = Record<string, any>;
|
|
3
|
-
type StateOptions<P extends StoreProps> = {
|
|
4
|
-
props: P;
|
|
5
|
-
};
|
|
6
|
-
type Actions = Record<string, (...args: any[]) => any>;
|
|
7
|
-
type ActionsOptions<P extends StoreProps, S extends State> = {
|
|
8
|
-
props: P;
|
|
9
|
-
state: S;
|
|
10
|
-
};
|
|
11
|
-
type StoreProps = Record<string, any>;
|
|
12
|
-
type StoreInitiator<P extends StoreProps, S extends State, A extends Actions> = {
|
|
13
|
-
state: (options: StateOptions<P>) => S;
|
|
14
|
-
actions: (options: ActionsOptions<P, S>) => A;
|
|
15
|
-
};
|
|
16
|
-
export type Store<P extends StoreProps, S extends State, A extends Actions> = {
|
|
17
|
-
provider(props: WithChildren<P>): PotokElement;
|
|
18
|
-
reader(props: {
|
|
19
|
-
children: (options: {
|
|
20
|
-
state: S;
|
|
21
|
-
actions: A;
|
|
22
|
-
}) => PotokElement;
|
|
23
|
-
}): PotokElement;
|
|
24
|
-
};
|
|
25
|
-
export declare function createStore<P extends StoreProps>(): <S extends State, A extends Actions>(initiator: StoreInitiator<P, S, A>) => Store<P, S, A>;
|
|
26
|
-
export {};
|