@anansi/core 0.16.2 → 0.16.4
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/CHANGELOG.md +19 -0
- package/dist/client.js +86 -8
- package/dist/client.js.map +1 -1
- package/dist/server.js +35 -35
- package/dist/server.js.map +1 -1
- package/lib/spouts/DocumentComponent.d.ts.map +1 -1
- package/lib/spouts/DocumentComponent.js +4 -4
- package/lib/spouts/antd.server.d.ts.map +1 -1
- package/lib/spouts/antd.server.js +10 -5
- package/lib/spouts/restHooks.d.ts +2 -2
- package/lib/spouts/restHooks.d.ts.map +1 -1
- package/lib/spouts/restHooks.js +10 -8
- package/lib/spouts/restHooks.provider.d.ts +2 -0
- package/lib/spouts/restHooks.provider.d.ts.map +1 -0
- package/lib/spouts/restHooks.provider.js +7 -0
- package/lib/spouts/restHooks.server.d.ts +1 -1
- package/lib/spouts/restHooks.server.d.ts.map +1 -1
- package/lib/spouts/restHooks.server.js +9 -8
- package/package.json +5 -5
- package/src/spouts/DocumentComponent.tsx +2 -3
- package/src/spouts/antd.server.tsx +3 -1
- package/src/spouts/restHooks.provider.tsx +1 -0
- package/src/spouts/restHooks.server.tsx +7 -10
- package/src/spouts/restHooks.tsx +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.16.4](https://github.com/ntucker/anansi/compare/@anansi/core@0.16.3...@anansi/core@0.16.4) (2023-02-09)
|
|
7
|
+
|
|
8
|
+
### 💅 Enhancement
|
|
9
|
+
|
|
10
|
+
* Use unsafe-inline for better legacy browser compat ([595cacb](https://github.com/ntucker/anansi/commit/595cacb9f157537bd0db7b71df8cc5e39dabfd85))
|
|
11
|
+
|
|
12
|
+
### 📦 Package
|
|
13
|
+
|
|
14
|
+
* Update all non-major dependencies ([#1838](https://github.com/ntucker/anansi/issues/1838)) ([0bd6008](https://github.com/ntucker/anansi/commit/0bd60089c57d81801d24fa1927cb50a285dde121))
|
|
15
|
+
* Update JS test packages to ^29.4.2 ([#1842](https://github.com/ntucker/anansi/issues/1842)) ([2a8c989](https://github.com/ntucker/anansi/commit/2a8c989127268c46524558f4c69714df20d6ca58))
|
|
16
|
+
|
|
17
|
+
### [0.16.3](https://github.com/ntucker/anansi/compare/@anansi/core@0.16.2...@anansi/core@0.16.3) (2023-01-30)
|
|
18
|
+
|
|
19
|
+
### 💅 Enhancement
|
|
20
|
+
|
|
21
|
+
* Dynamic import for antd deps ([cc7838a](https://github.com/ntucker/anansi/commit/cc7838a830ae949fb85a6f7d46b4de17ad70b99e))
|
|
22
|
+
* Dynamic import for rest-hooks deps ([a31f409](https://github.com/ntucker/anansi/commit/a31f4097ef068f5db79f7e3ea45a71e450321ac1))
|
|
23
|
+
* lib folder is es6 modules ([b2a4114](https://github.com/ntucker/anansi/commit/b2a411454a7606b378d94dea595d22bb4c7b51ba))
|
|
24
|
+
|
|
6
25
|
### [0.16.2](https://github.com/ntucker/anansi/compare/@anansi/core@0.16.1...@anansi/core@0.16.2) (2023-01-29)
|
|
7
26
|
|
|
8
27
|
### 📦 Package
|
package/dist/client.js
CHANGED
|
@@ -100,6 +100,19 @@ function getDataFromEl(el, key) {
|
|
|
100
100
|
|
|
101
101
|
/***/ }),
|
|
102
102
|
|
|
103
|
+
/***/ "./src/spouts/restHooks.provider.tsx":
|
|
104
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
105
|
+
|
|
106
|
+
"use strict";
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
exports.__esModule = true;
|
|
110
|
+
exports.CacheProvider = void 0;
|
|
111
|
+
var _react = __webpack_require__("@rest-hooks/react");
|
|
112
|
+
exports.CacheProvider = _react.CacheProvider;
|
|
113
|
+
|
|
114
|
+
/***/ }),
|
|
115
|
+
|
|
103
116
|
/***/ "./src/spouts/restHooks.tsx":
|
|
104
117
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
105
118
|
|
|
@@ -109,27 +122,29 @@ function getDataFromEl(el, key) {
|
|
|
109
122
|
var _interopRequireDefault = (__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireDefault.js")["default"]);
|
|
110
123
|
exports.__esModule = true;
|
|
111
124
|
exports["default"] = restHooksSpout;
|
|
125
|
+
var _interopRequireWildcard2 = _interopRequireDefault(__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireWildcard.js"));
|
|
112
126
|
var _react = _interopRequireDefault(__webpack_require__("react"));
|
|
113
|
-
var _react2 = __webpack_require__("@rest-hooks/react");
|
|
114
127
|
var _jsxFileName = "/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.tsx";
|
|
115
|
-
function restHooksSpout(options = {
|
|
116
|
-
getManagers: () => [new _react2.NetworkManager()]
|
|
117
|
-
}) {
|
|
128
|
+
function restHooksSpout(options = {}) {
|
|
118
129
|
return next => async props => {
|
|
119
130
|
const nextProps = await next(props);
|
|
120
|
-
const data
|
|
131
|
+
const [data, {
|
|
132
|
+
CacheProvider
|
|
133
|
+
}] = await Promise.all([props.getInitialData('resthooks'), Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(__webpack_require__("./src/spouts/restHooks.provider.tsx")))]);
|
|
121
134
|
if ( true && !data) {
|
|
122
135
|
console.error('Rest Hooks init data not found');
|
|
136
|
+
} else if (!data) {
|
|
137
|
+
console.info('Rest Hooks init missing');
|
|
123
138
|
}
|
|
124
139
|
return {
|
|
125
140
|
...nextProps,
|
|
126
|
-
app: /*#__PURE__*/_react.default.createElement(
|
|
141
|
+
app: /*#__PURE__*/_react.default.createElement(CacheProvider, {
|
|
127
142
|
initialState: data,
|
|
128
|
-
managers: options.getManagers(),
|
|
143
|
+
managers: options == null ? void 0 : options.getManagers == null ? void 0 : options.getManagers(),
|
|
129
144
|
__self: this,
|
|
130
145
|
__source: {
|
|
131
146
|
fileName: _jsxFileName,
|
|
132
|
-
lineNumber:
|
|
147
|
+
lineNumber: 26,
|
|
133
148
|
columnNumber: 9
|
|
134
149
|
}
|
|
135
150
|
}, nextProps.app)
|
|
@@ -247,6 +262,69 @@ function _interopRequireDefault(obj) {
|
|
|
247
262
|
}
|
|
248
263
|
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
249
264
|
|
|
265
|
+
/***/ }),
|
|
266
|
+
|
|
267
|
+
/***/ "../../node_modules/@babel/runtime/helpers/interopRequireWildcard.js":
|
|
268
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
269
|
+
|
|
270
|
+
var _typeof = (__webpack_require__("../../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
|
|
271
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
272
|
+
if (typeof WeakMap !== "function") return null;
|
|
273
|
+
var cacheBabelInterop = new WeakMap();
|
|
274
|
+
var cacheNodeInterop = new WeakMap();
|
|
275
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
|
|
276
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
277
|
+
})(nodeInterop);
|
|
278
|
+
}
|
|
279
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
280
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
281
|
+
return obj;
|
|
282
|
+
}
|
|
283
|
+
if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
|
|
284
|
+
return {
|
|
285
|
+
"default": obj
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
289
|
+
if (cache && cache.has(obj)) {
|
|
290
|
+
return cache.get(obj);
|
|
291
|
+
}
|
|
292
|
+
var newObj = {};
|
|
293
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
294
|
+
for (var key in obj) {
|
|
295
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
296
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
297
|
+
if (desc && (desc.get || desc.set)) {
|
|
298
|
+
Object.defineProperty(newObj, key, desc);
|
|
299
|
+
} else {
|
|
300
|
+
newObj[key] = obj[key];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
newObj["default"] = obj;
|
|
305
|
+
if (cache) {
|
|
306
|
+
cache.set(obj, newObj);
|
|
307
|
+
}
|
|
308
|
+
return newObj;
|
|
309
|
+
}
|
|
310
|
+
module.exports = _interopRequireWildcard, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
311
|
+
|
|
312
|
+
/***/ }),
|
|
313
|
+
|
|
314
|
+
/***/ "../../node_modules/@babel/runtime/helpers/typeof.js":
|
|
315
|
+
/***/ ((module) => {
|
|
316
|
+
|
|
317
|
+
function _typeof(obj) {
|
|
318
|
+
"@babel/helpers - typeof";
|
|
319
|
+
|
|
320
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
321
|
+
return typeof obj;
|
|
322
|
+
} : function (obj) {
|
|
323
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
324
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
325
|
+
}
|
|
326
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
327
|
+
|
|
250
328
|
/***/ })
|
|
251
329
|
|
|
252
330
|
/******/ });
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","mappings":";;;;;;;;;;;AAAA;AAEA;AAIA;AAAA;AACA;AACA;AAAA;AAAA;AAEA;AACA;;;;;;;;;;;;ACXA;AAGA;AAAA;AAAA;AAAA;AAEA;;;;;;;;;;;;ACAA;AAIA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;ACZA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;;;;;;;;;;;;;;ACnCA;AAAA;AAIA;AAGA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;;;;;;;;;;;;;AC1BA;AACA;AAEA;AAAA;AAIA;AAaA;AAGA;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAEA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;;;;;;;;ACpDA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACvBA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA","sources":["/home/ntucker/src/anansi/packages/core/src/floodSpouts.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/app.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/document.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/router.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@anansi/router\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"history\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react-dom/client\"","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireDefault.js","/home/ntucker/src/anansi/packages/core/webpack/bootstrap","/home/ntucker/src/anansi/packages/core/src/index.ts"],"sourcesContent":["import { hydrateRoot } from 'react-dom/client';\n\nexport default async function floodSpouts(\n spouts: (props: Record<string, unknown>) => Promise<{\n app: JSX.Element;\n }>,\n { rootId = 'anansi-root' }: { rootId?: string } = {},\n) {\n const { app } = await spouts({});\n\n hydrateRoot(document.getElementById(rootId) ?? document, app);\n}\n","const appSpout =\n (app: JSX.Element) =>\n <P extends Record<string, unknown>>(props: P) =>\n Promise.resolve({ ...props, app });\n\nexport default appSpout;\n","import type { Route } from '@anansi/router';\nimport React from 'react';\n\nimport type { ClientSpout } from './types';\n\nexport default function documentSpout(options: {\n head?: React.ReactNode;\n title: string;\n}): ClientSpout {\n return next => async props => {\n const nextProps = await next(props);\n\n return nextProps;\n };\n}\n","import type { ClientSpout } from './types';\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}): ClientSpout<\n Record<string, unknown>,\n { getInitialData: (key: string) => Promise<any> }\n> {\n return next => async props => {\n const getInitialData = (key: string) => {\n const globalId = `${id}.${key}`;\n return new Promise<any>((resolve, reject) => {\n let el: HTMLScriptElement | null;\n if ((el = document.getElementById(globalId) as any)) {\n resolve(getDataFromEl(el, globalId));\n return;\n }\n document.addEventListener('DOMContentLoaded', () => {\n el = document.getElementById(globalId) as any;\n if (el) resolve(getDataFromEl(el, globalId));\n else reject(new Error(`failed to find DOM with ${key} state`));\n });\n });\n };\n return { ...(await next({ ...props, getInitialData })), getInitialData };\n };\n}\n\nfunction getDataFromEl(el: HTMLScriptElement, key: string) {\n if (el.text === undefined) {\n console.error(\n `#${key} is completely empty. This could be due to CSP issues.`,\n );\n }\n return el?.text ? JSON.parse(el?.text) : undefined;\n}\n","import { CacheProvider, Manager, NetworkManager } from '@rest-hooks/react';\n\nimport type { ClientSpout } from './types';\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n): ClientSpout<{ getInitialData: (key: string) => Promise<any> }> {\n return next => async props => {\n const nextProps = await next(props);\n const data = await props.getInitialData('resthooks');\n\n if (process.env.NODE_ENV !== 'production' && !data) {\n console.error('Rest Hooks init data not found');\n }\n\n return {\n ...nextProps,\n app: (\n <CacheProvider initialState={data} managers={options.getManagers()}>\n {nextProps.app}\n </CacheProvider>\n ),\n };\n };\n}\n","import { Route, RouteProvider, RouteController } from '@anansi/router';\nimport { createBrowserHistory } from 'history';\nimport type { Update } from 'history';\nimport React from 'react';\n\nimport type { CreateRouter, ClientSpout } from './types';\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\n onChange?: (update: Update, callback: () => void | undefined) => void;\n}): ClientSpout<\n Record<string, unknown>,\n {\n matchedRoutes: Route<ResolveWith, any>[];\n } & {\n router: RouteController<Route<ResolveWith, any>>;\n }\n> {\n const createRouteComponent = (\n router: RouteController<Route<ResolveWith, any>>,\n ) =>\n function Router({ children }: { children: React.ReactNode }) {\n const resolveWith = options.useResolveWith();\n\n return (\n <RouteProvider\n router={router}\n resolveWith={resolveWith}\n onChange={options.onChange}\n >\n {children}\n </RouteProvider>\n );\n };\n\n return next => async props => {\n const history = createBrowserHistory();\n const router = options.createRouter(history);\n const matchedRoutes = router.getMatchedRoutes(history.location.pathname);\n\n const nextProps = await next({ ...props, matchedRoutes, router });\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\n };\n}\n","module.exports = require(\"@anansi/router\");","module.exports = require(\"@rest-hooks/react\");","module.exports = require(\"history\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/client\");","function _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n \"default\": obj\n };\n}\nmodule.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","export { default as floodSpouts } from './floodSpouts';\nexport { default as documentSpout } from './spouts/document';\nexport { default as restHooksSpout } from './spouts/restHooks';\nexport { default as routerSpout } from './spouts/router';\nexport { default as JSONSpout } from './spouts/json';\nexport { default as appSpout } from './spouts/app';\nexport type { ServerProps } from './spouts/types';\nexport type { ClientSpout as Spout } from './spouts/types';\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"client.js","mappings":";;;;;;;;;;;AAAA;AAEA;AAIA;AAAA;AACA;AACA;AAAA;AAAA;AAEA;AACA;;;;;;;;;;;;ACXA;AAGA;AAAA;AAAA;AAAA;AAEA;;;;;;;;;;;;ACAA;AAIA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;ACZA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;;;;;;;;;;;;ACnCA;AAAA;;;;;;;;;;;;;;;;ACIA;AAKA;AACA;AACA;AAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;;;;;;;;;;;;;AC/BA;AACA;AAEA;AAAA;AAIA;AAaA;AAGA;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAEA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;;;;;;;;ACpDA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACvBA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA","sources":["/home/ntucker/src/anansi/packages/core/src/floodSpouts.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/app.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/document.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.provider.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/router.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@anansi/router\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"history\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react-dom/client\"","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireDefault.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireWildcard.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/typeof.js","/home/ntucker/src/anansi/packages/core/webpack/bootstrap","/home/ntucker/src/anansi/packages/core/src/index.ts"],"sourcesContent":["import { hydrateRoot } from 'react-dom/client';\n\nexport default async function floodSpouts(\n spouts: (props: Record<string, unknown>) => Promise<{\n app: JSX.Element;\n }>,\n { rootId = 'anansi-root' }: { rootId?: string } = {},\n) {\n const { app } = await spouts({});\n\n hydrateRoot(document.getElementById(rootId) ?? document, app);\n}\n","const appSpout =\n (app: JSX.Element) =>\n <P extends Record<string, unknown>>(props: P) =>\n Promise.resolve({ ...props, app });\n\nexport default appSpout;\n","import type { Route } from '@anansi/router';\nimport React from 'react';\n\nimport type { ClientSpout } from './types';\n\nexport default function documentSpout(options: {\n head?: React.ReactNode;\n title: string;\n}): ClientSpout {\n return next => async props => {\n const nextProps = await next(props);\n\n return nextProps;\n };\n}\n","import type { ClientSpout } from './types';\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}): ClientSpout<\n Record<string, unknown>,\n { getInitialData: (key: string) => Promise<any> }\n> {\n return next => async props => {\n const getInitialData = (key: string) => {\n const globalId = `${id}.${key}`;\n return new Promise<any>((resolve, reject) => {\n let el: HTMLScriptElement | null;\n if ((el = document.getElementById(globalId) as any)) {\n resolve(getDataFromEl(el, globalId));\n return;\n }\n document.addEventListener('DOMContentLoaded', () => {\n el = document.getElementById(globalId) as any;\n if (el) resolve(getDataFromEl(el, globalId));\n else reject(new Error(`failed to find DOM with ${key} state`));\n });\n });\n };\n return { ...(await next({ ...props, getInitialData })), getInitialData };\n };\n}\n\nfunction getDataFromEl(el: HTMLScriptElement, key: string) {\n if (el.text === undefined) {\n console.error(\n `#${key} is completely empty. This could be due to CSP issues.`,\n );\n }\n return el?.text ? JSON.parse(el?.text) : undefined;\n}\n","export { CacheProvider } from '@rest-hooks/react';\n","import { type Manager } from '@rest-hooks/react';\n\nimport type { ClientSpout } from './types';\n\nexport default function restHooksSpout(\n options: {\n getManagers?: () => Manager[];\n } = {},\n): ClientSpout<{ getInitialData: (key: string) => Promise<any> }> {\n return next => async props => {\n const nextProps = await next(props);\n const [data, { CacheProvider }] = await Promise.all([\n props.getInitialData('resthooks'),\n import('./restHooks.provider'),\n ]);\n\n if (process.env.NODE_ENV !== 'production' && !data) {\n console.error('Rest Hooks init data not found');\n } else if (!data) {\n console.info('Rest Hooks init missing');\n }\n\n return {\n ...nextProps,\n app: (\n <CacheProvider initialState={data} managers={options?.getManagers?.()}>\n {nextProps.app}\n </CacheProvider>\n ),\n };\n };\n}\n","import { Route, RouteProvider, RouteController } from '@anansi/router';\nimport { createBrowserHistory } from 'history';\nimport type { Update } from 'history';\nimport React from 'react';\n\nimport type { CreateRouter, ClientSpout } from './types';\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\n onChange?: (update: Update, callback: () => void | undefined) => void;\n}): ClientSpout<\n Record<string, unknown>,\n {\n matchedRoutes: Route<ResolveWith, any>[];\n } & {\n router: RouteController<Route<ResolveWith, any>>;\n }\n> {\n const createRouteComponent = (\n router: RouteController<Route<ResolveWith, any>>,\n ) =>\n function Router({ children }: { children: React.ReactNode }) {\n const resolveWith = options.useResolveWith();\n\n return (\n <RouteProvider\n router={router}\n resolveWith={resolveWith}\n onChange={options.onChange}\n >\n {children}\n </RouteProvider>\n );\n };\n\n return next => async props => {\n const history = createBrowserHistory();\n const router = options.createRouter(history);\n const matchedRoutes = router.getMatchedRoutes(history.location.pathname);\n\n const nextProps = await next({ ...props, matchedRoutes, router });\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\n };\n}\n","module.exports = require(\"@anansi/router\");","module.exports = require(\"@rest-hooks/react\");","module.exports = require(\"history\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/client\");","function _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n \"default\": obj\n };\n}\nmodule.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction _getRequireWildcardCache(nodeInterop) {\n if (typeof WeakMap !== \"function\") return null;\n var cacheBabelInterop = new WeakMap();\n var cacheNodeInterop = new WeakMap();\n return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {\n return nodeInterop ? cacheNodeInterop : cacheBabelInterop;\n })(nodeInterop);\n}\nfunction _interopRequireWildcard(obj, nodeInterop) {\n if (!nodeInterop && obj && obj.__esModule) {\n return obj;\n }\n if (obj === null || _typeof(obj) !== \"object\" && typeof obj !== \"function\") {\n return {\n \"default\": obj\n };\n }\n var cache = _getRequireWildcardCache(nodeInterop);\n if (cache && cache.has(obj)) {\n return cache.get(obj);\n }\n var newObj = {};\n var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;\n for (var key in obj) {\n if (key !== \"default\" && Object.prototype.hasOwnProperty.call(obj, key)) {\n var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;\n if (desc && (desc.get || desc.set)) {\n Object.defineProperty(newObj, key, desc);\n } else {\n newObj[key] = obj[key];\n }\n }\n }\n newObj[\"default\"] = obj;\n if (cache) {\n cache.set(obj, newObj);\n }\n return newObj;\n}\nmodule.exports = _interopRequireWildcard, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return (module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports), _typeof(obj);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","export { default as floodSpouts } from './floodSpouts';\nexport { default as documentSpout } from './spouts/document';\nexport { default as restHooksSpout } from './spouts/restHooks';\nexport { default as routerSpout } from './spouts/router';\nexport { default as JSONSpout } from './spouts/json';\nexport { default as appSpout } from './spouts/app';\nexport type { ServerProps } from './spouts/types';\nexport type { ClientSpout as Spout } from './spouts/types';\n"],"names":[],"sourceRoot":""}
|
package/dist/server.js
CHANGED
|
@@ -98,22 +98,16 @@ function Document({
|
|
|
98
98
|
const policy = {
|
|
99
99
|
...csPolicy
|
|
100
100
|
};
|
|
101
|
-
if (nonce &&
|
|
102
|
-
// nonces negate 'unsafe-inline' so do not add it
|
|
103
|
-
|
|
104
|
-
if (typeof policy['script-src'] === 'string') {
|
|
105
|
-
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
106
|
-
} else {
|
|
107
|
-
policy['script-src'] = [...policy['script-src'], `'nonce-${nonce}'`];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
101
|
+
if (nonce &&
|
|
102
|
+
// nonces negate 'unsafe-inline' so do not add it in development to keep things easier
|
|
103
|
+
"development" === 'production') {}
|
|
110
104
|
cspMeta = /*#__PURE__*/_react.default.createElement("meta", {
|
|
111
105
|
httpEquiv: "Content-Security-Policy",
|
|
112
106
|
content: (0, _csp.buildPolicy)(policy),
|
|
113
107
|
__self: this,
|
|
114
108
|
__source: {
|
|
115
109
|
fileName: _jsxFileName,
|
|
116
|
-
lineNumber:
|
|
110
|
+
lineNumber: 47,
|
|
117
111
|
columnNumber: 7
|
|
118
112
|
}
|
|
119
113
|
});
|
|
@@ -122,14 +116,14 @@ function Document({
|
|
|
122
116
|
__self: this,
|
|
123
117
|
__source: {
|
|
124
118
|
fileName: _jsxFileName,
|
|
125
|
-
lineNumber:
|
|
119
|
+
lineNumber: 51,
|
|
126
120
|
columnNumber: 5
|
|
127
121
|
}
|
|
128
122
|
}, /*#__PURE__*/_react.default.createElement("head", {
|
|
129
123
|
__self: this,
|
|
130
124
|
__source: {
|
|
131
125
|
fileName: _jsxFileName,
|
|
132
|
-
lineNumber:
|
|
126
|
+
lineNumber: 52,
|
|
133
127
|
columnNumber: 7
|
|
134
128
|
}
|
|
135
129
|
}, /*#__PURE__*/_react.default.createElement("meta", {
|
|
@@ -137,7 +131,7 @@ function Document({
|
|
|
137
131
|
__self: this,
|
|
138
132
|
__source: {
|
|
139
133
|
fileName: _jsxFileName,
|
|
140
|
-
lineNumber:
|
|
134
|
+
lineNumber: 53,
|
|
141
135
|
columnNumber: 9
|
|
142
136
|
}
|
|
143
137
|
}), cspMeta, head, extraStyle, assets.map((asset, i) => /*#__PURE__*/_react.default.createElement("link", {
|
|
@@ -147,21 +141,21 @@ function Document({
|
|
|
147
141
|
__self: this,
|
|
148
142
|
__source: {
|
|
149
143
|
fileName: _jsxFileName,
|
|
150
|
-
lineNumber:
|
|
144
|
+
lineNumber: 58,
|
|
151
145
|
columnNumber: 11
|
|
152
146
|
}
|
|
153
147
|
})), /*#__PURE__*/_react.default.createElement("title", {
|
|
154
148
|
__self: this,
|
|
155
149
|
__source: {
|
|
156
150
|
fileName: _jsxFileName,
|
|
157
|
-
lineNumber:
|
|
151
|
+
lineNumber: 60,
|
|
158
152
|
columnNumber: 9
|
|
159
153
|
}
|
|
160
154
|
}, title)), /*#__PURE__*/_react.default.createElement("body", {
|
|
161
155
|
__self: this,
|
|
162
156
|
__source: {
|
|
163
157
|
fileName: _jsxFileName,
|
|
164
|
-
lineNumber:
|
|
158
|
+
lineNumber: 62,
|
|
165
159
|
columnNumber: 7
|
|
166
160
|
}
|
|
167
161
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -169,7 +163,7 @@ function Document({
|
|
|
169
163
|
__self: this,
|
|
170
164
|
__source: {
|
|
171
165
|
fileName: _jsxFileName,
|
|
172
|
-
lineNumber:
|
|
166
|
+
lineNumber: 63,
|
|
173
167
|
columnNumber: 9
|
|
174
168
|
}
|
|
175
169
|
}, children), scripts, assets.filter(({
|
|
@@ -183,7 +177,7 @@ function Document({
|
|
|
183
177
|
__self: this,
|
|
184
178
|
__source: {
|
|
185
179
|
fileName: _jsxFileName,
|
|
186
|
-
lineNumber:
|
|
180
|
+
lineNumber: 68,
|
|
187
181
|
columnNumber: 13
|
|
188
182
|
}
|
|
189
183
|
}))));
|
|
@@ -195,7 +189,7 @@ Document.defaultProps = {
|
|
|
195
189
|
__self: void 0,
|
|
196
190
|
__source: {
|
|
197
191
|
fileName: _jsxFileName,
|
|
198
|
-
lineNumber:
|
|
192
|
+
lineNumber: 77,
|
|
199
193
|
columnNumber: 7
|
|
200
194
|
}
|
|
201
195
|
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
@@ -204,7 +198,7 @@ Document.defaultProps = {
|
|
|
204
198
|
__self: void 0,
|
|
205
199
|
__source: {
|
|
206
200
|
fileName: _jsxFileName,
|
|
207
|
-
lineNumber:
|
|
201
|
+
lineNumber: 78,
|
|
208
202
|
columnNumber: 7
|
|
209
203
|
}
|
|
210
204
|
})),
|
|
@@ -224,24 +218,29 @@ Document.defaultProps = {
|
|
|
224
218
|
var _interopRequireDefault = (__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireDefault.js")["default"]);
|
|
225
219
|
exports.__esModule = true;
|
|
226
220
|
exports["default"] = antdSpout;
|
|
227
|
-
var
|
|
221
|
+
var _interopRequireWildcard2 = _interopRequireDefault(__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireWildcard.js"));
|
|
228
222
|
var _react = _interopRequireDefault(__webpack_require__("react"));
|
|
229
223
|
var _jsxFileName = "/home/ntucker/src/anansi/packages/core/src/spouts/antd.server.tsx";
|
|
230
224
|
function antdSpout() {
|
|
231
225
|
return next => async props => {
|
|
232
226
|
var _nextProps$scripts;
|
|
233
|
-
const
|
|
227
|
+
const {
|
|
228
|
+
createCache,
|
|
229
|
+
extractStyle,
|
|
230
|
+
StyleProvider
|
|
231
|
+
} = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(__webpack_require__("@ant-design/cssinjs")));
|
|
232
|
+
const cache = createCache();
|
|
234
233
|
const nextProps = await next(props);
|
|
235
234
|
const scripts = (_nextProps$scripts = nextProps.scripts) != null ? _nextProps$scripts : [];
|
|
236
235
|
const AntdSheets = () => {
|
|
237
236
|
return /*#__PURE__*/_react.default.createElement("script", {
|
|
238
237
|
dangerouslySetInnerHTML: {
|
|
239
|
-
__html: `</script>${
|
|
238
|
+
__html: `</script>${extractStyle(cache)}<script>`
|
|
240
239
|
},
|
|
241
240
|
__self: this,
|
|
242
241
|
__source: {
|
|
243
242
|
fileName: _jsxFileName,
|
|
244
|
-
lineNumber:
|
|
243
|
+
lineNumber: 28,
|
|
245
244
|
columnNumber: 9
|
|
246
245
|
}
|
|
247
246
|
});
|
|
@@ -252,18 +251,18 @@ function antdSpout() {
|
|
|
252
251
|
__self: this,
|
|
253
252
|
__source: {
|
|
254
253
|
fileName: _jsxFileName,
|
|
255
|
-
lineNumber:
|
|
254
|
+
lineNumber: 37,
|
|
256
255
|
columnNumber: 18
|
|
257
256
|
}
|
|
258
257
|
}));
|
|
259
258
|
return {
|
|
260
259
|
...nextProps,
|
|
261
|
-
app: /*#__PURE__*/_react.default.createElement(
|
|
260
|
+
app: /*#__PURE__*/_react.default.createElement(StyleProvider, {
|
|
262
261
|
cache: cache,
|
|
263
262
|
__self: this,
|
|
264
263
|
__source: {
|
|
265
264
|
fileName: _jsxFileName,
|
|
266
|
-
lineNumber:
|
|
265
|
+
lineNumber: 41,
|
|
267
266
|
columnNumber: 12
|
|
268
267
|
}
|
|
269
268
|
}, nextProps.app),
|
|
@@ -504,16 +503,17 @@ function prefetchSpout(field) {
|
|
|
504
503
|
var _interopRequireDefault = (__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireDefault.js")["default"]);
|
|
505
504
|
exports.__esModule = true;
|
|
506
505
|
exports["default"] = restHooksSpout;
|
|
506
|
+
var _interopRequireWildcard2 = _interopRequireDefault(__webpack_require__("../../node_modules/@babel/runtime/helpers/interopRequireWildcard.js"));
|
|
507
507
|
var _react = _interopRequireDefault(__webpack_require__("react"));
|
|
508
|
-
var _react2 = __webpack_require__("@rest-hooks/react");
|
|
509
|
-
var _ssr = __webpack_require__("@rest-hooks/ssr");
|
|
510
508
|
var _jsxFileName = "/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.server.tsx";
|
|
511
|
-
function restHooksSpout(options = {
|
|
512
|
-
getManagers: () => [new _react2.NetworkManager()]
|
|
513
|
-
}) {
|
|
514
|
-
const managers = options.getManagers();
|
|
509
|
+
function restHooksSpout(options = {}) {
|
|
515
510
|
return next => async props => {
|
|
516
|
-
|
|
511
|
+
var _options$getManagers;
|
|
512
|
+
const managers = (_options$getManagers = options == null ? void 0 : options.getManagers == null ? void 0 : options.getManagers()) != null ? _options$getManagers : [new (await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(__webpack_require__("@rest-hooks/react")))).NetworkManager()];
|
|
513
|
+
const {
|
|
514
|
+
createPersistedStore
|
|
515
|
+
} = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(__webpack_require__("@rest-hooks/ssr")));
|
|
516
|
+
const [ServerCacheProvider, useReadyCacheState, controller, store] = createPersistedStore(managers);
|
|
517
517
|
const nextProps = await next({
|
|
518
518
|
...props,
|
|
519
519
|
controller,
|
|
@@ -529,7 +529,7 @@ function restHooksSpout(options = {
|
|
|
529
529
|
__self: this,
|
|
530
530
|
__source: {
|
|
531
531
|
fileName: _jsxFileName,
|
|
532
|
-
lineNumber:
|
|
532
|
+
lineNumber: 34,
|
|
533
533
|
columnNumber: 12
|
|
534
534
|
}
|
|
535
535
|
}, nextProps.app),
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","mappings":";;;;;;;;;;;;AAAA;AACA;AAKA;AAKA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACxDA;AAAA;AAAA;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAAA;AAA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ACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AChDA;AACA;AAWA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACrCA;AAMA;AAAA;AAKA;AAGA;AAAA;AAMA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AC1CA;AACA;AACA;AAAA;AAIA;AAYA;AAGA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtDA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACvBA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA","sources":["/home/ntucker/src/anansi/packages/core/src/laySpouts.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/DocumentComponent.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/antd.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/app.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/csp.ts","/home/ntucker/src/anansi/packages/core/src/spouts/document.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/prefetch.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/router.server.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@anansi/router\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@ant-design/cssinjs\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/ssr\"","/home/ntucker/src/anansi/packages/core/external commonjs \"history\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react-dom/server\"","/home/ntucker/src/anansi/packages/core/external node-commonjs \"crypto\"","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireDefault.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireWildcard.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/typeof.js","/home/ntucker/src/anansi/packages/core/webpack/bootstrap","/home/ntucker/src/anansi/packages/core/src/index.server.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { renderToPipeableStream as reactRender } from 'react-dom/server';\n\nimport { Render } from './scripts/types';\nimport { ServerProps } from './spouts/types';\n\nexport default function laySpouts(\n spouts: (props: ServerProps) => Promise<{\n app: JSX.Element;\n }>,\n {\n timeoutMS = 10000,\n onError,\n }: { timeoutMS?: number; onError?: (error: unknown) => void } = {},\n) {\n const render: Render = async (clientManifest, req, res) => {\n const nonce = crypto.randomBytes(16).toString('base64');\n\n try {\n const { app } = await spouts({ clientManifest, req, res, nonce });\n\n let didError = false;\n const { pipe, abort } = reactRender(app, {\n nonce,\n //bootstrapScripts: assets.filter(asset => asset.endsWith('.js')),\n onShellReady() {\n //managers.forEach(manager => manager.cleanup());\n // If something errored before we started streaming, we set the error code appropriately.\n res.statusCode = didError ? 500 : 200;\n res.setHeader('Content-type', 'text/html');\n pipe(res);\n },\n onShellError() {\n didError = true;\n res.statusCode = 500;\n pipe(res);\n },\n onError(e: any) {\n didError = true;\n console.error(e);\n res.statusCode = 500;\n //pipe(res); Removing this avoids, \"React currently only supports piping to one writable stream.\"\n if (onError) onError(e);\n },\n });\n // Abandon and switch to client rendering if enough time passes.\n // Try lowering this to see the client recover.\n setTimeout(\n () => (abort as any)(`Timeout of ${timeoutMS}ms exceeded`),\n timeoutMS,\n );\n } catch (e: unknown) {\n if (onError) onError(e);\n throw e;\n }\n };\n return render;\n}\n","import type { Policy } from './csp';\nimport { buildPolicy } from './csp';\n\ntype Props = {\n children: React.ReactNode;\n assets: { href: string; as?: string; rel?: string }[];\n head: React.ReactNode;\n extraStyle: React.ReactNode;\n scripts: React.ReactNode;\n title: string;\n rootId: string;\n charSet: string;\n csPolicy?: Policy;\n nonce?: string | undefined;\n};\n\nexport default function Document({\n assets,\n head,\n children,\n title,\n rootId,\n charSet,\n csPolicy,\n nonce,\n scripts,\n extraStyle,\n}: Props) {\n let cspMeta: null | React.ReactNode = null;\n if (csPolicy) {\n // add nonce to policy\n const policy = {\n ...csPolicy,\n };\n if (\n nonce &&\n // nonces negate 'unsafe-inline' so do not add it if that directive exists\n (!policy['script-src'] ||\n !policy['script-src'].includes(\"'unsafe-inline'\"))\n ) {\n if (typeof policy['script-src'] === 'string') {\n policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];\n } else {\n policy['script-src'] = [...policy['script-src'], `'nonce-${nonce}'`];\n }\n }\n cspMeta = (\n <meta httpEquiv=\"Content-Security-Policy\" content={buildPolicy(policy)} />\n );\n }\n return (\n <html>\n <head>\n <meta charSet={charSet} />\n {cspMeta}\n {head}\n {extraStyle}\n {assets.map((asset, i) => (\n <link key={i} rel=\"preload\" {...asset} />\n ))}\n <title>{title}</title>\n </head>\n <body>\n <div id={rootId}>{children}</div>\n {scripts}\n {assets\n .filter(({ href }) => href.endsWith('.js'))\n .map(({ href }, i) => (\n <script key={i} src={href} async />\n ))}\n </body>\n </html>\n );\n}\nDocument.defaultProps = {\n head: (\n <>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <link\n rel=\"shortcut icon\"\n href={`${process.env.WEBPACK_PUBLIC_PATH ?? '/'}favicon.ico`}\n />\n </>\n ),\n charSet: 'utf-8',\n rootId: 'anansi-root',\n scripts: null,\n};\n","import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';\nimport React from 'react';\n\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n extraStyle?: React.ReactNode[];\n};\n\nexport default function antdSpout(): ServerSpout<\n Record<string, unknown>,\n Record<string, unknown>,\n NeededNext\n> {\n return next => async props => {\n const cache = createCache();\n\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n\n const AntdSheets = (): JSX.Element => {\n return (\n <script\n dangerouslySetInnerHTML={{\n __html: `</script>${extractStyle(cache)}<script>`,\n }}\n />\n );\n };\n // unfortunately we have to inject this after the entire content has streamed in or it doesn't correctly populate\n // see: https://github.com/ant-design/cssinjs/issues/79\n scripts.push(<AntdSheets />);\n\n return {\n ...nextProps,\n app: <StyleProvider cache={cache}>{nextProps.app}</StyleProvider>,\n scripts,\n };\n };\n}\n","import { ServerProps } from './types';\n\nconst appSpout =\n (app: JSX.Element) =>\n <P extends ServerProps>(props: P) =>\n Promise.resolve({ ...props, app });\n\nexport default appSpout;\n","export interface Policy {\n [directive: string]: string | string[];\n}\n\n// TODO: memoize this\nexport function buildPolicy(policyObj: Policy) {\n return Object.keys(policyObj)\n .map(key => {\n const val = Array.isArray(policyObj[key])\n ? [...new Set(policyObj[key]).values()].filter(v => v).join(' ')\n : policyObj[key];\n\n // move strict dynamic to the end of the policy if it exists to be backwards compatible with csp2\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#strict-dynamic\n if (typeof val === 'string' && val.includes(\"'strict-dynamic'\")) {\n const newVal = `${val\n .replace(/\\s?'strict-dynamic'\\s?/gi, ' ')\n .trim()} 'strict-dynamic'`;\n return `${key} ${newVal}`;\n }\n\n return `${key} ${val}`;\n })\n .join('; ');\n}\n","import type { Route } from '@anansi/router';\nimport React from 'react';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n matchedRoutes: Route<any>[];\n title?: string;\n scripts?: React.ReactNode[];\n extraStyle?: React.ReactNode[];\n};\n\nexport default function DocumentSpout(options: {\n head?: React.ReactNode;\n title: string;\n rootId?: string;\n charSet?: string;\n csPolicy?: Policy;\n}): ServerSpout<Record<string, unknown>, Record<string, unknown>, NeededNext> {\n return next => async props => {\n const nextProps = await next(props);\n\n const publicPath = props.clientManifest.publicPath;\n\n if (\n Object.keys(props.clientManifest?.entrypoints ?? {}).length < 1 ||\n publicPath === undefined\n )\n throw new Error('Manifest missing entries needed');\n\n // TODO: consider using this package for build stats in future:\n // https://github.com/facebook/react/tree/main/packages/react-server-dom-webpack\n const assetMap = (assets: { name: string; size?: number }[]) =>\n assets.map(({ name }) => `${publicPath}${name}`);\n\n const assetList: string[] = [];\n Object.values(props.clientManifest?.entrypoints ?? {}).forEach(\n entrypoint => {\n assetList.push(...assetMap(entrypoint.assets ?? []));\n },\n );\n new Set(\n assetMap(\n Object.values(props.clientManifest.namedChunkGroups ?? {})\n .filter(({ name }) =>\n nextProps.matchedRoutes.some(route => name?.includes(route.name)),\n )\n .flatMap(chunk => [\n ...(chunk.assets ?? []),\n // any chunk preloads\n ...childrenAssets(chunk),\n ]),\n ),\n ).forEach(asset => assetList.push(asset));\n\n // find additional assets to preload based on matched route\n const assets: {\n href: string;\n as?: string | undefined;\n rel?: string | undefined;\n }[] = assetList\n .filter(asset => !asset.endsWith('.hot-update.js'))\n .map(asset =>\n asset.endsWith('.css')\n ? { href: asset, rel: 'stylesheet' }\n : asset.endsWith('.js')\n ? { href: asset, as: 'script' }\n : { href: asset },\n );\n\n return {\n ...nextProps,\n app: (\n <Document\n {...options}\n extraStyle={nextProps.extraStyle}\n title={nextProps.title ?? options.title}\n assets={assets}\n rootId={options.rootId}\n nonce={props.nonce}\n csPolicy={options.csPolicy}\n scripts={nextProps.scripts}\n >\n {nextProps.app}\n </Document>\n ),\n };\n };\n}\n\nfunction childrenAssets(chunk: StatsChunkGroup) {\n return chunk.children\n ? Object.values(chunk.children).flatMap(preload =>\n preload.flatMap(c => c.assets ?? []),\n )\n : [];\n}\n","import React, { Suspense } from 'react';\n\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n};\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}): ServerSpout<\n Record<string, unknown>,\n Record<string, unknown>,\n NeededNext\n> {\n return next => async props => {\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n\n Object.entries(nextProps.initData ?? {}).forEach(([key, useData]) => {\n const globalId = `${id}.${key}`;\n const Script = () => {\n const data: any = useData();\n try {\n const encoded = JSON.stringify(data);\n return (\n <script\n id={globalId}\n type=\"application/json\"\n dangerouslySetInnerHTML={{\n __html: encoded,\n }}\n nonce={props.nonce}\n />\n );\n } catch (e) {\n // TODO: Use unified logging\n console.error(`Error serializing json for ${key}`);\n console.error(e);\n return null;\n }\n };\n scripts.push(\n <Suspense key={globalId}>\n <Script />\n </Suspense>,\n );\n });\n\n return {\n ...nextProps,\n scripts,\n };\n };\n}\n","import { Route } from '@anansi/router';\n\nimport type { ResolveProps, ServerProps } from './types';\n\ntype NeededProps<RouteWith> = {\n matchedRoutes: Route<RouteWith>[];\n} & ResolveProps;\n\nexport default function prefetchSpout<F extends string>(field: F) {\n return function <\n RouteWith,\n N extends NeededProps<RouteWith>,\n I extends ServerProps,\n >(\n next: (props: I) => Promise<\n {\n [K in F]: RouteWith;\n } & N\n >,\n ) {\n return async (props: I) => {\n const nextProps = await next(props);\n\n try {\n const toFetch: Promise<unknown>[] = [];\n nextProps.matchedRoutes.forEach(route => {\n if (typeof route.resolveData === 'function') {\n toFetch.push(route.resolveData(nextProps[field], route));\n }\n });\n await Promise.all(toFetch);\n } catch (e) {\n console.error(e);\n }\n return nextProps;\n };\n };\n}\n","import {\n type Controller,\n type Manager,\n NetworkManager,\n type State,\n} from '@rest-hooks/react';\nimport { createPersistedStore } from '@rest-hooks/ssr';\nimport type { Store } from 'redux';\n\nimport type { ServerSpout } from './types';\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n): ServerSpout<\n Record<string, unknown>,\n { controller: Controller } & { store: Store<State<unknown>> },\n { initData?: Record<string, () => unknown>; scripts?: React.ReactNode[] }\n> {\n const managers = options.getManagers();\n return next => async props => {\n const [ServerCacheProvider, useReadyCacheState, controller, store] =\n createPersistedStore(managers);\n\n const nextProps = await next({\n ...props,\n controller,\n store,\n });\n return {\n ...nextProps,\n initData: {\n ...nextProps.initData,\n resthooks: useReadyCacheState,\n },\n app: <ServerCacheProvider>{nextProps.app}</ServerCacheProvider>,\n // TODO: figure out how to only inject in next and not have to also put here\n controller,\n store,\n };\n };\n}\n","import { Route, RouteProvider, RouteController } from '@anansi/router';\nimport { createMemoryHistory } from 'history';\nimport React from 'react';\n\nimport type { CreateRouter, ServerSpout } from './types';\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\n}): ServerSpout<\n Record<string, unknown>,\n {\n matchedRoutes: Route<ResolveWith>[];\n } & {\n router: RouteController<Route<ResolveWith, any>>;\n }\n> {\n const createRouteComponent = (\n router: RouteController<Route<ResolveWith, any>>,\n ) =>\n function Router({ children }: { children: React.ReactNode }) {\n const resolveWith = options.useResolveWith();\n\n return (\n <RouteProvider router={router} resolveWith={resolveWith}>\n {children}\n </RouteProvider>\n );\n };\n\n return next => async props => {\n const url = props.req.url || '';\n const router = options.createRouter(\n createMemoryHistory({ initialEntries: [url] }),\n );\n const matchedRoutes: Route<ResolveWith>[] = router.getMatchedRoutes(url);\n\n const nextProps = await next({\n ...props,\n matchedRoutes,\n router,\n });\n\n const Router = createRouteComponent(router);\n\n return {\n ...nextProps,\n app: <Router>{nextProps.app}</Router>,\n // TODO: figure out how to only inject in next and not have to also put here\n matchedRoutes,\n router,\n };\n };\n}\n","module.exports = require(\"@anansi/router\");","module.exports = require(\"@ant-design/cssinjs\");","module.exports = require(\"@rest-hooks/react\");","module.exports = require(\"@rest-hooks/ssr\");","module.exports = require(\"history\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/server\");","module.exports = require(\"crypto\");","function _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n \"default\": obj\n };\n}\nmodule.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction _getRequireWildcardCache(nodeInterop) {\n if (typeof WeakMap !== \"function\") return null;\n var cacheBabelInterop = new WeakMap();\n var cacheNodeInterop = new WeakMap();\n return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {\n return nodeInterop ? cacheNodeInterop : cacheBabelInterop;\n })(nodeInterop);\n}\nfunction _interopRequireWildcard(obj, nodeInterop) {\n if (!nodeInterop && obj && obj.__esModule) {\n return obj;\n }\n if (obj === null || _typeof(obj) !== \"object\" && typeof obj !== \"function\") {\n return {\n \"default\": obj\n };\n }\n var cache = _getRequireWildcardCache(nodeInterop);\n if (cache && cache.has(obj)) {\n return cache.get(obj);\n }\n var newObj = {};\n var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;\n for (var key in obj) {\n if (key !== \"default\" && Object.prototype.hasOwnProperty.call(obj, key)) {\n var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;\n if (desc && (desc.get || desc.set)) {\n Object.defineProperty(newObj, key, desc);\n } else {\n newObj[key] = obj[key];\n }\n }\n }\n newObj[\"default\"] = obj;\n if (cache) {\n cache.set(obj, newObj);\n }\n return newObj;\n}\nmodule.exports = _interopRequireWildcard, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return (module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports), _typeof(obj);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","export { default as laySpouts } from './laySpouts';\nexport { default as documentSpout } from './spouts/document.server';\nexport { default as restHooksSpout } from './spouts/restHooks.server';\nexport { default as antdSpout } from './spouts/antd.server';\nexport { default as routerSpout } from './spouts/router.server';\nexport { default as prefetchSpout } from './spouts/prefetch.server';\nexport { default as JSONSpout } from './spouts/json.server';\nexport { default as appSpout } from './spouts/app.server';\nexport type { ServerProps } from './spouts/types';\nexport type { ServerSpout as Spout } from './spouts/types';\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"server.js","mappings":";;;;;;;;;;;;AAAA;AACA;AAKA;AAKA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACxDA;AAAA;AAAA;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAQA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;A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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AChDA;AACA;AAWA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AChCA;AASA;AAAA;AACA;AAGA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACvCA;AACA;AACA;AAAA;AAIA;AAYA;AAGA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtDA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACvBA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA","sources":["/home/ntucker/src/anansi/packages/core/src/laySpouts.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/DocumentComponent.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/antd.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/app.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/csp.ts","/home/ntucker/src/anansi/packages/core/src/spouts/document.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/prefetch.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/router.server.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@anansi/router\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@ant-design/cssinjs\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/ssr\"","/home/ntucker/src/anansi/packages/core/external commonjs \"history\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"react-dom/server\"","/home/ntucker/src/anansi/packages/core/external node-commonjs \"crypto\"","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireDefault.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/interopRequireWildcard.js","/home/ntucker/src/anansi/node_modules/@babel/runtime/helpers/typeof.js","/home/ntucker/src/anansi/packages/core/webpack/bootstrap","/home/ntucker/src/anansi/packages/core/src/index.server.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { renderToPipeableStream as reactRender } from 'react-dom/server';\n\nimport { Render } from './scripts/types';\nimport { ServerProps } from './spouts/types';\n\nexport default function laySpouts(\n spouts: (props: ServerProps) => Promise<{\n app: JSX.Element;\n }>,\n {\n timeoutMS = 10000,\n onError,\n }: { timeoutMS?: number; onError?: (error: unknown) => void } = {},\n) {\n const render: Render = async (clientManifest, req, res) => {\n const nonce = crypto.randomBytes(16).toString('base64');\n\n try {\n const { app } = await spouts({ clientManifest, req, res, nonce });\n\n let didError = false;\n const { pipe, abort } = reactRender(app, {\n nonce,\n //bootstrapScripts: assets.filter(asset => asset.endsWith('.js')),\n onShellReady() {\n //managers.forEach(manager => manager.cleanup());\n // If something errored before we started streaming, we set the error code appropriately.\n res.statusCode = didError ? 500 : 200;\n res.setHeader('Content-type', 'text/html');\n pipe(res);\n },\n onShellError() {\n didError = true;\n res.statusCode = 500;\n pipe(res);\n },\n onError(e: any) {\n didError = true;\n console.error(e);\n res.statusCode = 500;\n //pipe(res); Removing this avoids, \"React currently only supports piping to one writable stream.\"\n if (onError) onError(e);\n },\n });\n // Abandon and switch to client rendering if enough time passes.\n // Try lowering this to see the client recover.\n setTimeout(\n () => (abort as any)(`Timeout of ${timeoutMS}ms exceeded`),\n timeoutMS,\n );\n } catch (e: unknown) {\n if (onError) onError(e);\n throw e;\n }\n };\n return render;\n}\n","import type { Policy } from './csp';\nimport { buildPolicy } from './csp';\n\ntype Props = {\n children: React.ReactNode;\n assets: { href: string; as?: string; rel?: string }[];\n head: React.ReactNode;\n extraStyle: React.ReactNode;\n scripts: React.ReactNode;\n title: string;\n rootId: string;\n charSet: string;\n csPolicy?: Policy;\n nonce?: string | undefined;\n};\n\nexport default function Document({\n assets,\n head,\n children,\n title,\n rootId,\n charSet,\n csPolicy,\n nonce,\n scripts,\n extraStyle,\n}: Props) {\n let cspMeta: null | React.ReactNode = null;\n if (csPolicy) {\n // add nonce to policy\n const policy = {\n ...csPolicy,\n };\n if (\n nonce &&\n // nonces negate 'unsafe-inline' so do not add it in development to keep things easier\n process.env.NODE_ENV === 'production'\n ) {\n if (typeof policy['script-src'] === 'string') {\n policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];\n } else {\n policy['script-src'] = [...policy['script-src'], `'nonce-${nonce}'`];\n }\n }\n cspMeta = (\n <meta httpEquiv=\"Content-Security-Policy\" content={buildPolicy(policy)} />\n );\n }\n return (\n <html>\n <head>\n <meta charSet={charSet} />\n {cspMeta}\n {head}\n {extraStyle}\n {assets.map((asset, i) => (\n <link key={i} rel=\"preload\" {...asset} />\n ))}\n <title>{title}</title>\n </head>\n <body>\n <div id={rootId}>{children}</div>\n {scripts}\n {assets\n .filter(({ href }) => href.endsWith('.js'))\n .map(({ href }, i) => (\n <script key={i} src={href} async />\n ))}\n </body>\n </html>\n );\n}\nDocument.defaultProps = {\n head: (\n <>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <link\n rel=\"shortcut icon\"\n href={`${process.env.WEBPACK_PUBLIC_PATH ?? '/'}favicon.ico`}\n />\n </>\n ),\n charSet: 'utf-8',\n rootId: 'anansi-root',\n scripts: null,\n};\n","import React from 'react';\n\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n extraStyle?: React.ReactNode[];\n};\n\nexport default function antdSpout(): ServerSpout<\n Record<string, unknown>,\n Record<string, unknown>,\n NeededNext\n> {\n return next => async props => {\n const { createCache, extractStyle, StyleProvider } = await import(\n '@ant-design/cssinjs'\n );\n const cache = createCache();\n\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n\n const AntdSheets = (): JSX.Element => {\n return (\n <script\n dangerouslySetInnerHTML={{\n __html: `</script>${extractStyle(cache)}<script>`,\n }}\n />\n );\n };\n // unfortunately we have to inject this after the entire content has streamed in or it doesn't correctly populate\n // see: https://github.com/ant-design/cssinjs/issues/79\n scripts.push(<AntdSheets />);\n\n return {\n ...nextProps,\n app: <StyleProvider cache={cache}>{nextProps.app}</StyleProvider>,\n scripts,\n };\n };\n}\n","import { ServerProps } from './types';\n\nconst appSpout =\n (app: JSX.Element) =>\n <P extends ServerProps>(props: P) =>\n Promise.resolve({ ...props, app });\n\nexport default appSpout;\n","export interface Policy {\n [directive: string]: string | string[];\n}\n\n// TODO: memoize this\nexport function buildPolicy(policyObj: Policy) {\n return Object.keys(policyObj)\n .map(key => {\n const val = Array.isArray(policyObj[key])\n ? [...new Set(policyObj[key]).values()].filter(v => v).join(' ')\n : policyObj[key];\n\n // move strict dynamic to the end of the policy if it exists to be backwards compatible with csp2\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#strict-dynamic\n if (typeof val === 'string' && val.includes(\"'strict-dynamic'\")) {\n const newVal = `${val\n .replace(/\\s?'strict-dynamic'\\s?/gi, ' ')\n .trim()} 'strict-dynamic'`;\n return `${key} ${newVal}`;\n }\n\n return `${key} ${val}`;\n })\n .join('; ');\n}\n","import type { Route } from '@anansi/router';\nimport React from 'react';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n matchedRoutes: Route<any>[];\n title?: string;\n scripts?: React.ReactNode[];\n extraStyle?: React.ReactNode[];\n};\n\nexport default function DocumentSpout(options: {\n head?: React.ReactNode;\n title: string;\n rootId?: string;\n charSet?: string;\n csPolicy?: Policy;\n}): ServerSpout<Record<string, unknown>, Record<string, unknown>, NeededNext> {\n return next => async props => {\n const nextProps = await next(props);\n\n const publicPath = props.clientManifest.publicPath;\n\n if (\n Object.keys(props.clientManifest?.entrypoints ?? {}).length < 1 ||\n publicPath === undefined\n )\n throw new Error('Manifest missing entries needed');\n\n // TODO: consider using this package for build stats in future:\n // https://github.com/facebook/react/tree/main/packages/react-server-dom-webpack\n const assetMap = (assets: { name: string; size?: number }[]) =>\n assets.map(({ name }) => `${publicPath}${name}`);\n\n const assetList: string[] = [];\n Object.values(props.clientManifest?.entrypoints ?? {}).forEach(\n entrypoint => {\n assetList.push(...assetMap(entrypoint.assets ?? []));\n },\n );\n new Set(\n assetMap(\n Object.values(props.clientManifest.namedChunkGroups ?? {})\n .filter(({ name }) =>\n nextProps.matchedRoutes.some(route => name?.includes(route.name)),\n )\n .flatMap(chunk => [\n ...(chunk.assets ?? []),\n // any chunk preloads\n ...childrenAssets(chunk),\n ]),\n ),\n ).forEach(asset => assetList.push(asset));\n\n // find additional assets to preload based on matched route\n const assets: {\n href: string;\n as?: string | undefined;\n rel?: string | undefined;\n }[] = assetList\n .filter(asset => !asset.endsWith('.hot-update.js'))\n .map(asset =>\n asset.endsWith('.css')\n ? { href: asset, rel: 'stylesheet' }\n : asset.endsWith('.js')\n ? { href: asset, as: 'script' }\n : { href: asset },\n );\n\n return {\n ...nextProps,\n app: (\n <Document\n {...options}\n extraStyle={nextProps.extraStyle}\n title={nextProps.title ?? options.title}\n assets={assets}\n rootId={options.rootId}\n nonce={props.nonce}\n csPolicy={options.csPolicy}\n scripts={nextProps.scripts}\n >\n {nextProps.app}\n </Document>\n ),\n };\n };\n}\n\nfunction childrenAssets(chunk: StatsChunkGroup) {\n return chunk.children\n ? Object.values(chunk.children).flatMap(preload =>\n preload.flatMap(c => c.assets ?? []),\n )\n : [];\n}\n","import React, { Suspense } from 'react';\n\nimport type { ServerSpout } from './types';\n\ntype NeededNext = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n};\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}): ServerSpout<\n Record<string, unknown>,\n Record<string, unknown>,\n NeededNext\n> {\n return next => async props => {\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n\n Object.entries(nextProps.initData ?? {}).forEach(([key, useData]) => {\n const globalId = `${id}.${key}`;\n const Script = () => {\n const data: any = useData();\n try {\n const encoded = JSON.stringify(data);\n return (\n <script\n id={globalId}\n type=\"application/json\"\n dangerouslySetInnerHTML={{\n __html: encoded,\n }}\n nonce={props.nonce}\n />\n );\n } catch (e) {\n // TODO: Use unified logging\n console.error(`Error serializing json for ${key}`);\n console.error(e);\n return null;\n }\n };\n scripts.push(\n <Suspense key={globalId}>\n <Script />\n </Suspense>,\n );\n });\n\n return {\n ...nextProps,\n scripts,\n };\n };\n}\n","import { Route } from '@anansi/router';\n\nimport type { ResolveProps, ServerProps } from './types';\n\ntype NeededProps<RouteWith> = {\n matchedRoutes: Route<RouteWith>[];\n} & ResolveProps;\n\nexport default function prefetchSpout<F extends string>(field: F) {\n return function <\n RouteWith,\n N extends NeededProps<RouteWith>,\n I extends ServerProps,\n >(\n next: (props: I) => Promise<\n {\n [K in F]: RouteWith;\n } & N\n >,\n ) {\n return async (props: I) => {\n const nextProps = await next(props);\n\n try {\n const toFetch: Promise<unknown>[] = [];\n nextProps.matchedRoutes.forEach(route => {\n if (typeof route.resolveData === 'function') {\n toFetch.push(route.resolveData(nextProps[field], route));\n }\n });\n await Promise.all(toFetch);\n } catch (e) {\n console.error(e);\n }\n return nextProps;\n };\n };\n}\n","import { type Controller, type Manager, type State } from '@rest-hooks/react';\nimport type { Store } from 'redux';\n\nimport type { ServerSpout } from './types';\n\nexport default function restHooksSpout(\n options: {\n getManagers?: () => Manager[];\n } = {},\n): ServerSpout<\n Record<string, unknown>,\n { controller: Controller } & { store: Store<State<unknown>> },\n { initData?: Record<string, () => unknown>; scripts?: React.ReactNode[] }\n> {\n return next => async props => {\n const managers = options?.getManagers?.() ?? [\n new (await import('@rest-hooks/react')).NetworkManager(),\n ];\n const { createPersistedStore } = await import('@rest-hooks/ssr');\n const [ServerCacheProvider, useReadyCacheState, controller, store] =\n createPersistedStore(managers);\n\n const nextProps = await next({\n ...props,\n controller,\n store,\n });\n return {\n ...nextProps,\n initData: {\n ...nextProps.initData,\n resthooks: useReadyCacheState,\n },\n app: <ServerCacheProvider>{nextProps.app}</ServerCacheProvider>,\n // TODO: figure out how to only inject in next and not have to also put here\n controller,\n store,\n };\n };\n}\n","import { Route, RouteProvider, RouteController } from '@anansi/router';\nimport { createMemoryHistory } from 'history';\nimport React from 'react';\n\nimport type { CreateRouter, ServerSpout } from './types';\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\n}): ServerSpout<\n Record<string, unknown>,\n {\n matchedRoutes: Route<ResolveWith>[];\n } & {\n router: RouteController<Route<ResolveWith, any>>;\n }\n> {\n const createRouteComponent = (\n router: RouteController<Route<ResolveWith, any>>,\n ) =>\n function Router({ children }: { children: React.ReactNode }) {\n const resolveWith = options.useResolveWith();\n\n return (\n <RouteProvider router={router} resolveWith={resolveWith}>\n {children}\n </RouteProvider>\n );\n };\n\n return next => async props => {\n const url = props.req.url || '';\n const router = options.createRouter(\n createMemoryHistory({ initialEntries: [url] }),\n );\n const matchedRoutes: Route<ResolveWith>[] = router.getMatchedRoutes(url);\n\n const nextProps = await next({\n ...props,\n matchedRoutes,\n router,\n });\n\n const Router = createRouteComponent(router);\n\n return {\n ...nextProps,\n app: <Router>{nextProps.app}</Router>,\n // TODO: figure out how to only inject in next and not have to also put here\n matchedRoutes,\n router,\n };\n };\n}\n","module.exports = require(\"@anansi/router\");","module.exports = require(\"@ant-design/cssinjs\");","module.exports = require(\"@rest-hooks/react\");","module.exports = require(\"@rest-hooks/ssr\");","module.exports = require(\"history\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/server\");","module.exports = require(\"crypto\");","function _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n \"default\": obj\n };\n}\nmodule.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction _getRequireWildcardCache(nodeInterop) {\n if (typeof WeakMap !== \"function\") return null;\n var cacheBabelInterop = new WeakMap();\n var cacheNodeInterop = new WeakMap();\n return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {\n return nodeInterop ? cacheNodeInterop : cacheBabelInterop;\n })(nodeInterop);\n}\nfunction _interopRequireWildcard(obj, nodeInterop) {\n if (!nodeInterop && obj && obj.__esModule) {\n return obj;\n }\n if (obj === null || _typeof(obj) !== \"object\" && typeof obj !== \"function\") {\n return {\n \"default\": obj\n };\n }\n var cache = _getRequireWildcardCache(nodeInterop);\n if (cache && cache.has(obj)) {\n return cache.get(obj);\n }\n var newObj = {};\n var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;\n for (var key in obj) {\n if (key !== \"default\" && Object.prototype.hasOwnProperty.call(obj, key)) {\n var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;\n if (desc && (desc.get || desc.set)) {\n Object.defineProperty(newObj, key, desc);\n } else {\n newObj[key] = obj[key];\n }\n }\n }\n newObj[\"default\"] = obj;\n if (cache) {\n cache.set(obj, newObj);\n }\n return newObj;\n}\nmodule.exports = _interopRequireWildcard, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return (module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports), _typeof(obj);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","export { default as laySpouts } from './laySpouts';\nexport { default as documentSpout } from './spouts/document.server';\nexport { default as restHooksSpout } from './spouts/restHooks.server';\nexport { default as antdSpout } from './spouts/antd.server';\nexport { default as routerSpout } from './spouts/router.server';\nexport { default as prefetchSpout } from './spouts/prefetch.server';\nexport { default as JSONSpout } from './spouts/json.server';\nexport { default as appSpout } from './spouts/app.server';\nexport type { ServerProps } from './spouts/types';\nexport type { ServerSpout as Spout } from './spouts/types';\n"],"names":[],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentComponent.d.ts","sourceRoot":"","sources":["../../src/spouts/DocumentComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,iBAAwB,QAAQ,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,GACX,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"DocumentComponent.d.ts","sourceRoot":"","sources":["../../src/spouts/DocumentComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,iBAAwB,QAAQ,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,GACX,EAAE,KAAK,eA6CP;kBAxDuB,QAAQ;;;;;;;;eAAR,QAAQ"}
|
|
@@ -25,9 +25,9 @@ function Document({
|
|
|
25
25
|
const policy = {
|
|
26
26
|
...csPolicy
|
|
27
27
|
};
|
|
28
|
-
if (nonce &&
|
|
29
|
-
// nonces negate 'unsafe-inline' so do not add it
|
|
30
|
-
|
|
28
|
+
if (nonce &&
|
|
29
|
+
// nonces negate 'unsafe-inline' so do not add it in development to keep things easier
|
|
30
|
+
process.env.NODE_ENV === 'production') {
|
|
31
31
|
if (typeof policy['script-src'] === 'string') {
|
|
32
32
|
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
33
33
|
} else {
|
|
@@ -68,4 +68,4 @@ Document.defaultProps = {
|
|
|
68
68
|
rootId: 'anansi-root',
|
|
69
69
|
scripts: null
|
|
70
70
|
};
|
|
71
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
71
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJEb2N1bWVudCIsImFzc2V0cyIsImhlYWQiLCJjaGlsZHJlbiIsInRpdGxlIiwicm9vdElkIiwiY2hhclNldCIsImNzUG9saWN5Iiwibm9uY2UiLCJzY3JpcHRzIiwiZXh0cmFTdHlsZSIsImNzcE1ldGEiLCJwb2xpY3kiLCJwcm9jZXNzIiwiZW52IiwiTk9ERV9FTlYiLCJidWlsZFBvbGljeSIsIm1hcCIsImFzc2V0IiwiaSIsImZpbHRlciIsImhyZWYiLCJlbmRzV2l0aCIsImRlZmF1bHRQcm9wcyIsIldFQlBBQ0tfUFVCTElDX1BBVEgiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvc3BvdXRzL0RvY3VtZW50Q29tcG9uZW50LnRzeCJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFBvbGljeSB9IGZyb20gJy4vY3NwJztcbmltcG9ydCB7IGJ1aWxkUG9saWN5IH0gZnJvbSAnLi9jc3AnO1xuXG50eXBlIFByb3BzID0ge1xuICBjaGlsZHJlbjogUmVhY3QuUmVhY3ROb2RlO1xuICBhc3NldHM6IHsgaHJlZjogc3RyaW5nOyBhcz86IHN0cmluZzsgcmVsPzogc3RyaW5nIH1bXTtcbiAgaGVhZDogUmVhY3QuUmVhY3ROb2RlO1xuICBleHRyYVN0eWxlOiBSZWFjdC5SZWFjdE5vZGU7XG4gIHNjcmlwdHM6IFJlYWN0LlJlYWN0Tm9kZTtcbiAgdGl0bGU6IHN0cmluZztcbiAgcm9vdElkOiBzdHJpbmc7XG4gIGNoYXJTZXQ6IHN0cmluZztcbiAgY3NQb2xpY3k/OiBQb2xpY3k7XG4gIG5vbmNlPzogc3RyaW5nIHwgdW5kZWZpbmVkO1xufTtcblxuZXhw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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antd.server.d.ts","sourceRoot":"","sources":["../../src/spouts/antd.server.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"antd.server.d.ts","sourceRoot":"","sources":["../../src/spouts/antd.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,WAAW,CAC9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,UAAU,CACX,CA8BA"}
|
|
@@ -4,18 +4,23 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = antdSpout;
|
|
6
6
|
var _jsx2 = _interopRequireDefault(require("@babel/runtime/helpers/jsx"));
|
|
7
|
-
var
|
|
7
|
+
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
function antdSpout() {
|
|
10
10
|
return next => async props => {
|
|
11
11
|
var _nextProps$scripts;
|
|
12
|
-
const
|
|
12
|
+
const {
|
|
13
|
+
createCache,
|
|
14
|
+
extractStyle,
|
|
15
|
+
StyleProvider
|
|
16
|
+
} = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('@ant-design/cssinjs')));
|
|
17
|
+
const cache = createCache();
|
|
13
18
|
const nextProps = await next(props);
|
|
14
19
|
const scripts = (_nextProps$scripts = nextProps.scripts) != null ? _nextProps$scripts : [];
|
|
15
20
|
const AntdSheets = () => {
|
|
16
21
|
return /*#__PURE__*/(0, _jsx2.default)("script", {
|
|
17
22
|
dangerouslySetInnerHTML: {
|
|
18
|
-
__html: `</script>${
|
|
23
|
+
__html: `</script>${extractStyle(cache)}<script>`
|
|
19
24
|
}
|
|
20
25
|
});
|
|
21
26
|
};
|
|
@@ -24,11 +29,11 @@ function antdSpout() {
|
|
|
24
29
|
scripts.push( /*#__PURE__*/(0, _jsx2.default)(AntdSheets, {}));
|
|
25
30
|
return {
|
|
26
31
|
...nextProps,
|
|
27
|
-
app: /*#__PURE__*/(0, _jsx2.default)(
|
|
32
|
+
app: /*#__PURE__*/(0, _jsx2.default)(StyleProvider, {
|
|
28
33
|
cache: cache
|
|
29
34
|
}, void 0, nextProps.app),
|
|
30
35
|
scripts
|
|
31
36
|
};
|
|
32
37
|
};
|
|
33
38
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
39
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJhbnRkU3BvdXQiLCJuZXh0IiwicHJvcHMiLCJjcmVhdGVDYWNoZSIsImV4dHJhY3RTdHlsZSIsIlN0eWxlUHJvdmlkZXIiLCJjYWNoZSIsIm5leHRQcm9wcyIsInNjcmlwdHMiLCJBbnRkU2hlZXRzIiwiX19odG1sIiwicHVzaCIsImFwcCJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zcG91dHMvYW50ZC5zZXJ2ZXIudHN4Il0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCc7XG5cbmltcG9ydCB0eXBlIHsgU2VydmVyU3BvdXQgfSBmcm9tICcuL3R5cGVzJztcblxudHlwZSBOZWVkZWROZXh0ID0ge1xuICBpbml0RGF0YT86IFJlY29yZDxzdHJ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UsbUJBQUMsYUFBYTtRQUFDLEtBQUssRUFBRU47TUFBTSxXQUFFQyxTQUFTLENBQUNLLEdBQUcsQ0FBaUI7TUFDakVKO0lBQ0YsQ0FBQztFQUNILENBQUM7QUFDSCJ9
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Manager } from '@rest-hooks/react';
|
|
1
|
+
import { type Manager } from '@rest-hooks/react';
|
|
2
2
|
import type { ClientSpout } from './types';
|
|
3
3
|
export default function restHooksSpout(options?: {
|
|
4
|
-
getManagers
|
|
4
|
+
getManagers?: () => Manager[];
|
|
5
5
|
}): ClientSpout<{
|
|
6
6
|
getInitialData: (key: string) => Promise<any>;
|
|
7
7
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restHooks.d.ts","sourceRoot":"","sources":["../../src/spouts/restHooks.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"restHooks.d.ts","sourceRoot":"","sources":["../../src/spouts/restHooks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,OAAO,EAAE,CAAC;CAC1B,GACL,WAAW,CAAC;IAAE,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC,CAuBhE"}
|
package/lib/spouts/restHooks.js
CHANGED
|
@@ -4,24 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = restHooksSpout;
|
|
6
6
|
var _jsx2 = _interopRequireDefault(require("@babel/runtime/helpers/jsx"));
|
|
7
|
+
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
|
-
function restHooksSpout(options = {
|
|
10
|
-
getManagers: () => [new _react2.NetworkManager()]
|
|
11
|
-
}) {
|
|
9
|
+
function restHooksSpout(options = {}) {
|
|
12
10
|
return next => async props => {
|
|
13
11
|
const nextProps = await next(props);
|
|
14
|
-
const data
|
|
12
|
+
const [data, {
|
|
13
|
+
CacheProvider
|
|
14
|
+
}] = await Promise.all([props.getInitialData('resthooks'), Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('./restHooks.provider')))]);
|
|
15
15
|
if (process.env.NODE_ENV !== 'production' && !data) {
|
|
16
16
|
console.error('Rest Hooks init data not found');
|
|
17
|
+
} else if (!data) {
|
|
18
|
+
console.info('Rest Hooks init missing');
|
|
17
19
|
}
|
|
18
20
|
return {
|
|
19
21
|
...nextProps,
|
|
20
|
-
app: /*#__PURE__*/(0, _jsx2.default)(
|
|
22
|
+
app: /*#__PURE__*/(0, _jsx2.default)(CacheProvider, {
|
|
21
23
|
initialState: data,
|
|
22
|
-
managers: options.getManagers()
|
|
24
|
+
managers: options == null ? void 0 : options.getManagers == null ? void 0 : options.getManagers()
|
|
23
25
|
}, void 0, nextProps.app)
|
|
24
26
|
};
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZXN0SG9va3NTcG91dCIsIm9wdGlvbnMiLCJuZXh0IiwicHJvcHMiLCJuZXh0UHJvcHMiLCJkYXRhIiwiQ2FjaGVQcm92aWRlciIsIlByb21pc2UiLCJhbGwiLCJnZXRJbml0aWFsRGF0YSIsInByb2Nlc3MiLCJlbnYiLCJOT0RFX0VOViIsImNvbnNvbGUiLCJlcnJvciIsImluZm8iLCJhcHAiLCJnZXRNYW5hZ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UFFZ0IsV0FBVztNQUFLLFdBQ25FYixTQUFTLENBQUNZLEdBQUc7SUFHcEIsQ0FBQztFQUNILENBQUM7QUFDSCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restHooks.provider.d.ts","sourceRoot":"","sources":["../../src/spouts/restHooks.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.CacheProvider = void 0;
|
|
5
|
+
var _react = require("@rest-hooks/react");
|
|
6
|
+
exports.CacheProvider = _react.CacheProvider;
|
|
7
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6W10sInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Nwb3V0cy9yZXN0SG9va3MucHJvdmlkZXIudHN4Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IENhY2hlUHJvdmlkZXIgfSBmcm9tICdAcmVzdC1ob29rcy9yZWFjdCc7XG4iXSwibWFwcGluZ3MiOiI7Ozs7QUFBQTtBQUFrRCJ9
|
|
@@ -3,7 +3,7 @@ import { type Controller, type Manager, type State } from '@rest-hooks/react';
|
|
|
3
3
|
import type { Store } from 'redux';
|
|
4
4
|
import type { ServerSpout } from './types';
|
|
5
5
|
export default function restHooksSpout(options?: {
|
|
6
|
-
getManagers
|
|
6
|
+
getManagers?: () => Manager[];
|
|
7
7
|
}): ServerSpout<Record<string, unknown>, {
|
|
8
8
|
controller: Controller;
|
|
9
9
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restHooks.server.d.ts","sourceRoot":"","sources":["../../src/spouts/restHooks.server.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"restHooks.server.d.ts","sourceRoot":"","sources":["../../src/spouts/restHooks.server.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,OAAO,EAAE,CAAC;CAC1B,GACL,WAAW,CACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;CAAE,EAC7D;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;CAAE,CAC1E,CA0BA"}
|
|
@@ -4,15 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = restHooksSpout;
|
|
6
6
|
var _jsx2 = _interopRequireDefault(require("@babel/runtime/helpers/jsx"));
|
|
7
|
+
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
|
-
var _ssr = require("@rest-hooks/ssr");
|
|
10
|
-
function restHooksSpout(options = {
|
|
11
|
-
getManagers: () => [new _react2.NetworkManager()]
|
|
12
|
-
}) {
|
|
13
|
-
const managers = options.getManagers();
|
|
9
|
+
function restHooksSpout(options = {}) {
|
|
14
10
|
return next => async props => {
|
|
15
|
-
|
|
11
|
+
var _options$getManagers;
|
|
12
|
+
const managers = (_options$getManagers = options == null ? void 0 : options.getManagers == null ? void 0 : options.getManagers()) != null ? _options$getManagers : [new (await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('@rest-hooks/react')))).NetworkManager()];
|
|
13
|
+
const {
|
|
14
|
+
createPersistedStore
|
|
15
|
+
} = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('@rest-hooks/ssr')));
|
|
16
|
+
const [ServerCacheProvider, useReadyCacheState, controller, store] = createPersistedStore(managers);
|
|
16
17
|
const nextProps = await next({
|
|
17
18
|
...props,
|
|
18
19
|
controller,
|
|
@@ -31,4 +32,4 @@ function restHooksSpout(options = {
|
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZXN0SG9va3NTcG91dCIsIm9wdGlvbnMiLCJuZXh0IiwicHJvcHMiLCJtYW5hZ2VycyIsImdldE1hbmFnZXJzIiwiTmV0d29ya01hbmFnZXIiLCJjcmVhdGVQZXJzaXN0ZWRTdG9yZSIsIlNlcnZlckNhY2hlUHJvdmlkZXIiLCJ1c2VSZWFkeUNhY2hlU3RhdGUiLCJjb250cm9sbGVyIiwic3RvcmUiLCJuZXh0UHJvcHMiLCJpbml0RGF0YSIsInJlc3Rob29rcyIsImFwcCJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zcG91dHMvcmVzdEhvb2tzLnNlcnZlci50c3giXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBDb250cm9sbGVyLCB0eXBlIE1hbmFnZXIsIHR5cGUgU3RhdGUgfSBmcm9tICdAcmVzdC1ob29rcy9yZWFjdCc7XG5pbXBvcnQgdHlwZSB7IFN0b3JlIH0gZnJvbSAncmVkdXgnO1xuXG5pbXBvcnQgdHlwZSB7IFNlcnZlclNwb3V0I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FRLEVBQUU7UUFDUixHQUFHRCxTQUFTLENBQUNDLFFBQVE7UUFDckJDLFNBQVMsRUFBRUw7TUFDYixDQUFDO01BQ0RNLEdBQUcsZUFBRSxtQkFBQyxtQkFBbUIsY0FBRUgsU0FBUyxDQUFDRyxHQUFHLENBQXVCO01BQy9EO01BQ0FMLFVBQVU7TUFDVkM7SUFDRixDQUFDO0VBQ0gsQ0FBQztBQUNIIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anansi/core",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "React 18 Framework",
|
|
5
5
|
"homepage": "https://github.com/ntucker/anansi/tree/master/packages/core#readme",
|
|
6
6
|
"repository": {
|
|
@@ -67,22 +67,22 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@anansi/babel-preset": "3.4.1",
|
|
69
69
|
"@anansi/browserslist-config": "1.4.1",
|
|
70
|
-
"@anansi/webpack-config": "14.1.
|
|
70
|
+
"@anansi/webpack-config": "14.1.3",
|
|
71
71
|
"@babel/cli": "7.20.7",
|
|
72
72
|
"@babel/core": "7.20.12",
|
|
73
73
|
"@types/compression": "1.7.2",
|
|
74
74
|
"@types/source-map-support": "0.5.6",
|
|
75
75
|
"@types/tmp": "0.2.3",
|
|
76
76
|
"@types/webpack-hot-middleware": "2.25.6",
|
|
77
|
-
"jest": "29.4.
|
|
77
|
+
"jest": "29.4.2",
|
|
78
78
|
"rimraf": "4.1.2",
|
|
79
79
|
"webpack": "5.75.0",
|
|
80
80
|
"webpack-cli": "5.0.1"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@anansi/router": "^0.7.
|
|
83
|
+
"@anansi/router": "^0.7.13",
|
|
84
84
|
"@babel/runtime": "^7.17.0",
|
|
85
|
-
"@rest-hooks/ssr": "^0.7.
|
|
85
|
+
"@rest-hooks/ssr": "^0.7.8",
|
|
86
86
|
"chalk": "^4.1.2",
|
|
87
87
|
"compression": "^1.7.4",
|
|
88
88
|
"cross-fetch": "^3.1.5",
|
|
@@ -34,9 +34,8 @@ export default function Document({
|
|
|
34
34
|
};
|
|
35
35
|
if (
|
|
36
36
|
nonce &&
|
|
37
|
-
// nonces negate 'unsafe-inline' so do not add it
|
|
38
|
-
|
|
39
|
-
!policy['script-src'].includes("'unsafe-inline'"))
|
|
37
|
+
// nonces negate 'unsafe-inline' so do not add it in development to keep things easier
|
|
38
|
+
process.env.NODE_ENV === 'production'
|
|
40
39
|
) {
|
|
41
40
|
if (typeof policy['script-src'] === 'string') {
|
|
42
41
|
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
3
|
import type { ServerSpout } from './types';
|
|
@@ -15,6 +14,9 @@ export default function antdSpout(): ServerSpout<
|
|
|
15
14
|
NeededNext
|
|
16
15
|
> {
|
|
17
16
|
return next => async props => {
|
|
17
|
+
const { createCache, extractStyle, StyleProvider } = await import(
|
|
18
|
+
'@ant-design/cssinjs'
|
|
19
|
+
);
|
|
18
20
|
const cache = createCache();
|
|
19
21
|
|
|
20
22
|
const nextProps = await next(props);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CacheProvider } from '@rest-hooks/react';
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Controller,
|
|
3
|
-
type Manager,
|
|
4
|
-
NetworkManager,
|
|
5
|
-
type State,
|
|
6
|
-
} from '@rest-hooks/react';
|
|
7
|
-
import { createPersistedStore } from '@rest-hooks/ssr';
|
|
1
|
+
import { type Controller, type Manager, type State } from '@rest-hooks/react';
|
|
8
2
|
import type { Store } from 'redux';
|
|
9
3
|
|
|
10
4
|
import type { ServerSpout } from './types';
|
|
11
5
|
|
|
12
6
|
export default function restHooksSpout(
|
|
13
7
|
options: {
|
|
14
|
-
getManagers
|
|
15
|
-
} = {
|
|
8
|
+
getManagers?: () => Manager[];
|
|
9
|
+
} = {},
|
|
16
10
|
): ServerSpout<
|
|
17
11
|
Record<string, unknown>,
|
|
18
12
|
{ controller: Controller } & { store: Store<State<unknown>> },
|
|
19
13
|
{ initData?: Record<string, () => unknown>; scripts?: React.ReactNode[] }
|
|
20
14
|
> {
|
|
21
|
-
const managers = options.getManagers();
|
|
22
15
|
return next => async props => {
|
|
16
|
+
const managers = options?.getManagers?.() ?? [
|
|
17
|
+
new (await import('@rest-hooks/react')).NetworkManager(),
|
|
18
|
+
];
|
|
19
|
+
const { createPersistedStore } = await import('@rest-hooks/ssr');
|
|
23
20
|
const [ServerCacheProvider, useReadyCacheState, controller, store] =
|
|
24
21
|
createPersistedStore(managers);
|
|
25
22
|
|
package/src/spouts/restHooks.tsx
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Manager } from '@rest-hooks/react';
|
|
2
2
|
|
|
3
3
|
import type { ClientSpout } from './types';
|
|
4
4
|
|
|
5
5
|
export default function restHooksSpout(
|
|
6
6
|
options: {
|
|
7
|
-
getManagers
|
|
8
|
-
} = {
|
|
7
|
+
getManagers?: () => Manager[];
|
|
8
|
+
} = {},
|
|
9
9
|
): ClientSpout<{ getInitialData: (key: string) => Promise<any> }> {
|
|
10
10
|
return next => async props => {
|
|
11
11
|
const nextProps = await next(props);
|
|
12
|
-
const data = await
|
|
12
|
+
const [data, { CacheProvider }] = await Promise.all([
|
|
13
|
+
props.getInitialData('resthooks'),
|
|
14
|
+
import('./restHooks.provider'),
|
|
15
|
+
]);
|
|
13
16
|
|
|
14
17
|
if (process.env.NODE_ENV !== 'production' && !data) {
|
|
15
18
|
console.error('Rest Hooks init data not found');
|
|
19
|
+
} else if (!data) {
|
|
20
|
+
console.info('Rest Hooks init missing');
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
return {
|
|
19
24
|
...nextProps,
|
|
20
25
|
app: (
|
|
21
|
-
<CacheProvider initialState={data} managers={options
|
|
26
|
+
<CacheProvider initialState={data} managers={options?.getManagers?.()}>
|
|
22
27
|
{nextProps.app}
|
|
23
28
|
</CacheProvider>
|
|
24
29
|
),
|