@potok-web-framework/core 0.7.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 +11 -6
- package/dist/client/potok-preload.d.ts +6 -0
- package/dist/{dom/utils.d.ts → client/utils/dom.d.ts} +1 -1
- package/dist/client.mjs +93 -71
- 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 +2 -2
- 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 +202 -129
- 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 +219 -240
- 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 +83 -1145
- 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 +11 -14
- 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-BSt6shYv.mjs +0 -103
- package/dist/hmr/hmr-dev.d.ts +0 -9
- package/dist/html-element-DeGD0uGZ.mjs +0 -24
- package/dist/lib-scripts.d.ts +0 -2
- package/dist/lifecycle-C9_o5zOU.mjs +0 -58
- package/dist/portal-BxUviJsE.mjs +0 -45
- package/dist/signals-ZsU9bGc3.mjs +0 -262
- package/dist/store.d.ts +0 -26
- package/dist/text.d.ts +0 -5
- package/dist/utils.d.ts +0 -9
- /package/dist/{dom → client}/hydrate.d.ts +0 -0
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,25 +1,21 @@
|
|
|
1
1
|
import { LibBlock } from './block';
|
|
2
|
-
import {
|
|
3
|
-
import { 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(
|
|
11
|
+
insertNode(node: LibNode): void;
|
|
21
12
|
removeNode(node: LibNode): void;
|
|
22
13
|
portals: Record<string, WithChildren<{}>["children"]>;
|
|
14
|
+
preload: {
|
|
15
|
+
scripts: ModuleScript[];
|
|
16
|
+
addScripts(path: string[]): void;
|
|
17
|
+
};
|
|
18
|
+
states: Record<string, unknown>;
|
|
23
19
|
contexts: Record<symbol, Record<string, unknown>>;
|
|
24
20
|
isServer: boolean;
|
|
25
21
|
promises: Promise<unknown>[];
|
|
@@ -27,6 +23,7 @@ export type LibContext = {
|
|
|
27
23
|
};
|
|
28
24
|
export type PotokElement = (context: LibContext) => LibBlock;
|
|
29
25
|
export type MaybeArray<T> = T | T[];
|
|
26
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
30
27
|
export type Child = PotokElement | Child[] | string | number | null | undefined;
|
|
31
28
|
export type Children = MaybeArray<Child> | undefined;
|
|
32
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,103 +0,0 @@
|
|
|
1
|
-
import { n as createDisposer } from "./signals-ZsU9bGc3.mjs";
|
|
2
|
-
var LibBlock = class {
|
|
3
|
-
node = null;
|
|
4
|
-
effects = /* @__PURE__ */ new Set();
|
|
5
|
-
children = [];
|
|
6
|
-
get nearestParentElement() {
|
|
7
|
-
return this.node ?? this.context.parentBlock?.nearestParentElement ?? null;
|
|
8
|
-
}
|
|
9
|
-
get previousBlock() {
|
|
10
|
-
let e = this.context.parentBlock;
|
|
11
|
-
return e ? e.children[this.context.index - 1] || (e.node ? null : e.previousBlock) : null;
|
|
12
|
-
}
|
|
13
|
-
get nearestPreviousNode() {
|
|
14
|
-
if (this.node) return this.node;
|
|
15
|
-
let e = this.children[this.children.length - 1];
|
|
16
|
-
if (e) return e.nearestPreviousNode;
|
|
17
|
-
let t = this.previousBlock;
|
|
18
|
-
return t ? t.nearestPreviousNode : null;
|
|
19
|
-
}
|
|
20
|
-
get previousNode() {
|
|
21
|
-
let e = this.previousBlock;
|
|
22
|
-
return e ? e.nearestPreviousNode : null;
|
|
23
|
-
}
|
|
24
|
-
addEffect(e) {
|
|
25
|
-
this.effects.add(e);
|
|
26
|
-
}
|
|
27
|
-
unmountChildren() {
|
|
28
|
-
this.children.forEach((e) => {
|
|
29
|
-
e?.unmount();
|
|
30
|
-
}), this.children = [];
|
|
31
|
-
}
|
|
32
|
-
insertNode() {
|
|
33
|
-
let t = this.node;
|
|
34
|
-
t && createDisposer(() => {
|
|
35
|
-
this.context.insertNode(this.context.parentBlock?.nearestParentElement ?? null, t, this.previousNode);
|
|
36
|
-
}).effects.forEach((e) => {
|
|
37
|
-
this.effects.add(e);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
unmount() {
|
|
41
|
-
this.node && this.context.removeNode(this.node), this.unmountChildren(), this.effects.forEach((e) => {
|
|
42
|
-
e.dispose();
|
|
43
|
-
}), this.effects.clear();
|
|
44
|
-
}
|
|
45
|
-
}, LibText = class extends LibBlock {
|
|
46
|
-
constructor(e, t) {
|
|
47
|
-
super(), this.props = e, this.context = t, this.node = {
|
|
48
|
-
type: "text",
|
|
49
|
-
props: e,
|
|
50
|
-
context: t
|
|
51
|
-
}, this.insertNode();
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
function text(e) {
|
|
55
|
-
return function(t) {
|
|
56
|
-
return new LibText(e, t);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function mergeContext(e, t) {
|
|
60
|
-
return {
|
|
61
|
-
parentBlock: t.parentBlock,
|
|
62
|
-
get index() {
|
|
63
|
-
return t.index;
|
|
64
|
-
},
|
|
65
|
-
portals: e.portals,
|
|
66
|
-
contexts: {
|
|
67
|
-
...e.contexts,
|
|
68
|
-
...t.contexts
|
|
69
|
-
},
|
|
70
|
-
isServer: e.isServer,
|
|
71
|
-
promises: e.promises,
|
|
72
|
-
get isHydrating() {
|
|
73
|
-
return e.isHydrating;
|
|
74
|
-
},
|
|
75
|
-
insertNode: e.insertNode,
|
|
76
|
-
removeNode: e.removeNode
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function normalizeArray(e) {
|
|
80
|
-
return Array.isArray(e) ? e : [e];
|
|
81
|
-
}
|
|
82
|
-
function normalizeChild(e) {
|
|
83
|
-
return typeof e == "string" || typeof e == "number" ? [text({ text: String(e) })] : Array.isArray(e) ? e.flatMap(normalizeChildren) : [e];
|
|
84
|
-
}
|
|
85
|
-
function normalizeChildren(e) {
|
|
86
|
-
return e ? normalizeArray(e).filter((e) => e != null).flatMap(normalizeChild) : [];
|
|
87
|
-
}
|
|
88
|
-
var FragmentClass = class extends LibBlock {
|
|
89
|
-
constructor(e, t) {
|
|
90
|
-
super(), this.props = e, this.context = t, normalizeChildren(e.children).forEach((e, n) => {
|
|
91
|
-
this.children.push(e(mergeContext(t, {
|
|
92
|
-
parentBlock: this,
|
|
93
|
-
index: n
|
|
94
|
-
})));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
function fragment(e) {
|
|
99
|
-
return function(t) {
|
|
100
|
-
return new FragmentClass(e, t);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export { text as a, normalizeChildren as i, mergeContext as n, LibBlock as o, normalizeArray as r, fragment as t };
|
package/dist/hmr/hmr-dev.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { i as normalizeChildren, n as mergeContext, o as LibBlock } from "./fragment-BSt6shYv.mjs";
|
|
2
|
-
var LibHTMLElement = class extends LibBlock {
|
|
3
|
-
constructor(n, r) {
|
|
4
|
-
super(), this.props = n, this.context = r, this.node = {
|
|
5
|
-
type: "html-element",
|
|
6
|
-
context: r,
|
|
7
|
-
props: n
|
|
8
|
-
}, r.isHydrating && this.insertNode(), normalizeChildren(n.children).forEach((e, n) => {
|
|
9
|
-
this.children.push(e(mergeContext(r, {
|
|
10
|
-
parentBlock: this,
|
|
11
|
-
index: n
|
|
12
|
-
})));
|
|
13
|
-
}), r.isHydrating || this.insertNode();
|
|
14
|
-
}
|
|
15
|
-
unmount() {
|
|
16
|
-
this.props.ref && (this.props.ref.element = null), super.unmount();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function htmlElement(e) {
|
|
20
|
-
return function(t) {
|
|
21
|
-
return new LibHTMLElement(e, t);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export { htmlElement as t };
|
package/dist/lib-scripts.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { c as untrack, r as createEffect } from "./signals-ZsU9bGc3.mjs";
|
|
2
|
-
import { i as normalizeChildren, n as mergeContext, o as LibBlock, r as normalizeArray } from "./fragment-BSt6shYv.mjs";
|
|
3
|
-
var LibContextReaderClass = class extends LibBlock {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.props = e, this.context = t, normalizeArray(e.children).forEach((e, n) => {
|
|
6
|
-
this.children.push(e(t)(mergeContext(t, {
|
|
7
|
-
parentBlock: this,
|
|
8
|
-
index: n
|
|
9
|
-
})));
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
function LibContextReader(e) {
|
|
14
|
-
return function(t) {
|
|
15
|
-
return new LibContextReaderClass(e, t);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
var ShowClass = class extends LibBlock {
|
|
19
|
-
constructor(r, i) {
|
|
20
|
-
super(), this.props = r, this.context = i;
|
|
21
|
-
let a = normalizeChildren(r.children);
|
|
22
|
-
this.addEffect(createEffect(() => {
|
|
23
|
-
r.when ? untrack(() => {
|
|
24
|
-
a.forEach((e, t) => {
|
|
25
|
-
this.children.push(e(mergeContext(i, {
|
|
26
|
-
parentBlock: this,
|
|
27
|
-
index: t
|
|
28
|
-
})));
|
|
29
|
-
});
|
|
30
|
-
}) : this.unmountChildren();
|
|
31
|
-
}, !0));
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
function Show(e) {
|
|
35
|
-
return function(t) {
|
|
36
|
-
return new ShowClass(e, t);
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
var LifecycleClass = class extends LibBlock {
|
|
40
|
-
onMountedReturn;
|
|
41
|
-
constructor(e, t) {
|
|
42
|
-
super(), this.props = e, this.context = t, normalizeChildren(e.children).forEach((e, n) => {
|
|
43
|
-
this.children.push(e(mergeContext(t, {
|
|
44
|
-
parentBlock: this,
|
|
45
|
-
index: n
|
|
46
|
-
})));
|
|
47
|
-
}), this.onMountedReturn = e.onMounted?.();
|
|
48
|
-
}
|
|
49
|
-
unmount() {
|
|
50
|
-
super.unmount(), this.onMountedReturn?.(), this.props.onUnmounted?.();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
function Lifecycle(e) {
|
|
54
|
-
return function(t) {
|
|
55
|
-
return new LifecycleClass(e, t);
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export { Show as n, LibContextReader as r, Lifecycle as t };
|
package/dist/portal-BxUviJsE.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { c as untrack, r as createEffect } from "./signals-ZsU9bGc3.mjs";
|
|
2
|
-
import { i as normalizeChildren, n as mergeContext, o as LibBlock } from "./fragment-BSt6shYv.mjs";
|
|
3
|
-
var PortalInClass = class extends LibBlock {
|
|
4
|
-
constructor(n, r) {
|
|
5
|
-
super(), this.props = n, this.context = r;
|
|
6
|
-
let i;
|
|
7
|
-
r.portals[n.name] ? console.warn(`Портал ${n.name} уже существует`) : this.addEffect(createEffect(() => {
|
|
8
|
-
let t = n.name;
|
|
9
|
-
t !== i && untrack(() => {
|
|
10
|
-
delete r.portals[t], r.portals[t] = n.children;
|
|
11
|
-
}), i = t;
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
unmount() {
|
|
15
|
-
super.unmount(), delete this.context.portals[this.props.name];
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
function PortalIn(e) {
|
|
19
|
-
return function(t) {
|
|
20
|
-
return new PortalInClass(e, t);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
var PortalOutClass = class extends LibBlock {
|
|
24
|
-
constructor(i, a) {
|
|
25
|
-
super(), this.props = i, this.context = a;
|
|
26
|
-
let o;
|
|
27
|
-
this.addEffect(createEffect(() => {
|
|
28
|
-
let t = i.name, s = normalizeChildren(a.portals[t]);
|
|
29
|
-
s ? s !== o && (this.unmountChildren(), untrack(() => {
|
|
30
|
-
s.forEach((e, t) => {
|
|
31
|
-
this.children.push(e(mergeContext(a, {
|
|
32
|
-
parentBlock: this,
|
|
33
|
-
index: t
|
|
34
|
-
})));
|
|
35
|
-
});
|
|
36
|
-
}), o = s) : (this.unmountChildren(), o = null);
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
function PortalOut(e) {
|
|
41
|
-
return function(t) {
|
|
42
|
-
return new PortalOutClass(e, t);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export { PortalOut as n, PortalIn as t };
|