@anansi/core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/client.js +45 -46
- package/dist/client.js.map +1 -1
- package/dist/server.js +139 -145
- package/dist/server.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.server.d.ts +1 -0
- package/lib/index.server.d.ts.map +1 -1
- package/lib/index.server.js +3 -2
- package/lib/spouts/document.d.ts +2 -8
- package/lib/spouts/document.d.ts.map +1 -1
- package/lib/spouts/document.js +4 -6
- package/lib/spouts/document.server.d.ts +3 -5
- package/lib/spouts/document.server.d.ts.map +1 -1
- package/lib/spouts/document.server.js +40 -42
- package/lib/spouts/json.d.ts +3 -3
- package/lib/spouts/json.d.ts.map +1 -1
- package/lib/spouts/json.js +6 -6
- package/lib/spouts/json.server.d.ts +3 -5
- package/lib/spouts/json.server.d.ts.map +1 -1
- package/lib/spouts/json.server.js +32 -34
- package/lib/spouts/restHooks.d.ts +2 -4
- package/lib/spouts/restHooks.d.ts.map +1 -1
- package/lib/spouts/restHooks.js +9 -11
- package/lib/spouts/restHooks.server.d.ts +4 -81
- package/lib/spouts/restHooks.server.d.ts.map +1 -1
- package/lib/spouts/restHooks.server.js +15 -17
- package/lib/spouts/router.d.ts +3 -4
- package/lib/spouts/router.d.ts.map +1 -1
- package/lib/spouts/router.js +14 -13
- package/lib/spouts/router.server.d.ts +2 -6
- package/lib/spouts/router.server.d.ts.map +1 -1
- package/lib/spouts/router.server.js +17 -19
- package/lib/spouts/types.d.ts +2 -0
- package/lib/spouts/types.d.ts.map +1 -1
- package/lib/spouts/types.js +1 -1
- package/package.json +1 -1
- package/src/index.server.ts +1 -0
- package/src/index.ts +1 -0
- package/src/spouts/document.server.tsx +63 -67
- package/src/spouts/document.tsx +5 -14
- package/src/spouts/json.server.tsx +40 -40
- package/src/spouts/json.tsx +8 -11
- package/src/spouts/restHooks.server.tsx +25 -29
- package/src/spouts/restHooks.tsx +12 -18
- package/src/spouts/router.server.tsx +29 -34
- package/src/spouts/router.tsx +19 -19
- package/src/spouts/types.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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.14.0](https://github.com/ntucker/anansi/compare/@anansi/core@0.13.0...@anansi/core@0.14.0) (2022-06-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
* Add Spout type for easy spout construction ([8f93eb3](https://github.com/ntucker/anansi/commit/8f93eb363f1bfe30d1ac30395df1a3d9fbd9cab3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [0.13.0](https://github.com/ntucker/anansi/compare/@anansi/core@0.12.0...@anansi/core@0.13.0) (2022-06-23)
|
|
7
16
|
|
|
8
17
|
|
package/dist/client.js
CHANGED
|
@@ -53,6 +53,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
53
53
|
__webpack_require__.d(__webpack_exports__, {
|
|
54
54
|
"JSONSpout": () => (/* reexport */ JSONSpout),
|
|
55
55
|
"ServerProps": () => (/* reexport */ types_namespaceObject.ServerProps),
|
|
56
|
+
"Spout": () => (/* reexport */ types_namespaceObject.ClientSpout),
|
|
56
57
|
"appSpout": () => (/* reexport */ app),
|
|
57
58
|
"documentSpout": () => (/* reexport */ documentSpout),
|
|
58
59
|
"floodSpouts": () => (/* reexport */ floodSpouts),
|
|
@@ -80,11 +81,9 @@ async function floodSpouts(spouts, {
|
|
|
80
81
|
}
|
|
81
82
|
;// CONCATENATED MODULE: ./src/spouts/document.tsx
|
|
82
83
|
function documentSpout(options) {
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return nextProps;
|
|
87
|
-
};
|
|
84
|
+
return next => async props => {
|
|
85
|
+
const nextProps = await next(props);
|
|
86
|
+
return nextProps;
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
;// CONCATENATED MODULE: external "react"
|
|
@@ -99,22 +98,20 @@ var _jsxFileName = "/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.
|
|
|
99
98
|
function restHooksSpout(options = {
|
|
100
99
|
getManagers: () => [new core_namespaceObject.NetworkManager()]
|
|
101
100
|
}) {
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}, nextProps.app)
|
|
117
|
-
};
|
|
101
|
+
return next => async props => {
|
|
102
|
+
const data = props.initData.resthooks;
|
|
103
|
+
const nextProps = await next(props);
|
|
104
|
+
return { ...nextProps,
|
|
105
|
+
app: /*#__PURE__*/external_react_default().createElement(core_namespaceObject.CacheProvider, {
|
|
106
|
+
initialState: data,
|
|
107
|
+
managers: options.getManagers(),
|
|
108
|
+
__self: this,
|
|
109
|
+
__source: {
|
|
110
|
+
fileName: _jsxFileName,
|
|
111
|
+
lineNumber: 23,
|
|
112
|
+
columnNumber: 9
|
|
113
|
+
}
|
|
114
|
+
}, nextProps.app)
|
|
118
115
|
};
|
|
119
116
|
};
|
|
120
117
|
}
|
|
@@ -139,31 +136,32 @@ function routerSpout(options) {
|
|
|
139
136
|
__self: this,
|
|
140
137
|
__source: {
|
|
141
138
|
fileName: router_jsxFileName,
|
|
142
|
-
lineNumber:
|
|
139
|
+
lineNumber: 27,
|
|
143
140
|
columnNumber: 9
|
|
144
141
|
}
|
|
145
142
|
}, children);
|
|
146
143
|
};
|
|
147
144
|
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
145
|
+
return next => async props => {
|
|
146
|
+
const history = (0,external_history_namespaceObject.createBrowserHistory)();
|
|
147
|
+
const router = options.createRouter(history);
|
|
148
|
+
const matchedRoutes = router.getMatchedRoutes(history.location.pathname);
|
|
149
|
+
const nextProps = await next({ ...props,
|
|
150
|
+
matchedRoutes,
|
|
151
|
+
router
|
|
152
|
+
});
|
|
153
|
+
const Router = createRouteComponent(router);
|
|
154
|
+
return { ...nextProps,
|
|
155
|
+
matchedRoutes,
|
|
156
|
+
router,
|
|
157
|
+
app: /*#__PURE__*/external_react_default().createElement(Router, {
|
|
158
|
+
__self: this,
|
|
159
|
+
__source: {
|
|
160
|
+
fileName: router_jsxFileName,
|
|
161
|
+
lineNumber: 49,
|
|
162
|
+
columnNumber: 12
|
|
163
|
+
}
|
|
164
|
+
}, nextProps.app)
|
|
167
165
|
};
|
|
168
166
|
};
|
|
169
167
|
}
|
|
@@ -171,12 +169,12 @@ function routerSpout(options) {
|
|
|
171
169
|
function JSONSpout({
|
|
172
170
|
id = 'anansi-json'
|
|
173
171
|
} = {}) {
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return await next({ ...props,
|
|
172
|
+
return next => async props => {
|
|
173
|
+
const initData = getDatafromDOM(id);
|
|
174
|
+
return { ...(await next({ ...props,
|
|
178
175
|
initData
|
|
179
|
-
})
|
|
176
|
+
})),
|
|
177
|
+
initData
|
|
180
178
|
};
|
|
181
179
|
};
|
|
182
180
|
}
|
|
@@ -201,6 +199,7 @@ const appSpout = app => props => Promise.resolve({ ...props,
|
|
|
201
199
|
|
|
202
200
|
|
|
203
201
|
|
|
202
|
+
|
|
204
203
|
module.exports = __webpack_exports__;
|
|
205
204
|
/******/ })()
|
|
206
205
|
;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","mappings":";;AAAA;AACA;AACA;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":"client.js","mappings":";;AAAA;AACA;AACA;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;ACNA;;ACAA;AAEA;AAIA;AAAA;AACA;;AACA;AAAA;AAAA;AAEA;AACA;;ACNA;AAIA;AACA;AAEA;AACA;AACA;;ACdA;;;ACAA;;;;ACAA;AASA;AAGA;AAAA;AAEA;AACA;AAEA;AAEA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAHA;AAQA;AACA;;AC5BA;;ACAA;;;ACAA;AACA;AACA;AAKA;AAYA;AAGA;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAHA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;;AAEA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAJA;AAMA;AACA;;ACjDA;AACA;AADA;AAMA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;;AACA;AACA;AACA;AACA;;AChBA;AAGA;AAAA;;AAEA;;;;AELA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["/home/ntucker/src/anansi/packages/core/webpack/bootstrap","/home/ntucker/src/anansi/packages/core/webpack/runtime/compat get default export","/home/ntucker/src/anansi/packages/core/webpack/runtime/define property getters","/home/ntucker/src/anansi/packages/core/webpack/runtime/hasOwnProperty shorthand","/home/ntucker/src/anansi/packages/core/webpack/runtime/make namespace object","/home/ntucker/src/anansi/packages/core/external commonjs \"react-dom/client\"","/home/ntucker/src/anansi/packages/core/src/floodSpouts.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/document.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/core\"","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@anansi/router\"","/home/ntucker/src/anansi/packages/core/external commonjs \"history\"","/home/ntucker/src/anansi/packages/core/src/spouts/router.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/app.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/types.ts","/home/ntucker/src/anansi/packages/core/src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-dom/client\");","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","import React from 'react';\nimport type { Route } from '@anansi/router';\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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@rest-hooks/core\");","import {\n CacheProvider,\n Manager,\n NetworkManager,\n State,\n} from '@rest-hooks/core';\n\nimport type { ClientSpout } from './types';\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n): ClientSpout<{ initData: Record<string, unknown> }> {\n return next => async props => {\n const data = props.initData.resthooks as State<unknown>;\n\n const nextProps = await next(props);\n\n return {\n ...nextProps,\n app: (\n <CacheProvider initialState={data} managers={options.getManagers()}>\n {nextProps.app}\n </CacheProvider>\n ),\n };\n };\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@anansi/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"history\");","import { Route, RouteProvider, RouteController } from '@anansi/router';\nimport React from 'react';\nimport { createBrowserHistory } from 'history';\nimport type { Update } from 'history';\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 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","import type { ClientSpout } from './types';\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}): ClientSpout<\n Record<string, unknown>,\n { initData: Record<string, unknown> }\n> {\n return next => async props => {\n const initData = getDatafromDOM(id);\n return { ...(await next({ ...props, initData })), initData };\n };\n}\nfunction getDatafromDOM(id: string): Record<string, unknown> {\n const element: HTMLScriptElement | null = document.querySelector(`#${id}`);\n return element?.text ? JSON.parse(element?.text) : undefined;\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 { IncomingMessage, ServerResponse } from 'http';\nimport { Request, Response } from 'express';\nimport type { StatsCompilation } from 'webpack';\nimport { History } from 'history';\nimport { Route, RouteController } from '@anansi/router';\n\n/* Variables from the rendering call */\nexport type ServerProps = {\n req: Request | IncomingMessage;\n res: Response | ServerResponse;\n clientManifest: StatsCompilation;\n nonce: string;\n};\n\n/* Baseline expectations of return value */\nexport type ResolveProps = {\n app: JSX.Element;\n};\n\nexport type CreateRouter<T> = (\n history: History,\n) => RouteController<Route<T, any>>;\n\n/* Spouts are middleware for Anansi */\nexport type ServerSpout<\n NeededProps extends Record<string, unknown> = Record<string, unknown>,\n ProvidedProps extends Record<string, unknown> = Record<string, unknown>,\n NeededNext extends Record<string, unknown> = NeededProps,\n> = <N extends NeededNext & ResolveProps, I extends NeededProps & ServerProps>(\n next: (props: I & ProvidedProps) => Promise<N>,\n) => (props: I) => Promise<N & ProvidedProps>;\n\n/* Spouts are middleware for Anansi */\nexport type ClientSpout<\n NeededProps extends Record<string, unknown> = Record<string, unknown>,\n ProvidedProps extends Record<string, unknown> = Record<string, unknown>,\n NeededNext extends Record<string, unknown> = NeededProps,\n> = <N extends NeededNext & ResolveProps, I extends NeededProps>(\n next: (props: I & ProvidedProps) => Promise<N>,\n) => (props: I) => Promise<N & ProvidedProps>;\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 { ServerProps } from './spouts/types';\nexport { ClientSpout as Spout } from './spouts/types';\n"],"names":[],"sourceRoot":""}
|
package/dist/server.js
CHANGED
|
@@ -53,6 +53,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
53
53
|
__webpack_require__.d(__webpack_exports__, {
|
|
54
54
|
"JSONSpout": () => (/* reexport */ JSONSpout),
|
|
55
55
|
"ServerProps": () => (/* reexport */ types_namespaceObject.ServerProps),
|
|
56
|
+
"Spout": () => (/* reexport */ types_namespaceObject.ServerSpout),
|
|
56
57
|
"appSpout": () => (/* reexport */ app_server),
|
|
57
58
|
"documentSpout": () => (/* reexport */ DocumentSpout),
|
|
58
59
|
"laySpouts": () => (/* reexport */ laySpouts),
|
|
@@ -293,59 +294,57 @@ var document_server_jsxFileName = "/home/ntucker/src/anansi/packages/core/src/sp
|
|
|
293
294
|
|
|
294
295
|
|
|
295
296
|
function DocumentSpout(options) {
|
|
296
|
-
return
|
|
297
|
-
|
|
298
|
-
var _props$clientManifest, _props$clientManifest2, _props$clientManifest3, _props$clientManifest4, _props$clientManifest5, _nextProps$title;
|
|
297
|
+
return next => async props => {
|
|
298
|
+
var _props$clientManifest, _props$clientManifest2, _props$clientManifest3, _props$clientManifest4, _props$clientManifest5, _nextProps$title;
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
const nextProps = await next(props);
|
|
301
|
+
const publicPath = props.clientManifest.publicPath;
|
|
302
|
+
if (Object.keys((_props$clientManifest = (_props$clientManifest2 = props.clientManifest) === null || _props$clientManifest2 === void 0 ? void 0 : _props$clientManifest2.entrypoints) != null ? _props$clientManifest : {}).length < 1 || publicPath === undefined) throw new Error('Manifest missing entries needed'); // TODO: consider using this package for build stats in future:
|
|
303
|
+
// https://github.com/facebook/react/tree/main/packages/react-server-dom-webpack
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
const assetMap = assets => assets.map(({
|
|
306
|
+
name
|
|
307
|
+
}) => `${publicPath}${name}`);
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
const assetList = [];
|
|
310
|
+
Object.values((_props$clientManifest3 = (_props$clientManifest4 = props.clientManifest) === null || _props$clientManifest4 === void 0 ? void 0 : _props$clientManifest4.entrypoints) != null ? _props$clientManifest3 : {}).forEach(entrypoint => {
|
|
311
|
+
var _entrypoint$assets;
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
};
|
|
313
|
+
assetList.push(...assetMap((_entrypoint$assets = entrypoint.assets) != null ? _entrypoint$assets : []));
|
|
314
|
+
});
|
|
315
|
+
new Set(assetMap(Object.values((_props$clientManifest5 = props.clientManifest.namedChunkGroups) != null ? _props$clientManifest5 : {}).filter(({
|
|
316
|
+
name
|
|
317
|
+
}) => nextProps.matchedRoutes.some(route => name === null || name === void 0 ? void 0 : name.includes(route.name))).flatMap(chunk => {
|
|
318
|
+
var _chunk$assets;
|
|
319
|
+
|
|
320
|
+
return [...((_chunk$assets = chunk.assets) != null ? _chunk$assets : []), // any chunk preloads
|
|
321
|
+
...childrenAssets(chunk)];
|
|
322
|
+
}))).forEach(asset => assetList.push(asset)); // find additional assets to preload based on matched route
|
|
323
|
+
|
|
324
|
+
const assets = assetList.filter(asset => !asset.endsWith('.hot-update.js')).map(asset => asset.endsWith('.css') ? {
|
|
325
|
+
href: asset,
|
|
326
|
+
rel: 'stylesheet'
|
|
327
|
+
} : asset.endsWith('.js') ? {
|
|
328
|
+
href: asset,
|
|
329
|
+
as: 'script'
|
|
330
|
+
} : {
|
|
331
|
+
href: asset
|
|
332
|
+
});
|
|
333
|
+
return { ...nextProps,
|
|
334
|
+
app: /*#__PURE__*/external_react_default().createElement(Document, { ...options,
|
|
335
|
+
title: (_nextProps$title = nextProps.title) != null ? _nextProps$title : options.title,
|
|
336
|
+
assets: assets,
|
|
337
|
+
rootId: options.rootId,
|
|
338
|
+
nonce: props.nonce,
|
|
339
|
+
csPolicy: options.csPolicy,
|
|
340
|
+
scripts: nextProps.scripts,
|
|
341
|
+
__self: this,
|
|
342
|
+
__source: {
|
|
343
|
+
fileName: document_server_jsxFileName,
|
|
344
|
+
lineNumber: 55,
|
|
345
|
+
columnNumber: 12
|
|
346
|
+
}
|
|
347
|
+
}, nextProps.app)
|
|
349
348
|
};
|
|
350
349
|
};
|
|
351
350
|
}
|
|
@@ -412,29 +411,27 @@ var restHooks_server_jsxFileName = "/home/ntucker/src/anansi/packages/core/src/s
|
|
|
412
411
|
function restHooksSpout(options = {
|
|
413
412
|
getManagers: () => [new core_namespaceObject.NetworkManager()]
|
|
414
413
|
}) {
|
|
415
|
-
return
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
store
|
|
437
|
-
};
|
|
414
|
+
return next => async props => {
|
|
415
|
+
const [ServerCacheProvider, controller, store] = createPersistedStore(options.getManagers());
|
|
416
|
+
const nextProps = await next({ ...props,
|
|
417
|
+
controller,
|
|
418
|
+
store
|
|
419
|
+
});
|
|
420
|
+
return { ...nextProps,
|
|
421
|
+
initData: { ...nextProps.initData,
|
|
422
|
+
resthooks: () => store.getState()
|
|
423
|
+
},
|
|
424
|
+
app: /*#__PURE__*/external_react_default().createElement(ServerCacheProvider, {
|
|
425
|
+
__self: this,
|
|
426
|
+
__source: {
|
|
427
|
+
fileName: restHooks_server_jsxFileName,
|
|
428
|
+
lineNumber: 33,
|
|
429
|
+
columnNumber: 12
|
|
430
|
+
}
|
|
431
|
+
}, nextProps.app),
|
|
432
|
+
// TODO: figure out how to only inject in next and not have to also put here
|
|
433
|
+
controller,
|
|
434
|
+
store
|
|
438
435
|
};
|
|
439
436
|
};
|
|
440
437
|
}
|
|
@@ -458,37 +455,35 @@ function routerSpout(options) {
|
|
|
458
455
|
__self: this,
|
|
459
456
|
__source: {
|
|
460
457
|
fileName: router_server_jsxFileName,
|
|
461
|
-
lineNumber:
|
|
458
|
+
lineNumber: 25,
|
|
462
459
|
columnNumber: 9
|
|
463
460
|
}
|
|
464
461
|
}, children);
|
|
465
462
|
};
|
|
466
463
|
|
|
467
|
-
return
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
router
|
|
491
|
-
};
|
|
464
|
+
return next => async props => {
|
|
465
|
+
const url = props.req.url || '';
|
|
466
|
+
const router = options.createRouter((0,external_history_namespaceObject.createMemoryHistory)({
|
|
467
|
+
initialEntries: [url]
|
|
468
|
+
}));
|
|
469
|
+
const matchedRoutes = router.getMatchedRoutes(url);
|
|
470
|
+
const nextProps = await next({ ...props,
|
|
471
|
+
matchedRoutes,
|
|
472
|
+
router
|
|
473
|
+
});
|
|
474
|
+
const Router = createRouteComponent(router);
|
|
475
|
+
return { ...nextProps,
|
|
476
|
+
app: /*#__PURE__*/external_react_default().createElement(Router, {
|
|
477
|
+
__self: this,
|
|
478
|
+
__source: {
|
|
479
|
+
fileName: router_server_jsxFileName,
|
|
480
|
+
lineNumber: 48,
|
|
481
|
+
columnNumber: 12
|
|
482
|
+
}
|
|
483
|
+
}, nextProps.app),
|
|
484
|
+
// TODO: figure out how to only inject in next and not have to also put here
|
|
485
|
+
matchedRoutes,
|
|
486
|
+
router
|
|
492
487
|
};
|
|
493
488
|
};
|
|
494
489
|
}
|
|
@@ -520,13 +515,12 @@ var json_server_jsxFileName = "/home/ntucker/src/anansi/packages/core/src/spouts
|
|
|
520
515
|
function JSONSpout({
|
|
521
516
|
id = 'anansi-json'
|
|
522
517
|
} = {}) {
|
|
523
|
-
return
|
|
524
|
-
|
|
525
|
-
var _nextProps$scripts;
|
|
518
|
+
return next => async props => {
|
|
519
|
+
var _nextProps$scripts;
|
|
526
520
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
521
|
+
const nextProps = await next(props);
|
|
522
|
+
const scripts = (_nextProps$scripts = nextProps.scripts) != null ? _nextProps$scripts : [];
|
|
523
|
+
/*
|
|
530
524
|
Object.entries(nextProps.initData ?? {}).forEach(([key, data]) => {
|
|
531
525
|
try {
|
|
532
526
|
const encoded = JSON.stringify(data);
|
|
@@ -547,49 +541,48 @@ function JSONSpout({
|
|
|
547
541
|
}
|
|
548
542
|
});*/
|
|
549
543
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
544
|
+
const Script = () => {
|
|
545
|
+
try {
|
|
546
|
+
var _nextProps$initData;
|
|
553
547
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
548
|
+
const data = {};
|
|
549
|
+
Object.entries((_nextProps$initData = nextProps.initData) != null ? _nextProps$initData : {}).forEach(([key, getData]) => {
|
|
550
|
+
data[key] = getData();
|
|
551
|
+
});
|
|
552
|
+
const encoded = JSON.stringify(data);
|
|
553
|
+
return /*#__PURE__*/external_react_default().createElement("script", {
|
|
554
|
+
key: id,
|
|
555
|
+
id: id,
|
|
556
|
+
type: "application/json",
|
|
557
|
+
dangerouslySetInnerHTML: {
|
|
558
|
+
__html: encoded
|
|
559
|
+
},
|
|
560
|
+
nonce: props.nonce,
|
|
561
|
+
__self: this,
|
|
562
|
+
__source: {
|
|
563
|
+
fileName: json_server_jsxFileName,
|
|
564
|
+
lineNumber: 49,
|
|
565
|
+
columnNumber: 11
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
} catch (e) {
|
|
569
|
+
// TODO: Use unified logging
|
|
570
|
+
console.error('Error serializing json');
|
|
571
|
+
console.error(e);
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
};
|
|
581
575
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
};
|
|
576
|
+
scripts.push( /*#__PURE__*/external_react_default().createElement(Script, {
|
|
577
|
+
__self: this,
|
|
578
|
+
__source: {
|
|
579
|
+
fileName: json_server_jsxFileName,
|
|
580
|
+
lineNumber: 66,
|
|
581
|
+
columnNumber: 18
|
|
582
|
+
}
|
|
583
|
+
}));
|
|
584
|
+
return { ...nextProps,
|
|
585
|
+
scripts
|
|
593
586
|
};
|
|
594
587
|
};
|
|
595
588
|
}
|
|
@@ -610,6 +603,7 @@ const appSpout = app => props => Promise.resolve({ ...props,
|
|
|
610
603
|
|
|
611
604
|
|
|
612
605
|
|
|
606
|
+
|
|
613
607
|
module.exports = __webpack_exports__;
|
|
614
608
|
/******/ })()
|
|
615
609
|
;
|