@foxford/den-preact 0.1.1 → 0.2.1-beta-3141d32-20260904
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/{chunk-MBFQZ6VG.js → chunk-7GQ7NIUN.js} +39 -20
- package/{chunk-J2T5F5Q5.cjs → chunk-H2QOAMNS.cjs} +38 -19
- package/client.cjs +21 -9
- package/client.js +20 -8
- package/index.cjs +5 -5
- package/index.js +1 -1
- package/package.json +22 -6
- package/preset.cjs +11 -1
- package/preset.js +11 -1
- package/use-sync-external-store.cjs +33 -0
- package/use-sync-external-store.d.cts +20 -0
- package/use-sync-external-store.d.ts +20 -0
- package/use-sync-external-store.js +33 -0
|
@@ -76,6 +76,7 @@ function Slot({ name }) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// src/island.tsx
|
|
79
|
+
import { Component } from "preact";
|
|
79
80
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
80
81
|
import {
|
|
81
82
|
activateIslandViewModels,
|
|
@@ -84,9 +85,43 @@ import {
|
|
|
84
85
|
describeIsland,
|
|
85
86
|
hydrateIslandState,
|
|
86
87
|
registerIsland,
|
|
88
|
+
reportIslandError,
|
|
87
89
|
resolveEagerUnits
|
|
88
90
|
} from "@foxford/den/island";
|
|
89
|
-
import { jsx as jsx3
|
|
91
|
+
import { jsx as jsx3 } from "preact/jsx-runtime";
|
|
92
|
+
var failureStyle = {
|
|
93
|
+
background: "#fef2f2",
|
|
94
|
+
border: "1px solid #fca5a5",
|
|
95
|
+
borderRadius: 8,
|
|
96
|
+
color: "#b91c1c",
|
|
97
|
+
fontSize: 14,
|
|
98
|
+
padding: 12
|
|
99
|
+
};
|
|
100
|
+
function FailurePlaque({ name, reason }) {
|
|
101
|
+
const text = reason === "build" ? `\u041E\u0441\u0442\u0440\u043E\u0432 \xAB${name}\xBB \u0443\u043F\u0430\u043B \u043F\u0440\u0438 \u0441\u0431\u043E\u0440\u043A\u0435 \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442.` : `\u041E\u0441\u0442\u0440\u043E\u0432 \xAB${name}\xBB \u0443\u043F\u0430\u043B \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442.`;
|
|
102
|
+
return /* @__PURE__ */ jsx3("div", { style: failureStyle, children: text });
|
|
103
|
+
}
|
|
104
|
+
var IslandViewErrorBoundary = class extends Component {
|
|
105
|
+
constructor() {
|
|
106
|
+
super(...arguments);
|
|
107
|
+
this.state = { failed: false };
|
|
108
|
+
}
|
|
109
|
+
static getDerivedStateFromError() {
|
|
110
|
+
return { failed: true };
|
|
111
|
+
}
|
|
112
|
+
componentDidCatch(error) {
|
|
113
|
+
reportIslandError(error, { appName: this.props.appName, phase: "render" });
|
|
114
|
+
if (!this.state.failed) {
|
|
115
|
+
this.setState({ failed: true });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
if (this.state.failed) {
|
|
120
|
+
return /* @__PURE__ */ jsx3(FailurePlaque, { name: this.props.appName, reason: "render" });
|
|
121
|
+
}
|
|
122
|
+
return this.props.children;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
90
125
|
function IslandRuntime({
|
|
91
126
|
descriptor,
|
|
92
127
|
denState,
|
|
@@ -126,28 +161,12 @@ function IslandRuntime({
|
|
|
126
161
|
}
|
|
127
162
|
return registerIsland(describeIsland(descriptor, denState));
|
|
128
163
|
}, [container, descriptor, denState]);
|
|
164
|
+
const appName = (_a = descriptor.name) != null ? _a : "app";
|
|
129
165
|
if (container === null) {
|
|
130
|
-
return /* @__PURE__ */
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
style: {
|
|
134
|
-
background: "#fef2f2",
|
|
135
|
-
border: "1px solid #fca5a5",
|
|
136
|
-
borderRadius: 8,
|
|
137
|
-
color: "#b91c1c",
|
|
138
|
-
fontSize: 14,
|
|
139
|
-
padding: 12
|
|
140
|
-
},
|
|
141
|
-
children: [
|
|
142
|
-
"\u041E\u0441\u0442\u0440\u043E\u0432 \xAB",
|
|
143
|
-
(_a = descriptor.name) != null ? _a : "app",
|
|
144
|
-
"\xBB \u0443\u043F\u0430\u043B \u043F\u0440\u0438 \u0441\u0431\u043E\u0440\u043A\u0435 \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442."
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
);
|
|
166
|
+
return /* @__PURE__ */ jsx3(FailurePlaque, { name: appName, reason: "build" });
|
|
148
167
|
}
|
|
149
168
|
const View = descriptor.view;
|
|
150
|
-
return /* @__PURE__ */ jsx3(ContainerProvider, { value: container, children: /* @__PURE__ */ jsx3(SlotHost, { fills: slots, children: /* @__PURE__ */ jsx3(View, {}) }) });
|
|
169
|
+
return /* @__PURE__ */ jsx3(ContainerProvider, { value: container, children: /* @__PURE__ */ jsx3(SlotHost, { fills: slots, children: /* @__PURE__ */ jsx3(IslandViewErrorBoundary, { appName, children: /* @__PURE__ */ jsx3(View, {}) }) }) });
|
|
151
170
|
}
|
|
152
171
|
function createPreactIsland(descriptor) {
|
|
153
172
|
return function Island(props) {
|
|
@@ -87,6 +87,41 @@ function Slot({ name }) {
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var failureStyle = {
|
|
93
|
+
background: "#fef2f2",
|
|
94
|
+
border: "1px solid #fca5a5",
|
|
95
|
+
borderRadius: 8,
|
|
96
|
+
color: "#b91c1c",
|
|
97
|
+
fontSize: 14,
|
|
98
|
+
padding: 12
|
|
99
|
+
};
|
|
100
|
+
function FailurePlaque({ name, reason }) {
|
|
101
|
+
const text = reason === "build" ? `\u041E\u0441\u0442\u0440\u043E\u0432 \xAB${name}\xBB \u0443\u043F\u0430\u043B \u043F\u0440\u0438 \u0441\u0431\u043E\u0440\u043A\u0435 \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442.` : `\u041E\u0441\u0442\u0440\u043E\u0432 \xAB${name}\xBB \u0443\u043F\u0430\u043B \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442.`;
|
|
102
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: failureStyle, children: text });
|
|
103
|
+
}
|
|
104
|
+
var IslandViewErrorBoundary = class extends _preact.Component {
|
|
105
|
+
constructor() {
|
|
106
|
+
super(...arguments);
|
|
107
|
+
this.state = { failed: false };
|
|
108
|
+
}
|
|
109
|
+
static getDerivedStateFromError() {
|
|
110
|
+
return { failed: true };
|
|
111
|
+
}
|
|
112
|
+
componentDidCatch(error) {
|
|
113
|
+
_island.reportIslandError.call(void 0, error, { appName: this.props.appName, phase: "render" });
|
|
114
|
+
if (!this.state.failed) {
|
|
115
|
+
this.setState({ failed: true });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
if (this.state.failed) {
|
|
120
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FailurePlaque, { name: this.props.appName, reason: "render" });
|
|
121
|
+
}
|
|
122
|
+
return this.props.children;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
90
125
|
function IslandRuntime({
|
|
91
126
|
descriptor,
|
|
92
127
|
denState,
|
|
@@ -126,28 +161,12 @@ function IslandRuntime({
|
|
|
126
161
|
}
|
|
127
162
|
return _island.registerIsland.call(void 0, _island.describeIsland.call(void 0, descriptor, denState));
|
|
128
163
|
}, [container, descriptor, denState]);
|
|
164
|
+
const appName = (_a = descriptor.name) != null ? _a : "app";
|
|
129
165
|
if (container === null) {
|
|
130
|
-
return /* @__PURE__ */ _jsxruntime.
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
style: {
|
|
134
|
-
background: "#fef2f2",
|
|
135
|
-
border: "1px solid #fca5a5",
|
|
136
|
-
borderRadius: 8,
|
|
137
|
-
color: "#b91c1c",
|
|
138
|
-
fontSize: 14,
|
|
139
|
-
padding: 12
|
|
140
|
-
},
|
|
141
|
-
children: [
|
|
142
|
-
"\u041E\u0441\u0442\u0440\u043E\u0432 \xAB",
|
|
143
|
-
(_a = descriptor.name) != null ? _a : "app",
|
|
144
|
-
"\xBB \u0443\u043F\u0430\u043B \u043F\u0440\u0438 \u0441\u0431\u043E\u0440\u043A\u0435 \u2014 \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442."
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
);
|
|
166
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FailurePlaque, { name: appName, reason: "build" });
|
|
148
167
|
}
|
|
149
168
|
const View = descriptor.view;
|
|
150
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContainerProvider, { value: container, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotHost, { fills: slots, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, View, {}) }) });
|
|
169
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContainerProvider, { value: container, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SlotHost, { fills: slots, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, IslandViewErrorBoundary, { appName, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, View, {}) }) }) });
|
|
151
170
|
}
|
|
152
171
|
function createPreactIsland(descriptor) {
|
|
153
172
|
return function Island(props) {
|
package/client.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkH2QOAMNScjs = require('./chunk-H2QOAMNS.cjs');
|
|
5
5
|
require('./chunk-P4DSWCF6.cjs');
|
|
6
6
|
|
|
7
7
|
// src/client.ts
|
|
@@ -44,26 +44,38 @@ function hydrateApp(descriptor) {
|
|
|
44
44
|
mountApp(descriptor);
|
|
45
45
|
}
|
|
46
46
|
function mountApp(descriptor) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const appName = (_a = descriptor.name) != null ? _a : "app";
|
|
47
49
|
const node = document.querySelector(`[${ROOT_MARK}="${descriptor.name}"]`);
|
|
48
50
|
if (node === null) {
|
|
49
|
-
logger.error(`\u0443\u0437\u0435\u043B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \xAB${
|
|
51
|
+
logger.error(`\u0443\u0437\u0435\u043B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \xAB${appName}\xBB \u0432 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u2014 \u043E\u0436\u0438\u0432\u043B\u044F\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E`);
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
54
|
if (hydrated.has(node)) {
|
|
53
|
-
logger.warn(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${
|
|
55
|
+
logger.warn(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB \u0443\u0436\u0435 \u043E\u0436\u0438\u0432\u043B\u0435\u043D\u043E \u2014 \u0432\u0442\u043E\u0440\u043E\u0439 \u0432\u0445\u043E\u0434 \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D`);
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
hydrated.add(node);
|
|
57
|
-
|
|
58
|
-
const Island =
|
|
59
|
+
_chunkH2QOAMNScjs.installIslandResolver.call(void 0, );
|
|
60
|
+
const Island = _chunkH2QOAMNScjs.createPreactIsland.call(void 0, descriptor);
|
|
59
61
|
const onDocument = (contribution) => {
|
|
60
62
|
_island.publishIslandDocument.call(void 0, node, contribution);
|
|
61
63
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
try {
|
|
65
|
+
_preact.hydrate.call(void 0, _preact.h.call(void 0, Island, { denState: readState((_b = descriptor.name) != null ? _b : ""), onDocument, route: currentRoute() }), node);
|
|
66
|
+
logger.info(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB \u043E\u0436\u0438\u0432\u043B\u0435\u043D\u043E`);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
_island.reportIslandError.call(void 0, error, { appName, phase: "hydrate" });
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
64
71
|
_island.onIslandNavigate.call(void 0, node, (route) => {
|
|
65
|
-
logger.debug(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${
|
|
66
|
-
|
|
72
|
+
logger.debug(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB: \u043F\u0435\u0440\u0435\u0445\u043E\u0434 \u043D\u0430 \xAB${route.pathname}\xBB`);
|
|
73
|
+
try {
|
|
74
|
+
_preact.render.call(void 0, _preact.h.call(void 0, Island, { onDocument, route }), node);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
_island.reportIslandError.call(void 0, error, { appName, phase: "navigate" });
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
67
79
|
});
|
|
68
80
|
}
|
|
69
81
|
|
package/client.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPreactIsland,
|
|
3
3
|
installIslandResolver
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7GQ7NIUN.js";
|
|
5
5
|
import "./chunk-5JBD5THX.js";
|
|
6
6
|
|
|
7
7
|
// src/client.ts
|
|
8
8
|
import { h, hydrate, render } from "preact";
|
|
9
|
-
import { onIslandNavigate, publishIslandDocument } from "@foxford/den/island";
|
|
9
|
+
import { onIslandNavigate, publishIslandDocument, reportIslandError } from "@foxford/den/island";
|
|
10
10
|
import { log } from "@foxford/logger";
|
|
11
11
|
var logger = log.getLogger("den-preact").getLogger("client");
|
|
12
12
|
var ROOT_MARK = "data-den-root";
|
|
@@ -42,13 +42,15 @@ function hydrateApp(descriptor) {
|
|
|
42
42
|
mountApp(descriptor);
|
|
43
43
|
}
|
|
44
44
|
function mountApp(descriptor) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const appName = (_a = descriptor.name) != null ? _a : "app";
|
|
45
47
|
const node = document.querySelector(`[${ROOT_MARK}="${descriptor.name}"]`);
|
|
46
48
|
if (node === null) {
|
|
47
|
-
logger.error(`\u0443\u0437\u0435\u043B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \xAB${
|
|
49
|
+
logger.error(`\u0443\u0437\u0435\u043B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \xAB${appName}\xBB \u0432 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u2014 \u043E\u0436\u0438\u0432\u043B\u044F\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E`);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
if (hydrated.has(node)) {
|
|
51
|
-
logger.warn(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${
|
|
53
|
+
logger.warn(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB \u0443\u0436\u0435 \u043E\u0436\u0438\u0432\u043B\u0435\u043D\u043E \u2014 \u0432\u0442\u043E\u0440\u043E\u0439 \u0432\u0445\u043E\u0434 \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D`);
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
56
|
hydrated.add(node);
|
|
@@ -57,11 +59,21 @@ function mountApp(descriptor) {
|
|
|
57
59
|
const onDocument = (contribution) => {
|
|
58
60
|
publishIslandDocument(node, contribution);
|
|
59
61
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
try {
|
|
63
|
+
hydrate(h(Island, { denState: readState((_b = descriptor.name) != null ? _b : ""), onDocument, route: currentRoute() }), node);
|
|
64
|
+
logger.info(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB \u043E\u0436\u0438\u0432\u043B\u0435\u043D\u043E`);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
reportIslandError(error, { appName, phase: "hydrate" });
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
62
69
|
onIslandNavigate(node, (route) => {
|
|
63
|
-
logger.debug(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${
|
|
64
|
-
|
|
70
|
+
logger.debug(`\u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${appName}\xBB: \u043F\u0435\u0440\u0435\u0445\u043E\u0434 \u043D\u0430 \xAB${route.pathname}\xBB`);
|
|
71
|
+
try {
|
|
72
|
+
render(h(Island, { onDocument, route }), node);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
reportIslandError(error, { appName, phase: "navigate" });
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
65
77
|
});
|
|
66
78
|
}
|
|
67
79
|
export {
|
package/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkH2QOAMNScjs = require('./chunk-H2QOAMNS.cjs');
|
|
9
9
|
require('./chunk-P4DSWCF6.cjs');
|
|
10
10
|
|
|
11
11
|
// src/render-island.tsx
|
|
@@ -13,7 +13,7 @@ var _preactrendertostring = require('preact-render-to-string');
|
|
|
13
13
|
var _jsxruntime = require('preact/jsx-runtime');
|
|
14
14
|
function renderPreactIsland(descriptor, { container, slots }) {
|
|
15
15
|
const View = descriptor.view;
|
|
16
|
-
const tree = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
16
|
+
const tree = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkH2QOAMNScjs.ContainerProvider, { value: container, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkH2QOAMNScjs.SlotHost, { fills: slots, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, View, {}) }) });
|
|
17
17
|
const serverRender = descriptor.serverRender;
|
|
18
18
|
if (serverRender) {
|
|
19
19
|
return serverRender(tree, (node) => _preactrendertostring.renderToString.call(void 0, node));
|
|
@@ -30,8 +30,8 @@ function renderIslandOnClient() {
|
|
|
30
30
|
}
|
|
31
31
|
function preactAdapter() {
|
|
32
32
|
return {
|
|
33
|
-
createIsland:
|
|
34
|
-
installResolver:
|
|
33
|
+
createIsland: _chunkH2QOAMNScjs.createPreactIsland,
|
|
34
|
+
installResolver: _chunkH2QOAMNScjs.installIslandResolver,
|
|
35
35
|
renderIsland: CLIENT_BUNDLE ? renderIslandOnClient : renderPreactIsland,
|
|
36
36
|
type: "preact"
|
|
37
37
|
};
|
|
@@ -44,4 +44,4 @@ function preactAdapter() {
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
exports.ContainerProvider =
|
|
47
|
+
exports.ContainerProvider = _chunkH2QOAMNScjs.ContainerProvider; exports.Slot = _chunkH2QOAMNScjs.Slot; exports.SlotHost = _chunkH2QOAMNScjs.SlotHost; exports.createPreactIsland = _chunkH2QOAMNScjs.createPreactIsland; exports.installIslandResolver = _chunkH2QOAMNScjs.installIslandResolver; exports.preactAdapter = preactAdapter; exports.useContainer = _chunkH2QOAMNScjs.useContainer;
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxford/den-preact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1-beta-3141d32-20260904",
|
|
4
4
|
"description": "Den Preact view adapter — остров, серверная отрисовка, слоты, пресет сборки",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foxford",
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
"preact",
|
|
9
9
|
"view"
|
|
10
10
|
],
|
|
11
|
+
"homepage": "https://github.com/foxford/frontend-platform",
|
|
12
|
+
"bugs": "https://github.com/foxford/frontend-platform/issues",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/foxford/frontend-platform.git",
|
|
16
|
+
"directory": "packages/den-preact"
|
|
17
|
+
},
|
|
11
18
|
"license": "MIT",
|
|
12
19
|
"author": "Foxford Co",
|
|
13
20
|
"maintainers": [
|
|
@@ -19,7 +26,7 @@
|
|
|
19
26
|
],
|
|
20
27
|
"type": "module",
|
|
21
28
|
"dependencies": {
|
|
22
|
-
"@foxford/den": "^3.2.
|
|
29
|
+
"@foxford/den": "^3.2.5",
|
|
23
30
|
"@foxford/logger": "^1.2.2"
|
|
24
31
|
},
|
|
25
32
|
"peerDependencies": {
|
|
@@ -49,13 +56,18 @@
|
|
|
49
56
|
"import": "./preset.js",
|
|
50
57
|
"require": "./preset.cjs",
|
|
51
58
|
"types": "./preset.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./use-sync-external-store": {
|
|
61
|
+
"import": "./use-sync-external-store.js",
|
|
62
|
+
"require": "./use-sync-external-store.cjs",
|
|
63
|
+
"types": "./use-sync-external-store.d.ts"
|
|
52
64
|
}
|
|
53
65
|
},
|
|
54
66
|
"files": [
|
|
55
67
|
"README.mdx",
|
|
56
68
|
"chunk-5JBD5THX.js",
|
|
57
|
-
"chunk-
|
|
58
|
-
"chunk-
|
|
69
|
+
"chunk-7GQ7NIUN.js",
|
|
70
|
+
"chunk-H2QOAMNS.cjs",
|
|
59
71
|
"chunk-P4DSWCF6.cjs",
|
|
60
72
|
"client.cjs",
|
|
61
73
|
"client.d.cts",
|
|
@@ -69,8 +81,12 @@
|
|
|
69
81
|
"preset.cjs",
|
|
70
82
|
"preset.d.cts",
|
|
71
83
|
"preset.d.ts",
|
|
72
|
-
"preset.js"
|
|
84
|
+
"preset.js",
|
|
85
|
+
"use-sync-external-store.cjs",
|
|
86
|
+
"use-sync-external-store.d.cts",
|
|
87
|
+
"use-sync-external-store.d.ts",
|
|
88
|
+
"use-sync-external-store.js"
|
|
73
89
|
],
|
|
74
|
-
"sha": "
|
|
90
|
+
"sha": "3141d32",
|
|
75
91
|
"scripts": {}
|
|
76
92
|
}
|
package/preset.cjs
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
var _presetvite = require('@preact/preset-vite'); var _presetvite2 = _interopRequireDefault(_presetvite);
|
|
5
5
|
var CLIENT_ENTRY = "@foxford/den-preact/client";
|
|
6
6
|
var STYLED = "styled-components";
|
|
7
|
+
var SHIM = /^use-sync-external-store(\/.*)?$/;
|
|
8
|
+
var SHIM_MODULE = "@foxford/den-preact/use-sync-external-store";
|
|
9
|
+
var useSyncExternalStoreShim = {
|
|
10
|
+
config: () => ({ resolve: { alias: [{ find: SHIM, replacement: SHIM_MODULE }] } }),
|
|
11
|
+
name: "den-preact:use-sync-external-store"
|
|
12
|
+
};
|
|
7
13
|
var runtimeSingleton = {
|
|
8
14
|
config: () => ({
|
|
9
15
|
resolve: { dedupe: ["preact", "preact-render-to-string"] },
|
|
@@ -18,7 +24,11 @@ function preact(options = {}) {
|
|
|
18
24
|
clientEntry: CLIENT_ENTRY,
|
|
19
25
|
// Prefresh выключен: у приложения нет dev-сервера сборщика — `den dev` пересобирает
|
|
20
26
|
// выход и перезапускает процесс.
|
|
21
|
-
plugins: [
|
|
27
|
+
plugins: [
|
|
28
|
+
_presetvite2.default.call(void 0, { babel: { plugins }, prefreshEnabled: false }),
|
|
29
|
+
runtimeSingleton,
|
|
30
|
+
useSyncExternalStoreShim
|
|
31
|
+
],
|
|
22
32
|
// Проверка тут потому, что цена ошибки — МОЛЧАНИЕ. Без сборочной поддержки
|
|
23
33
|
// styled-components считает идентификатор компонента счётчиком: порядок вычисления в
|
|
24
34
|
// серверном и клиентском выходах разный, имена классов расходятся, и это видно только
|
package/preset.js
CHANGED
|
@@ -4,6 +4,12 @@ import "./chunk-5JBD5THX.js";
|
|
|
4
4
|
import preactPlugin from "@preact/preset-vite";
|
|
5
5
|
var CLIENT_ENTRY = "@foxford/den-preact/client";
|
|
6
6
|
var STYLED = "styled-components";
|
|
7
|
+
var SHIM = /^use-sync-external-store(\/.*)?$/;
|
|
8
|
+
var SHIM_MODULE = "@foxford/den-preact/use-sync-external-store";
|
|
9
|
+
var useSyncExternalStoreShim = {
|
|
10
|
+
config: () => ({ resolve: { alias: [{ find: SHIM, replacement: SHIM_MODULE }] } }),
|
|
11
|
+
name: "den-preact:use-sync-external-store"
|
|
12
|
+
};
|
|
7
13
|
var runtimeSingleton = {
|
|
8
14
|
config: () => ({
|
|
9
15
|
resolve: { dedupe: ["preact", "preact-render-to-string"] },
|
|
@@ -18,7 +24,11 @@ function preact(options = {}) {
|
|
|
18
24
|
clientEntry: CLIENT_ENTRY,
|
|
19
25
|
// Prefresh выключен: у приложения нет dev-сервера сборщика — `den dev` пересобирает
|
|
20
26
|
// выход и перезапускает процесс.
|
|
21
|
-
plugins: [
|
|
27
|
+
plugins: [
|
|
28
|
+
preactPlugin({ babel: { plugins }, prefreshEnabled: false }),
|
|
29
|
+
runtimeSingleton,
|
|
30
|
+
useSyncExternalStoreShim
|
|
31
|
+
],
|
|
22
32
|
// Проверка тут потому, что цена ошибки — МОЛЧАНИЕ. Без сборочной поддержки
|
|
23
33
|
// styled-components считает идентификатор компонента счётчиком: порядок вычисления в
|
|
24
34
|
// серверном и клиентском выходах разный, имена классов расходятся, и это видно только
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-P4DSWCF6.cjs');
|
|
2
|
+
|
|
3
|
+
// src/use-sync-external-store.ts
|
|
4
|
+
var _compat = require('preact/compat');
|
|
5
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, _getServerSnapshot, selector, isEqual) {
|
|
6
|
+
const cache = _compat.useRef.call(void 0, { hasValue: false });
|
|
7
|
+
const getSelection = _compat.useMemo.call(void 0, () => {
|
|
8
|
+
let memo = null;
|
|
9
|
+
function select(snapshot) {
|
|
10
|
+
if (memo !== null && Object.is(memo.snapshot, snapshot)) {
|
|
11
|
+
return memo.selection;
|
|
12
|
+
}
|
|
13
|
+
const next = selector(snapshot);
|
|
14
|
+
const previous = memo === null ? cache.current : { hasValue: true, value: memo.selection };
|
|
15
|
+
const selection2 = isEqual !== void 0 && previous.hasValue && isEqual(previous.value, next) ? previous.value : next;
|
|
16
|
+
memo = { selection: selection2, snapshot };
|
|
17
|
+
return selection2;
|
|
18
|
+
}
|
|
19
|
+
return () => select(getSnapshot());
|
|
20
|
+
}, [getSnapshot, isEqual, selector]);
|
|
21
|
+
const selection = _compat.useSyncExternalStore.call(void 0, subscribe, getSelection);
|
|
22
|
+
_compat.useEffect.call(void 0, () => {
|
|
23
|
+
cache.current = { hasValue: true, value: selection };
|
|
24
|
+
}, [selection]);
|
|
25
|
+
_compat.useDebugValue.call(void 0, selection);
|
|
26
|
+
return selection;
|
|
27
|
+
}
|
|
28
|
+
var use_sync_external_store_default = { useSyncExternalStore: _compat.useSyncExternalStore, useSyncExternalStoreWithSelector };
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.default = use_sync_external_store_default; exports.useSyncExternalStore = _compat.useSyncExternalStore; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'preact/compat';
|
|
2
|
+
export { useSyncExternalStore } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `useSyncExternalStore` с выборкой части снимка.
|
|
6
|
+
*
|
|
7
|
+
* @param subscribe - подписка на изменения хранилища
|
|
8
|
+
* @param getSnapshot - снимок хранилища
|
|
9
|
+
* @param _getServerSnapshot - серверный снимок; у preact его роль играет `getSnapshot`
|
|
10
|
+
* @param selector - выборка из снимка
|
|
11
|
+
* @param isEqual - сравнение двух выборок; без него сравниваются ссылки
|
|
12
|
+
*/
|
|
13
|
+
declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, _getServerSnapshot: (() => Snapshot) | undefined, selector: (snapshot: Snapshot) => Selection, isEqual?: (previous: Selection, next: Selection) => boolean): Selection;
|
|
14
|
+
|
|
15
|
+
declare const _default: {
|
|
16
|
+
useSyncExternalStore: typeof useSyncExternalStore;
|
|
17
|
+
useSyncExternalStoreWithSelector: typeof useSyncExternalStoreWithSelector;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { _default as default, useSyncExternalStoreWithSelector };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'preact/compat';
|
|
2
|
+
export { useSyncExternalStore } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `useSyncExternalStore` с выборкой части снимка.
|
|
6
|
+
*
|
|
7
|
+
* @param subscribe - подписка на изменения хранилища
|
|
8
|
+
* @param getSnapshot - снимок хранилища
|
|
9
|
+
* @param _getServerSnapshot - серверный снимок; у preact его роль играет `getSnapshot`
|
|
10
|
+
* @param selector - выборка из снимка
|
|
11
|
+
* @param isEqual - сравнение двух выборок; без него сравниваются ссылки
|
|
12
|
+
*/
|
|
13
|
+
declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, _getServerSnapshot: (() => Snapshot) | undefined, selector: (snapshot: Snapshot) => Selection, isEqual?: (previous: Selection, next: Selection) => boolean): Selection;
|
|
14
|
+
|
|
15
|
+
declare const _default: {
|
|
16
|
+
useSyncExternalStore: typeof useSyncExternalStore;
|
|
17
|
+
useSyncExternalStoreWithSelector: typeof useSyncExternalStoreWithSelector;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { _default as default, useSyncExternalStoreWithSelector };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "./chunk-5JBD5THX.js";
|
|
2
|
+
|
|
3
|
+
// src/use-sync-external-store.ts
|
|
4
|
+
import { useDebugValue, useEffect, useMemo, useRef, useSyncExternalStore } from "preact/compat";
|
|
5
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, _getServerSnapshot, selector, isEqual) {
|
|
6
|
+
const cache = useRef({ hasValue: false });
|
|
7
|
+
const getSelection = useMemo(() => {
|
|
8
|
+
let memo = null;
|
|
9
|
+
function select(snapshot) {
|
|
10
|
+
if (memo !== null && Object.is(memo.snapshot, snapshot)) {
|
|
11
|
+
return memo.selection;
|
|
12
|
+
}
|
|
13
|
+
const next = selector(snapshot);
|
|
14
|
+
const previous = memo === null ? cache.current : { hasValue: true, value: memo.selection };
|
|
15
|
+
const selection2 = isEqual !== void 0 && previous.hasValue && isEqual(previous.value, next) ? previous.value : next;
|
|
16
|
+
memo = { selection: selection2, snapshot };
|
|
17
|
+
return selection2;
|
|
18
|
+
}
|
|
19
|
+
return () => select(getSnapshot());
|
|
20
|
+
}, [getSnapshot, isEqual, selector]);
|
|
21
|
+
const selection = useSyncExternalStore(subscribe, getSelection);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
cache.current = { hasValue: true, value: selection };
|
|
24
|
+
}, [selection]);
|
|
25
|
+
useDebugValue(selection);
|
|
26
|
+
return selection;
|
|
27
|
+
}
|
|
28
|
+
var use_sync_external_store_default = { useSyncExternalStore, useSyncExternalStoreWithSelector };
|
|
29
|
+
export {
|
|
30
|
+
use_sync_external_store_default as default,
|
|
31
|
+
useSyncExternalStore,
|
|
32
|
+
useSyncExternalStoreWithSelector
|
|
33
|
+
};
|