@potok-web-framework/core 0.13.0 → 0.15.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 +3 -1
- package/dist/client/utils/dom.d.ts +1 -0
- package/dist/client.mjs +7 -4
- package/dist/context-IwELKojA.mjs +41 -0
- package/dist/document-type-node.d.ts +12 -0
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/jsx-runtime.d.ts +1 -1
- package/dist/{fragment-miU_1DSF.mjs → fragment-BPbIbst6.mjs} +2 -2
- package/dist/{get-component-instance-id-BC0t58Yc.mjs → get-component-instance-id-BsCBJaZv.mjs} +2 -2
- package/dist/hmr.mjs +3 -3
- package/dist/{html-element-C4QFddWA.mjs → html-element-node-TpTgOUo-.mjs} +2 -2
- package/dist/index.mjs +21 -7
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/{lib-node-JxhtuJyh.mjs → lib-node-A2uZ5QH1.mjs} +3 -0
- package/dist/{normalize-children-Dh51Diw_.mjs → normalize-children-C7XDL3rl.mjs} +1 -1
- package/dist/{register-component-BpqHm9l-.mjs → register-component-fwzVBk6g.mjs} +4 -4
- package/dist/{server-node.d.ts → server/server-node.d.ts} +4 -3
- package/dist/server.mjs +12 -11
- package/dist/store.mjs +15 -53
- package/package.json +1 -1
- /package/dist/{css-BercB0Kp.mjs → css-DMDIE7dH.mjs} +0 -0
- /package/dist/{html-element.d.ts → html-element-node.d.ts} +0 -0
package/dist/block.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LibDocumentTypeNode } from './document-type-node';
|
|
2
|
+
import { LibHTMLElementNode } from './html-element-node';
|
|
2
3
|
import { LibNode } from './lib-node';
|
|
3
4
|
import { Effect } from './signals';
|
|
4
5
|
import { LibTextNode } from './text-node';
|
|
@@ -16,6 +17,7 @@ export declare abstract class LibBlock {
|
|
|
16
17
|
isNode(): this is LibNode;
|
|
17
18
|
isHTMLElementNode(): this is LibHTMLElementNode;
|
|
18
19
|
isTextNode(): this is LibTextNode;
|
|
20
|
+
isDocumentTypeNode(): this is LibDocumentTypeNode;
|
|
19
21
|
addEffect(effect: Effect): void;
|
|
20
22
|
unmountChildren(): void;
|
|
21
23
|
unmount(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LibNode } from '../../lib-node';
|
|
2
2
|
export declare function isTextNode(node: Node): node is Text;
|
|
3
3
|
export declare function isHTMLElementNode(node: Node): node is HTMLElement;
|
|
4
|
+
export declare function isDocumentTypeNode(node: Node): node is DocumentType;
|
|
4
5
|
export declare function isLibNodeEqualToDomNode(libNode: LibNode, domNode: Node): boolean;
|
package/dist/client.mjs
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { i as createSignal, n as batch, r as createEffect } from "./lib-node-
|
|
1
|
+
import { i as createSignal, n as batch, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
2
|
import { i as PRELOAD_SCRIPTS_SCRIPT_ID, n as HYDRATION_STATE_SCRIPT_ID, r as NON_BUBBLING_EVENTS } from "./constants-Bxn0R4hW.mjs";
|
|
3
3
|
import { t as deserializeWithTypes } from "./serialization-qOayQbjE.mjs";
|
|
4
|
-
import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-
|
|
4
|
+
import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-DMDIE7dH.mjs";
|
|
5
5
|
function isTextNode(e) {
|
|
6
6
|
return e.nodeType === Node.TEXT_NODE;
|
|
7
7
|
}
|
|
8
8
|
function isHTMLElementNode(e) {
|
|
9
9
|
return e.nodeType === Node.ELEMENT_NODE;
|
|
10
10
|
}
|
|
11
|
+
function isDocumentTypeNode(e) {
|
|
12
|
+
return e.nodeType === Node.DOCUMENT_TYPE_NODE;
|
|
13
|
+
}
|
|
11
14
|
function isLibNodeEqualToDomNode(e, t) {
|
|
12
|
-
return e.isTextNode() && isTextNode(t) ? String(e.props.text) === t.textContent : e.isHTMLElementNode() && isHTMLElementNode(t) ? e.props.tag === t.tagName.toLowerCase() : !1;
|
|
15
|
+
return e.isTextNode() && isTextNode(t) ? String(e.props.text) === t.textContent : e.isHTMLElementNode() && isHTMLElementNode(t) ? e.props.tag === t.tagName.toLowerCase() : e.isDocumentTypeNode() && isDocumentTypeNode(t) ? e.props.type === t.name.toLowerCase() : !1;
|
|
13
16
|
}
|
|
14
17
|
function hydrate(s) {
|
|
15
18
|
let c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = document.getElementById(PRELOAD_SCRIPTS_SCRIPT_ID), f = createSignal({
|
|
@@ -79,7 +82,7 @@ function hydrate(s) {
|
|
|
79
82
|
n = n.nextSibling, e.parentElement?.removeChild(e);
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
} else c.has(e) || (e.isTextNode() ? c.set(e, document.createTextNode(String(e.props.text))) : e.isHTMLElementNode()
|
|
85
|
+
} else c.has(e) || (e.isTextNode() ? c.set(e, document.createTextNode(String(e.props.text))) : e.isHTMLElementNode() ? c.set(e, document.createElement(e.props.tag)) : e.isDocumentTypeNode() && c.set(e, document.implementation.createDocumentType(e.props.type, "", "")));
|
|
83
86
|
let s = c.get(e);
|
|
84
87
|
h(e, (t, n) => {
|
|
85
88
|
if (e.isTextNode()) s.textContent = String(n);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { l as LibBlock } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
|
+
var ContextProvider = class extends LibBlock {
|
|
4
|
+
constructor(e, n, i) {
|
|
5
|
+
super(), this.props = e, this.context = i, normalizeChildren(e.children).forEach((r, a) => {
|
|
6
|
+
this.children.push(r(mergeContext(i, {
|
|
7
|
+
parentBlock: this,
|
|
8
|
+
index: a,
|
|
9
|
+
contexts: { [n]: e.value }
|
|
10
|
+
})));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}, ContextConsumer = class extends LibBlock {
|
|
14
|
+
constructor(e, r, i) {
|
|
15
|
+
super(), this.props = e, this.context = i;
|
|
16
|
+
let a = i.contexts[r];
|
|
17
|
+
if (!a) throw Error("Контекст не найден");
|
|
18
|
+
normalizeArray(e.children).forEach((e, n) => {
|
|
19
|
+
this.children.push(e(a)(mergeContext(i, {
|
|
20
|
+
parentBlock: this,
|
|
21
|
+
index: n
|
|
22
|
+
})));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function createContext() {
|
|
27
|
+
let e = Symbol("context");
|
|
28
|
+
return {
|
|
29
|
+
provider(t) {
|
|
30
|
+
return function(n) {
|
|
31
|
+
return new ContextProvider(t, e, n);
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
reader(t) {
|
|
35
|
+
return function(n) {
|
|
36
|
+
return new ContextConsumer(t, e, n);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { createContext as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LibNode } from './lib-node';
|
|
2
|
+
import { LibContext, PotokElement } from './types';
|
|
3
|
+
export type LibDocumentTypeNodeProps = {
|
|
4
|
+
type: "html" | "xml" | "svg";
|
|
5
|
+
};
|
|
6
|
+
export declare class LibDocumentTypeNode extends LibNode {
|
|
7
|
+
readonly props: LibDocumentTypeNodeProps;
|
|
8
|
+
readonly context: LibContext;
|
|
9
|
+
constructor(props: LibDocumentTypeNodeProps, context: LibContext);
|
|
10
|
+
isDocumentTypeNode(): this is LibDocumentTypeNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function DocumentType(props: LibDocumentTypeNodeProps): PotokElement;
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -10,5 +10,7 @@ export { PortalIn, PortalOut } from '../portal';
|
|
|
10
10
|
export { createElementReference } from '../ref';
|
|
11
11
|
export { Show } from '../show';
|
|
12
12
|
export { createSignal, createEffect, batch, untrack, deepTrack, getSignal, } from '../signals';
|
|
13
|
+
export { createContext } from '../context';
|
|
14
|
+
export { DocumentType } from '../document-type-node';
|
|
13
15
|
export type { PotokElement, WithChildren } from '../types';
|
|
14
16
|
export type * from '../jsx-types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { fragment } from '../fragment';
|
|
2
|
-
export { htmlElement } from '../html-element';
|
|
2
|
+
export { htmlElement } from '../html-element-node';
|
|
3
3
|
export { text } from '../text-node';
|
|
4
4
|
export { detectChild } from '../detect-child';
|
|
5
5
|
export { potokPreload } from '../client/potok-preload';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as LibBlock } from "./lib-node-
|
|
2
|
-
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-
|
|
1
|
+
import { l as LibBlock } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
3
|
var FragmentClass = class extends LibBlock {
|
|
4
4
|
constructor(e, r) {
|
|
5
5
|
super(), this.props = e, this.context = r, normalizeChildren(e.children).forEach((e, n) => {
|
package/dist/{get-component-instance-id-BC0t58Yc.mjs → get-component-instance-id-BsCBJaZv.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as createSignal, l as LibBlock } from "./lib-node-
|
|
2
|
-
import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-
|
|
1
|
+
import { i as createSignal, l as LibBlock } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
3
|
var LibContextReaderClass = class extends LibBlock {
|
|
4
4
|
constructor(e, t) {
|
|
5
5
|
super(), this.props = e, this.context = t, normalizeArray(e.children).forEach((e, r) => {
|
package/dist/hmr.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as createSignal } from "./lib-node-
|
|
2
|
-
import { i as HMR_STYLES } from "./get-component-instance-id-
|
|
3
|
-
import { n as registerComponent } from "./register-component-
|
|
1
|
+
import { i as createSignal } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as HMR_STYLES } from "./get-component-instance-id-BsCBJaZv.mjs";
|
|
3
|
+
import { n as registerComponent } from "./register-component-fwzVBk6g.mjs";
|
|
4
4
|
function registerStyle(n, r) {
|
|
5
5
|
let i = HMR_STYLES.styles.find((e) => e.id === n);
|
|
6
6
|
i ? i.css = r : HMR_STYLES.styles = [...HMR_STYLES.styles, createSignal({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as LibNode } from "./lib-node-
|
|
2
|
-
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-
|
|
1
|
+
import { t as LibNode } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
3
|
function potokPreload(e, t) {
|
|
4
4
|
let n = () => e();
|
|
5
5
|
return n.dependencies = t, n;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { a as deepTrack, c as untrack, i as createSignal, l as LibBlock, n as batch, o as getSignal, r as createEffect, s as isSignal } from "./lib-node-
|
|
2
|
-
import { i as mergeContext, n as text, t as normalizeChildren } from "./normalize-children-
|
|
3
|
-
import { a as Lifecycle, i as HMR_STYLES, o as LibContextReader } from "./get-component-instance-id-
|
|
4
|
-
import { r as Show, t as isRegisteredComponentElement } from "./register-component-
|
|
5
|
-
import { n as isPotokPreloader, t as htmlElement } from "./html-element-
|
|
6
|
-
import { t as fragment } from "./fragment-
|
|
1
|
+
import { a as deepTrack, c as untrack, i as createSignal, l as LibBlock, n as batch, o as getSignal, r as createEffect, s as isSignal, t as LibNode } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, n as text, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
|
+
import { a as Lifecycle, i as HMR_STYLES, o as LibContextReader } from "./get-component-instance-id-BsCBJaZv.mjs";
|
|
4
|
+
import { r as Show, t as isRegisteredComponentElement } from "./register-component-fwzVBk6g.mjs";
|
|
5
|
+
import { n as isPotokPreloader, t as htmlElement } from "./html-element-node-TpTgOUo-.mjs";
|
|
6
|
+
import { t as fragment } from "./fragment-BPbIbst6.mjs";
|
|
7
7
|
import { i as PRELOAD_SCRIPTS_SCRIPT_ID, n as HYDRATION_STATE_SCRIPT_ID } from "./constants-Bxn0R4hW.mjs";
|
|
8
8
|
import { t as escapeFromScriptTag } from "./escape-from-script-tag-CRT2evI1.mjs";
|
|
9
9
|
import { n as serializeWithTypes } from "./serialization-qOayQbjE.mjs";
|
|
10
|
+
import { t as createContext } from "./context-IwELKojA.mjs";
|
|
10
11
|
import { clientEntry } from "virtual:client-variables";
|
|
11
12
|
function ClientOnly(e) {
|
|
12
13
|
return LibContextReader({ children: (t) => Show({
|
|
@@ -268,4 +269,17 @@ function PortalOut(e) {
|
|
|
268
269
|
return new PortalOutClass(e, t);
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
|
-
|
|
272
|
+
var LibDocumentTypeNode = class extends LibNode {
|
|
273
|
+
constructor(e, t) {
|
|
274
|
+
super(), this.props = e, this.context = t, this.insert();
|
|
275
|
+
}
|
|
276
|
+
isDocumentTypeNode() {
|
|
277
|
+
return !0;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
function DocumentType(e) {
|
|
281
|
+
return function(t) {
|
|
282
|
+
return new LibDocumentTypeNode(e, t);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
export { ClientOnly, DocumentType, ErrorBoundary, FooterScripts, HeaderScripts, Lazy, LibContextReader, Lifecycle, List, PortalIn, PortalOut, Show, batch, createContext, createEffect, createElementReference, createSignal, deepTrack, getSignal, untrack };
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as text } from "./normalize-children-
|
|
2
|
-
import { r as potokPreload, t as htmlElement } from "./html-element-
|
|
3
|
-
import { t as fragment } from "./fragment-
|
|
1
|
+
import { n as text } from "./normalize-children-C7XDL3rl.mjs";
|
|
2
|
+
import { r as potokPreload, t as htmlElement } from "./html-element-node-TpTgOUo-.mjs";
|
|
3
|
+
import { t as fragment } from "./fragment-BPbIbst6.mjs";
|
|
4
4
|
function detectChild(e) {
|
|
5
5
|
let t = e.value, n = typeof t;
|
|
6
6
|
return n === "string" || n === "number" || n === "boolean" ? text({ get text() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as untrack, i as createSignal, l as LibBlock, r as createEffect } from "./lib-node-
|
|
2
|
-
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-
|
|
3
|
-
import { a as Lifecycle, n as HMR_COMPONENTS_REGISTRY, o as LibContextReader, t as getComponentInstanceId } from "./get-component-instance-id-
|
|
4
|
-
import { t as fragment } from "./fragment-
|
|
1
|
+
import { c as untrack, i as createSignal, l as LibBlock, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
|
|
3
|
+
import { a as Lifecycle, n as HMR_COMPONENTS_REGISTRY, o as LibContextReader, t as getComponentInstanceId } from "./get-component-instance-id-BsCBJaZv.mjs";
|
|
4
|
+
import { t as fragment } from "./fragment-BPbIbst6.mjs";
|
|
5
5
|
var ShowClass = class extends LibBlock {
|
|
6
6
|
constructor(t, n) {
|
|
7
7
|
super(), this.props = t, this.context = n;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { LibNode } from '
|
|
1
|
+
import { LibNode } from '../lib-node';
|
|
2
2
|
export declare class ServerNode {
|
|
3
|
-
libNode: LibNode;
|
|
3
|
+
readonly libNode: LibNode | null;
|
|
4
4
|
parent: ServerNode | null;
|
|
5
5
|
children: ServerNode[];
|
|
6
|
-
constructor(libNode: LibNode);
|
|
6
|
+
constructor(libNode: LibNode | null);
|
|
7
7
|
addChild(node: ServerNode, after: ServerNode | null): void;
|
|
8
8
|
remove(): void;
|
|
9
|
+
private stringifyChildren;
|
|
9
10
|
stringify(): string;
|
|
10
11
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as createSignal, n as batch } from "./lib-node-
|
|
1
|
+
import { i as createSignal, n as batch } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
2
|
import { t as escapeFromScriptTag } from "./escape-from-script-tag-CRT2evI1.mjs";
|
|
3
|
-
import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-
|
|
3
|
+
import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-DMDIE7dH.mjs";
|
|
4
4
|
import { clientDependencies } from "virtual:client-variables";
|
|
5
5
|
import path from "path";
|
|
6
6
|
async function bootstrapApp(e) {
|
|
@@ -29,7 +29,6 @@ function escapeHtml(e) {
|
|
|
29
29
|
return /[&<>"']/.test(e) ? e.replace(/[&<>"']/g, (e) => HTML_ESCAPE_MAP[e]) : e;
|
|
30
30
|
}
|
|
31
31
|
var ServerNode = class {
|
|
32
|
-
libNode;
|
|
33
32
|
parent = null;
|
|
34
33
|
children = [];
|
|
35
34
|
constructor(e) {
|
|
@@ -46,7 +45,11 @@ var ServerNode = class {
|
|
|
46
45
|
remove() {
|
|
47
46
|
this.parent && this.parent.children.splice(this.parent.children.indexOf(this), 1);
|
|
48
47
|
}
|
|
48
|
+
stringifyChildren() {
|
|
49
|
+
return this.children.map((e) => e.stringify()).join("");
|
|
50
|
+
}
|
|
49
51
|
stringify() {
|
|
52
|
+
if (!this.libNode) return this.stringifyChildren();
|
|
50
53
|
if (this.libNode.isTextNode()) {
|
|
51
54
|
let e = this.libNode.parentElementNode?.props.tag;
|
|
52
55
|
return e === "title" ? escapeHtml(String(this.libNode.props.text)) : e === "script" ? escapeFromScriptTag(String(this.libNode.props.text)) : `<!-- -->${escapeHtml(String(this.libNode.props.text))}<!-- -->`;
|
|
@@ -74,10 +77,8 @@ var ServerNode = class {
|
|
|
74
77
|
} else if (t.startsWith("on")) continue;
|
|
75
78
|
else e += ` ${t}="${escapeHtml(String(a))}"`;
|
|
76
79
|
}
|
|
77
|
-
return e += ">", this.
|
|
78
|
-
|
|
79
|
-
}), e += `</${this.libNode.props.tag}>`, e;
|
|
80
|
-
}
|
|
80
|
+
return e += ">", e += this.stringifyChildren(), e += `</${this.libNode.props.tag}>`, e;
|
|
81
|
+
} else if (this.libNode.isDocumentTypeNode()) return `<!DOCTYPE ${escapeHtml(this.libNode.props.type)}>`;
|
|
81
82
|
throw Error("Not implemented");
|
|
82
83
|
}
|
|
83
84
|
}, clientDependencyScripts = clientDependencies.map((t) => createSignal({
|
|
@@ -99,7 +100,7 @@ async function renderToString(n) {
|
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
}), i = /* @__PURE__ */ new Map(), a, o = [];
|
|
103
|
+
}), i = /* @__PURE__ */ new Map(), a = new ServerNode(null), o = [];
|
|
103
104
|
function s(e) {
|
|
104
105
|
return i.has(e) || i.set(e, new ServerNode(e)), i.get(e);
|
|
105
106
|
}
|
|
@@ -114,14 +115,14 @@ async function renderToString(n) {
|
|
|
114
115
|
promises: o,
|
|
115
116
|
isHydrating: !1,
|
|
116
117
|
insertNode(e) {
|
|
117
|
-
let t = e.parentElementNode ? s(e.parentElementNode) :
|
|
118
|
-
t
|
|
118
|
+
let t = e.parentElementNode ? s(e.parentElementNode) : a, n = s(e), r = e.previousNode ? s(e.previousNode) : null;
|
|
119
|
+
t.addChild(n, r);
|
|
119
120
|
},
|
|
120
121
|
removeNode(e) {
|
|
121
122
|
i.get(e)?.remove();
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
|
-
|
|
125
|
+
await Promise.all(o);
|
|
125
126
|
let l = a.stringify();
|
|
126
127
|
return c.unmount(), l;
|
|
127
128
|
}
|
package/dist/store.mjs
CHANGED
|
@@ -1,45 +1,7 @@
|
|
|
1
|
-
import { a as deepTrack, i as createSignal,
|
|
2
|
-
import {
|
|
3
|
-
import { a as Lifecycle, o as LibContextReader, r as HMR_STATE_CACHE, t as getComponentInstanceId } from "./get-component-instance-id-BC0t58Yc.mjs";
|
|
1
|
+
import { a as deepTrack, i as createSignal, n as batch, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
|
|
2
|
+
import { a as Lifecycle, o as LibContextReader, r as HMR_STATE_CACHE, t as getComponentInstanceId } from "./get-component-instance-id-BsCBJaZv.mjs";
|
|
4
3
|
import { t as isPureObject } from "./is-pure-object-s_MkQp1w.mjs";
|
|
5
|
-
|
|
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
|
-
}
|
|
4
|
+
import { t as createContext } from "./context-IwELKojA.mjs";
|
|
43
5
|
function deepAssignObject(e, t) {
|
|
44
6
|
for (let n in t) {
|
|
45
7
|
if (!Object.prototype.hasOwnProperty.call(t, n)) continue;
|
|
@@ -49,34 +11,34 @@ function deepAssignObject(e, t) {
|
|
|
49
11
|
return e;
|
|
50
12
|
}
|
|
51
13
|
function createStore() {
|
|
52
|
-
return function(
|
|
53
|
-
let
|
|
14
|
+
return function(a) {
|
|
15
|
+
let s = createContext();
|
|
54
16
|
return {
|
|
55
17
|
provider(o) {
|
|
56
|
-
return LibContextReader({ children: (
|
|
57
|
-
let c = getComponentInstanceId(
|
|
18
|
+
return LibContextReader({ children: (i) => {
|
|
19
|
+
let c = getComponentInstanceId(i), l = [], u = Object.entries(a.extensions).reduce((e, [t, n]) => {
|
|
58
20
|
let r = n();
|
|
59
21
|
return r.onUnmounted && l.push(r.onUnmounted), e[t] = r.api, e;
|
|
60
|
-
}, {}), d =
|
|
61
|
-
process.env.NODE_ENV === "development" && HMR_STATE_CACHE.has(c) ? f = HMR_STATE_CACHE.get(c).value : (f = createSignal(deepAssignObject(
|
|
22
|
+
}, {}), d = i.states[c] ?? {}, f;
|
|
23
|
+
process.env.NODE_ENV === "development" && HMR_STATE_CACHE.has(c) ? f = HMR_STATE_CACHE.get(c).value : (f = createSignal(deepAssignObject(a.state({
|
|
62
24
|
props: o,
|
|
63
25
|
extensions: u
|
|
64
26
|
}), d)), process.env.NODE_ENV === "development" && HMR_STATE_CACHE.set(c, {
|
|
65
27
|
value: f,
|
|
66
28
|
isRemovable: !1
|
|
67
29
|
}));
|
|
68
|
-
let p =
|
|
30
|
+
let p = a.actions({
|
|
69
31
|
props: o,
|
|
70
32
|
state: f
|
|
71
|
-
}), m = Object.entries(p).reduce((e, [t,
|
|
33
|
+
}), m = Object.entries(p).reduce((e, [t, r]) => (e[t] = (...e) => batch(() => r.apply(p, e)), e), {});
|
|
72
34
|
return Lifecycle({
|
|
73
35
|
onMounted() {
|
|
74
36
|
if (process.env.NODE_ENV === "development") {
|
|
75
37
|
let e = HMR_STATE_CACHE.get(c);
|
|
76
38
|
e && (e.isRemovable = !1);
|
|
77
39
|
}
|
|
78
|
-
if (
|
|
79
|
-
deepTrack(f),
|
|
40
|
+
if (i.isServer) return createEffect(() => {
|
|
41
|
+
deepTrack(f), i.states[c] = f;
|
|
80
42
|
}, !0).dispose;
|
|
81
43
|
},
|
|
82
44
|
onUnmounted() {
|
|
@@ -87,7 +49,7 @@ function createStore() {
|
|
|
87
49
|
}));
|
|
88
50
|
}
|
|
89
51
|
},
|
|
90
|
-
children:
|
|
52
|
+
children: s.provider({
|
|
91
53
|
value: {
|
|
92
54
|
state: f,
|
|
93
55
|
actions: m
|
|
@@ -98,7 +60,7 @@ function createStore() {
|
|
|
98
60
|
} });
|
|
99
61
|
},
|
|
100
62
|
reader(e) {
|
|
101
|
-
return
|
|
63
|
+
return s.reader({ children: (t) => e.children(t) });
|
|
102
64
|
}
|
|
103
65
|
};
|
|
104
66
|
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|