@anansi/core 0.11.1 → 0.11.2
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 +15 -0
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/server.js +13 -12
- package/dist/server.js.map +1 -1
- package/lib/spouts/DocumentComponent.d.ts.map +1 -1
- package/lib/spouts/DocumentComponent.js +3 -2
- package/lib/spouts/json.js +2 -2
- package/package.json +3 -3
- package/src/spouts/DocumentComponent.tsx +6 -1
- package/src/spouts/json.tsx +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.11.2](https://github.com/ntucker/anansi/compare/@anansi/core@0.11.1...@anansi/core@0.11.2) (2022-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 💅 Enhancement
|
|
10
|
+
|
|
11
|
+
* Do not override 'unsafe-inline' with nonce for CSP ([cfbd2bd](https://github.com/ntucker/anansi/commit/cfbd2bdfa69ae97ef2db6a824496888420251371))
|
|
12
|
+
* Use 'text' to get inline JSON ([9ecdb07](https://github.com/ntucker/anansi/commit/9ecdb074d01e6f09c28a685433105cf0d6f711cc))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 📦 Package
|
|
16
|
+
|
|
17
|
+
* Update `webpack-cli` to v4.10.0 ([#1543](https://github.com/ntucker/anansi/issues/1543)) ([298cb01](https://github.com/ntucker/anansi/commit/298cb018db2975fb5c926c48d2145d7c1f4515b9))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
### [0.11.1](https://github.com/ntucker/anansi/compare/@anansi/core@0.11.0...@anansi/core@0.11.1) (2022-06-13)
|
|
7
22
|
|
|
8
23
|
|
package/dist/client.js
CHANGED
|
@@ -176,7 +176,7 @@ function JSONSpout({
|
|
|
176
176
|
|
|
177
177
|
function getDatafromDOM(id) {
|
|
178
178
|
const element = document.querySelector(`#${id}`);
|
|
179
|
-
return element !== null && element !== void 0 && element.
|
|
179
|
+
return element !== null && element !== void 0 && element.text ? JSON.parse(element === null || element === void 0 ? void 0 : element.text) : undefined;
|
|
180
180
|
}
|
|
181
181
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
182
182
|
|
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;;;;;;;;;;;;;;;;;;ACNA;;ACAA;AAEA;AAIA;AAAA;AACA;;AACA;AAAA;AAAA;AAEA;AACA;;ACDA;AAIA;AAGA;AACA;AAEA;AACA;AACA;AACA;;ACvBA;;;ACAA;;;;ACAA;AAWA;AAGA;AAAA;AAEA;AAGA;AACA;AAEA;AAEA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAHA;AAQA;AACA;AACA;;AClCA;;ACAA;;;ACAA;AACA;AACA;AAOA;AAMA;AAGA;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAHA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;;AAEA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAJA;AAMA;AACA;AACA;;AC5CA;AACA;AADA;AAGA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;ACxBA;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/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: () => 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 { ResolveProps } from './types';\n\ntype NeededProps = {\n matchedRoutes: Route<any>[];\n title?: string;\n} & ResolveProps;\n\nexport default function documentSpout(options: {\n head?: React.ReactNode;\n title: string;\n}) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const nextProps = await next(initData);\n\n return nextProps;\n };\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 { ResolveProps } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const data = initData.resthooks as State<unknown>;\n\n const nextProps = await next(initData);\n\n return {\n ...nextProps,\n app: (\n <CacheProvider initialState={data} managers={options.getManagers()}>\n {nextProps.app}\n </CacheProvider>\n ),\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 { ResolveProps, CreateRouter } from './types';\n\ntype NeededProps = ResolveProps;\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}) {\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 function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const history = createBrowserHistory();\n const router = options.createRouter(history);\n const matchedRoutes = router.getMatchedRoutes(history.location.pathname);\n\n const nextProps = await next(initData);\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\n };\n };\n}\n","import React from 'react';\nimport type { Route } from '@anansi/router';\n\nimport type { ResolveProps } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async () => {\n const initData = getDatafromDOM(id);\n const nextProps = await next(initData);\n\n return nextProps;\n };\n };\n}\nfunction getDatafromDOM(id: string): Record<string, unknown> {\n const element = document.querySelector(`#${id}`);\n return element?.
|
|
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;;ACDA;AAIA;AAGA;AACA;AAEA;AACA;AACA;AACA;;ACvBA;;;ACAA;;;;ACAA;AAWA;AAGA;AAAA;AAEA;AAGA;AACA;AAEA;AAEA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAHA;AAQA;AACA;AACA;;AClCA;;ACAA;;;ACAA;AACA;AACA;AAOA;AAMA;AAGA;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAHA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;;AAEA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAJA;AAMA;AACA;AACA;;AC5CA;AACA;AADA;AAGA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;ACxBA;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/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: () => 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 { ResolveProps } from './types';\n\ntype NeededProps = {\n matchedRoutes: Route<any>[];\n title?: string;\n} & ResolveProps;\n\nexport default function documentSpout(options: {\n head?: React.ReactNode;\n title: string;\n}) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const nextProps = await next(initData);\n\n return nextProps;\n };\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 { ResolveProps } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const data = initData.resthooks as State<unknown>;\n\n const nextProps = await next(initData);\n\n return {\n ...nextProps,\n app: (\n <CacheProvider initialState={data} managers={options.getManagers()}>\n {nextProps.app}\n </CacheProvider>\n ),\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 { ResolveProps, CreateRouter } from './types';\n\ntype NeededProps = ResolveProps;\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}) {\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 function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async (initData: Record<string, unknown>) => {\n const history = createBrowserHistory();\n const router = options.createRouter(history);\n const matchedRoutes = router.getMatchedRoutes(history.location.pathname);\n\n const nextProps = await next(initData);\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\n };\n };\n}\n","import React from 'react';\nimport type { Route } from '@anansi/router';\n\nimport type { ResolveProps } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}) {\n return function <T extends NeededProps>(\n next: (initData: Record<string, unknown>) => Promise<T>,\n ) {\n return async () => {\n const initData = getDatafromDOM(id);\n const nextProps = await next(initData);\n\n return nextProps;\n };\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","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';\n"],"names":[],"sourceRoot":""}
|
package/dist/server.js
CHANGED
|
@@ -175,7 +175,8 @@ function Document({
|
|
|
175
175
|
const policy = { ...csPolicy
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
if (nonce
|
|
178
|
+
if (nonce && ( // nonces negate 'unsafe-inline' so do not add it if that directive exists
|
|
179
|
+
!policy['script-src'] || !policy['script-src'].includes("'unsafe-inline'"))) {
|
|
179
180
|
if (typeof policy['script-src'] === 'string') {
|
|
180
181
|
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
181
182
|
} else {
|
|
@@ -189,7 +190,7 @@ function Document({
|
|
|
189
190
|
__self: this,
|
|
190
191
|
__source: {
|
|
191
192
|
fileName: _jsxFileName,
|
|
192
|
-
lineNumber:
|
|
193
|
+
lineNumber: 46,
|
|
193
194
|
columnNumber: 7
|
|
194
195
|
}
|
|
195
196
|
});
|
|
@@ -199,14 +200,14 @@ function Document({
|
|
|
199
200
|
__self: this,
|
|
200
201
|
__source: {
|
|
201
202
|
fileName: _jsxFileName,
|
|
202
|
-
lineNumber:
|
|
203
|
+
lineNumber: 50,
|
|
203
204
|
columnNumber: 5
|
|
204
205
|
}
|
|
205
206
|
}, /*#__PURE__*/external_react_default().createElement("head", {
|
|
206
207
|
__self: this,
|
|
207
208
|
__source: {
|
|
208
209
|
fileName: _jsxFileName,
|
|
209
|
-
lineNumber:
|
|
210
|
+
lineNumber: 51,
|
|
210
211
|
columnNumber: 7
|
|
211
212
|
}
|
|
212
213
|
}, /*#__PURE__*/external_react_default().createElement("meta", {
|
|
@@ -214,7 +215,7 @@ function Document({
|
|
|
214
215
|
__self: this,
|
|
215
216
|
__source: {
|
|
216
217
|
fileName: _jsxFileName,
|
|
217
|
-
lineNumber:
|
|
218
|
+
lineNumber: 52,
|
|
218
219
|
columnNumber: 9
|
|
219
220
|
}
|
|
220
221
|
}), cspMeta, head, assets.map((asset, i) => /*#__PURE__*/external_react_default().createElement("link", {
|
|
@@ -224,21 +225,21 @@ function Document({
|
|
|
224
225
|
__self: this,
|
|
225
226
|
__source: {
|
|
226
227
|
fileName: _jsxFileName,
|
|
227
|
-
lineNumber:
|
|
228
|
+
lineNumber: 56,
|
|
228
229
|
columnNumber: 11
|
|
229
230
|
}
|
|
230
231
|
})), /*#__PURE__*/external_react_default().createElement("title", {
|
|
231
232
|
__self: this,
|
|
232
233
|
__source: {
|
|
233
234
|
fileName: _jsxFileName,
|
|
234
|
-
lineNumber:
|
|
235
|
+
lineNumber: 58,
|
|
235
236
|
columnNumber: 9
|
|
236
237
|
}
|
|
237
238
|
}, title)), /*#__PURE__*/external_react_default().createElement("body", {
|
|
238
239
|
__self: this,
|
|
239
240
|
__source: {
|
|
240
241
|
fileName: _jsxFileName,
|
|
241
|
-
lineNumber:
|
|
242
|
+
lineNumber: 60,
|
|
242
243
|
columnNumber: 7
|
|
243
244
|
}
|
|
244
245
|
}, /*#__PURE__*/external_react_default().createElement("div", {
|
|
@@ -246,7 +247,7 @@ function Document({
|
|
|
246
247
|
__self: this,
|
|
247
248
|
__source: {
|
|
248
249
|
fileName: _jsxFileName,
|
|
249
|
-
lineNumber:
|
|
250
|
+
lineNumber: 61,
|
|
250
251
|
columnNumber: 9
|
|
251
252
|
}
|
|
252
253
|
}, children), scripts, assets.filter(({
|
|
@@ -260,7 +261,7 @@ function Document({
|
|
|
260
261
|
__self: this,
|
|
261
262
|
__source: {
|
|
262
263
|
fileName: _jsxFileName,
|
|
263
|
-
lineNumber:
|
|
264
|
+
lineNumber: 66,
|
|
264
265
|
columnNumber: 13
|
|
265
266
|
}
|
|
266
267
|
}))));
|
|
@@ -272,7 +273,7 @@ Document.defaultProps = {
|
|
|
272
273
|
__self: undefined,
|
|
273
274
|
__source: {
|
|
274
275
|
fileName: _jsxFileName,
|
|
275
|
-
lineNumber:
|
|
276
|
+
lineNumber: 75,
|
|
276
277
|
columnNumber: 7
|
|
277
278
|
}
|
|
278
279
|
}), /*#__PURE__*/external_react_default().createElement("link", {
|
|
@@ -281,7 +282,7 @@ Document.defaultProps = {
|
|
|
281
282
|
__self: undefined,
|
|
282
283
|
__source: {
|
|
283
284
|
fileName: _jsxFileName,
|
|
284
|
-
lineNumber:
|
|
285
|
+
lineNumber: 76,
|
|
285
286
|
columnNumber: 7
|
|
286
287
|
}
|
|
287
288
|
})),
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.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;;;ACAA;AACA;AAKA;AAIA;AAAA;AAEA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;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;AAEA;;AApBA;AAwBA;;AACA;AACA;;AACA;AACA;;AC/DA;;;ACIA;AACA;AACA;AAEA;AAKA;;AACA;AACA;AAGA;AACA;;AAEA;AACA;AAEA;;;;;;ACvBA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA;AAWA;;AACA;AACA;AACA;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAA;AAAA;AAAA;AAAA;AAPA;AASA;AACA;AACA;;ACjCA;;ACAA;;;ACAA;AACA;AACA;AAMA;AAKA;AAGA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;;AAEA;AAGA;AACA;AACA;AACA;AAAA;AAEA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAJA;AAMA;AACA;AACA;;ACvCA;AACA;AAOA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;;ACjCA;AAaA;AACA;AADA;AAGA;AAGA;AAAA;;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AAGA;AAPA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAEA;AAFA;AAIA;AACA;AACA;;AC5EA;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/server\"","/home/ntucker/src/anansi/packages/core/external node-commonjs \"crypto\"","/home/ntucker/src/anansi/packages/core/src/laySpouts.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/src/spouts/csp.ts","/home/ntucker/src/anansi/packages/core/src/spouts/DocumentComponent.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/document.server.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/core\"","/home/ntucker/src/anansi/packages/core/external commonjs \"rest-hooks\"","/home/ntucker/src/anansi/packages/core/external commonjs \"redux\"","/home/ntucker/src/anansi/packages/core/src/spouts/rhHelp.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.server.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.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/prefetch.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.server.tsx","/home/ntucker/src/anansi/packages/core/src/index.server.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/server\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"crypto\");","import { renderToPipeableStream as reactRender } from 'react-dom/server';\nimport crypto from 'crypto';\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 { timeoutMS = 200 }: { timeoutMS?: number } = {},\n) {\n const render: Render = async (clientManifest, req, res) => {\n const nonce = crypto.randomBytes(16).toString('base64');\n\n const { app } = await spouts({ clientManifest, req, res, nonce });\n let didError = false;\n const { pipe, abort } = reactRender(\n app,\n /*\n This is not documented, so included the types here for reference:\ntype Options = {|\n identifierPrefix?: string,\n namespaceURI?: string,\n nonce?: string,\n bootstrapScriptContent?: string,\n bootstrapScripts?: Array<string>,\n bootstrapModules?: Array<string>,\n progressiveChunkSize?: number,\n onShellReady?: () => void,\n onShellError?: () => void,\n onAllReady?: () => void,\n onError?: (error: mixed) => void,\n|};\n */\n {\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(x: any) {\n didError = true;\n console.error(x);\n res.statusCode = 500;\n //pipe(res); Removing this avoids, \"React currently only supports piping to one writable stream.\"\n },\n },\n );\n // Abandon and switch to client rendering if enough time passes.\n // Try lowering this to see the client recover.\n setTimeout(abort, timeoutMS);\n };\n return render;\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","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 { 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 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}: Props) {\n let cspMeta: null | React.ReactNode = null;\n if (csPolicy) {\n // add nonce to policy\n const policy = {\n ...csPolicy,\n };\n if (nonce) {\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 {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';\nimport type { Route } from '@anansi/router';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { ServerProps, ResolveProps } from './types';\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\n\ntype NeededProps = {\n matchedRoutes: Route<any>[];\n title?: string;\n scripts?: React.ReactNode[];\n} & ResolveProps;\n\nexport default function DocumentSpout(options: {\n head?: React.ReactNode;\n title: string;\n rootId?: string;\n charSet?: string;\n csPolicy?: Policy;\n}) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\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 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}\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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@rest-hooks/core\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rest-hooks\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"redux\");","import { ExternalCacheProvider, PromiseifyMiddleware } from 'rest-hooks';\nimport {\n Controller,\n createReducer,\n initialState,\n Manager,\n applyManager,\n NetworkManager,\n} from '@rest-hooks/core';\nimport { createStore, applyMiddleware } from 'redux';\n\n// TODO: Rework this and upstream to rest hooks\nexport function createPersistedStore(managers?: Manager[]) {\n const controller = new Controller();\n managers = managers ?? [new NetworkManager()];\n const reducer = createReducer(controller);\n const enhancer = applyMiddleware(\n ...applyManager(managers, controller),\n PromiseifyMiddleware as any,\n );\n const store = createStore(reducer, initialState as any, enhancer);\n managers.forEach(manager => manager.init?.(store.getState()));\n\n const selector = (state: any) => state;\n function ServerCacheProvider({ children }: { children: React.ReactNode }) {\n return (\n <ExternalCacheProvider\n store={store}\n selector={selector}\n controller={controller}\n >\n {children}\n </ExternalCacheProvider>\n );\n }\n return [ServerCacheProvider, controller, store] as const;\n}\n","import { Manager, NetworkManager } from '@rest-hooks/core';\n\nimport { createPersistedStore } from './rhHelp';\nimport type { ResolveProps, ServerProps } from './types';\n\ntype NeededProps = { initData?: Record<string, () => unknown> } & ResolveProps;\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\n const [ServerCacheProvider, controller, store] = createPersistedStore(\n options.getManagers(),\n );\n\n const nextProps = await next(props);\n\n return {\n ...nextProps,\n controller,\n initData: {\n ...nextProps.initData,\n resthooks: () => store.getState(),\n },\n app: <ServerCacheProvider>{nextProps.app}</ServerCacheProvider>,\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 { createMemoryHistory } from 'history';\n\nimport type { ResolveProps, ServerProps, CreateRouter } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\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 function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\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(props);\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\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 <RouteWith, T extends NeededProps<RouteWith>>(\n next: (props: ServerProps) => Promise<\n {\n [K in F]: RouteWith;\n } & T\n >,\n ) {\n return async (props: ServerProps) => {\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 React from 'react';\nimport type { Route } from '@anansi/router';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { ServerProps, ResolveProps } from './types';\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\n\ntype NeededProps = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n} & ResolveProps;\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n /*\n Object.entries(nextProps.initData ?? {}).forEach(([key, data]) => {\n try {\n const encoded = JSON.stringify(data);\n scripts.push(\n <script\n key={key}\n id={`${id}-${key}`}\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(e);\n }\n });*/\n const Script = () => {\n try {\n const data: any = {};\n Object.entries(nextProps.initData ?? {}).forEach(([key, getData]) => {\n data[key] = getData();\n });\n const encoded = JSON.stringify(data);\n return (\n <script\n key={id}\n id={id}\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');\n console.error(e);\n return null;\n }\n };\n scripts.push(<Script />);\n\n return {\n ...nextProps,\n scripts,\n };\n };\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 routerSpout } from './spouts/router.server';\nexport { default as prefetchSpout } from './spouts/prefetch.server';\nexport { default as JSONSpout } from './spouts/json.server';\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"server.js","mappings":";;AAAA;AACA;AACA;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AADA;AAGA;AAPA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAEA;AAFA;AAIA;AACA;AACA;;AC5EA;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/server\"","/home/ntucker/src/anansi/packages/core/external node-commonjs \"crypto\"","/home/ntucker/src/anansi/packages/core/src/laySpouts.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"react\"","/home/ntucker/src/anansi/packages/core/src/spouts/csp.ts","/home/ntucker/src/anansi/packages/core/src/spouts/DocumentComponent.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/document.server.tsx","/home/ntucker/src/anansi/packages/core/external commonjs \"@rest-hooks/core\"","/home/ntucker/src/anansi/packages/core/external commonjs \"rest-hooks\"","/home/ntucker/src/anansi/packages/core/external commonjs \"redux\"","/home/ntucker/src/anansi/packages/core/src/spouts/rhHelp.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/restHooks.server.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.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/prefetch.server.tsx","/home/ntucker/src/anansi/packages/core/src/spouts/json.server.tsx","/home/ntucker/src/anansi/packages/core/src/index.server.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/server\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"crypto\");","import { renderToPipeableStream as reactRender } from 'react-dom/server';\nimport crypto from 'crypto';\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 { timeoutMS = 200 }: { timeoutMS?: number } = {},\n) {\n const render: Render = async (clientManifest, req, res) => {\n const nonce = crypto.randomBytes(16).toString('base64');\n\n const { app } = await spouts({ clientManifest, req, res, nonce });\n let didError = false;\n const { pipe, abort } = reactRender(\n app,\n /*\n This is not documented, so included the types here for reference:\ntype Options = {|\n identifierPrefix?: string,\n namespaceURI?: string,\n nonce?: string,\n bootstrapScriptContent?: string,\n bootstrapScripts?: Array<string>,\n bootstrapModules?: Array<string>,\n progressiveChunkSize?: number,\n onShellReady?: () => void,\n onShellError?: () => void,\n onAllReady?: () => void,\n onError?: (error: mixed) => void,\n|};\n */\n {\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(x: any) {\n didError = true;\n console.error(x);\n res.statusCode = 500;\n //pipe(res); Removing this avoids, \"React currently only supports piping to one writable stream.\"\n },\n },\n );\n // Abandon and switch to client rendering if enough time passes.\n // Try lowering this to see the client recover.\n setTimeout(abort, timeoutMS);\n };\n return render;\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","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 { 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 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}: 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 {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';\nimport type { Route } from '@anansi/router';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { ServerProps, ResolveProps } from './types';\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\n\ntype NeededProps = {\n matchedRoutes: Route<any>[];\n title?: string;\n scripts?: React.ReactNode[];\n} & ResolveProps;\n\nexport default function DocumentSpout(options: {\n head?: React.ReactNode;\n title: string;\n rootId?: string;\n charSet?: string;\n csPolicy?: Policy;\n}) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\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 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}\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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@rest-hooks/core\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rest-hooks\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"redux\");","import { ExternalCacheProvider, PromiseifyMiddleware } from 'rest-hooks';\nimport {\n Controller,\n createReducer,\n initialState,\n Manager,\n applyManager,\n NetworkManager,\n} from '@rest-hooks/core';\nimport { createStore, applyMiddleware } from 'redux';\n\n// TODO: Rework this and upstream to rest hooks\nexport function createPersistedStore(managers?: Manager[]) {\n const controller = new Controller();\n managers = managers ?? [new NetworkManager()];\n const reducer = createReducer(controller);\n const enhancer = applyMiddleware(\n ...applyManager(managers, controller),\n PromiseifyMiddleware as any,\n );\n const store = createStore(reducer, initialState as any, enhancer);\n managers.forEach(manager => manager.init?.(store.getState()));\n\n const selector = (state: any) => state;\n function ServerCacheProvider({ children }: { children: React.ReactNode }) {\n return (\n <ExternalCacheProvider\n store={store}\n selector={selector}\n controller={controller}\n >\n {children}\n </ExternalCacheProvider>\n );\n }\n return [ServerCacheProvider, controller, store] as const;\n}\n","import { Manager, NetworkManager } from '@rest-hooks/core';\n\nimport { createPersistedStore } from './rhHelp';\nimport type { ResolveProps, ServerProps } from './types';\n\ntype NeededProps = { initData?: Record<string, () => unknown> } & ResolveProps;\n\nexport default function restHooksSpout(\n options: {\n getManagers: () => Manager[];\n } = { getManagers: () => [new NetworkManager()] },\n) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\n const [ServerCacheProvider, controller, store] = createPersistedStore(\n options.getManagers(),\n );\n\n const nextProps = await next(props);\n\n return {\n ...nextProps,\n controller,\n initData: {\n ...nextProps.initData,\n resthooks: () => store.getState(),\n },\n app: <ServerCacheProvider>{nextProps.app}</ServerCacheProvider>,\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 { createMemoryHistory } from 'history';\n\nimport type { ResolveProps, ServerProps, CreateRouter } from './types';\n\ntype NeededProps = ResolveProps;\n\nexport default function routerSpout<ResolveWith>(options: {\n resolveWith?: any;\n useResolveWith: () => ResolveWith;\n createRouter: CreateRouter<ResolveWith>;\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 function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\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(props);\n\n const Router = createRouteComponent(router);\n return {\n ...nextProps,\n matchedRoutes,\n router,\n app: <Router>{nextProps.app}</Router>,\n };\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 <RouteWith, T extends NeededProps<RouteWith>>(\n next: (props: ServerProps) => Promise<\n {\n [K in F]: RouteWith;\n } & T\n >,\n ) {\n return async (props: ServerProps) => {\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 React from 'react';\nimport type { Route } from '@anansi/router';\nimport { StatsChunkGroup } from 'webpack';\n\nimport type { ServerProps, ResolveProps } from './types';\nimport type { Policy } from './csp';\nimport Document from './DocumentComponent';\n\ntype NeededProps = {\n initData?: Record<string, () => unknown>;\n scripts?: React.ReactNode[];\n} & ResolveProps;\n\nexport default function JSONSpout({\n id = 'anansi-json',\n}: { id?: string } = {}) {\n return function <T extends NeededProps>(\n next: (props: ServerProps) => Promise<T>,\n ) {\n return async (props: ServerProps) => {\n const nextProps = await next(props);\n\n const scripts: React.ReactNode[] = nextProps.scripts ?? [];\n /*\n Object.entries(nextProps.initData ?? {}).forEach(([key, data]) => {\n try {\n const encoded = JSON.stringify(data);\n scripts.push(\n <script\n key={key}\n id={`${id}-${key}`}\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(e);\n }\n });*/\n const Script = () => {\n try {\n const data: any = {};\n Object.entries(nextProps.initData ?? {}).forEach(([key, getData]) => {\n data[key] = getData();\n });\n const encoded = JSON.stringify(data);\n return (\n <script\n key={id}\n id={id}\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');\n console.error(e);\n return null;\n }\n };\n scripts.push(<Script />);\n\n return {\n ...nextProps,\n scripts,\n };\n };\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 routerSpout } from './spouts/router.server';\nexport { default as prefetchSpout } from './spouts/prefetch.server';\nexport { default as JSONSpout } from './spouts/json.server';\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,aAAK,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,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,GACR,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,aAAK,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,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,GACR,EAAE,KAAK,eA6CP;kBAvDuB,QAAQ;;;;;;;;eAAR,QAAQ"}
|
|
@@ -31,7 +31,8 @@ function Document({
|
|
|
31
31
|
const policy = { ...csPolicy
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
if (nonce
|
|
34
|
+
if (nonce && ( // nonces negate 'unsafe-inline' so do not add it if that directive exists
|
|
35
|
+
!policy['script-src'] || !policy['script-src'].includes("'unsafe-inline'"))) {
|
|
35
36
|
if (typeof policy['script-src'] === 'string') {
|
|
36
37
|
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
37
38
|
} else {
|
|
@@ -75,4 +76,4 @@ Document.defaultProps = {
|
|
|
75
76
|
rootId: 'anansi-root',
|
|
76
77
|
scripts: null
|
|
77
78
|
};
|
|
78
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
79
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJEb2N1bWVudCIsImFzc2V0cyIsImhlYWQiLCJjaGlsZHJlbiIsInRpdGxlIiwicm9vdElkIiwiY2hhclNldCIsImNzUG9saWN5Iiwibm9uY2UiLCJzY3JpcHRzIiwiY3NwTWV0YSIsInBvbGljeSIsImluY2x1ZGVzIiwiYnVpbGRQb2xpY3kiLCJtYXAiLCJhc3NldCIsImkiLCJmaWx0ZXIiLCJocmVmIiwiZW5kc1dpdGgiLCJkZWZhdWx0UHJvcHMiLCJwcm9jZXNzIiwiZW52IiwiV0VCUEFDS19QVUJMSUNfUEFUSCJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zcG91dHMvRG9jdW1lbnRDb21wb25lbnQudHN4Il0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUG9saWN5IH0gZnJvbSAnLi9jc3AnO1xuaW1wb3J0IHsgYnVpbGRQb2xpY3kgfSBmcm9tICcuL2NzcCc7XG5cbnR5cGUgUHJvcHMgPSB7XG4gIGNoaWxkcmVuOiBSZWFjdC5SZWFjdE5vZGU7XG4gIGFzc2V0czogeyBocmVmOiBzdHJpbmc7IGFzPzogc3RyaW5nOyByZWw/OiBzdHJpbmcgfVtdO1xuICBoZWFkOiBSZWFjdC5SZWFjdE5v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CLE9BQU8sRUFBQztFQUE5QixFQURGLGVBRUU7SUFDRSxHQUFHLEVBQUMsZUFETjtJQUVFLElBQUksRUFBRyxHQUFELHlCQUFHbUIsT0FBTyxDQUFDQyxHQUFSLENBQVlDLG1CQUFmLG9DQUFzQyxHQUFJO0VBRmxELEVBRkYsQ0FGb0I7RUFVdEJqQixPQUFPLEVBQUUsT0FWYTtFQVd0QkQsTUFBTSxFQUFFLGFBWGM7RUFZdEJJLE9BQU8sRUFBRTtBQVphLENBQXhCIn0=
|
package/lib/spouts/json.js
CHANGED
|
@@ -17,6 +17,6 @@ function JSONSpout({
|
|
|
17
17
|
|
|
18
18
|
function getDatafromDOM(id) {
|
|
19
19
|
const element = document.querySelector(`#${id}`);
|
|
20
|
-
return element !== null && element !== void 0 && element.
|
|
20
|
+
return element !== null && element !== void 0 && element.text ? JSON.parse(element === null || element === void 0 ? void 0 : element.text) : undefined;
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJKU09OU3BvdXQiLCJpZCIsIm5leHQiLCJpbml0RGF0YSIsImdldERhdGFmcm9tRE9NIiwibmV4dFByb3BzIiwiZWxlbWVudCIsImRvY3VtZW50IiwicXVlcnlTZWxlY3RvciIsInRleHQiLCJKU09OIiwicGFyc2UiLCJ1bmRlZmluZWQiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvc3BvdXRzL2pzb24udHN4Il0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCc7XG5pbXBvcnQgdHlwZSB7IFJvdXRlIH0gZnJvbSAnQGFuYW5zaS9yb3V0ZXInO1xuXG5pbXBvcnQgdHlwZSB7IFJlc29sdmVQcm9wcyB9IGZyb20gJy4vdHlwZXMnO1xuXG50eXBlIE5lZWRlZFByb3BzID0gUmVzb2x2ZVByb3BzO1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NBQVA7SUFDRCxDQUxEO0VBTUQsQ0FURDtBQVVEOztBQUNELFNBQVNELGNBQVQsQ0FBd0JILEVBQXhCLEVBQTZEO0VBQzNELE1BQU1LLE9BQWlDLEdBQUdDLFFBQVEsQ0FBQ0MsYUFBVCxDQUF3QixJQUFHUCxFQUFHLEVBQTlCLENBQTFDO0VBQ0EsT0FBT0ssT0FBTyxTQUFQLElBQUFBLE9BQU8sV0FBUCxJQUFBQSxPQUFPLENBQUVHLElBQVQsR0FBZ0JDLElBQUksQ0FBQ0MsS0FBTCxDQUFXTCxPQUFYLGFBQVdBLE9BQVgsdUJBQVdBLE9BQU8sQ0FBRUcsSUFBcEIsQ0FBaEIsR0FBNENHLFNBQW5EO0FBQ0QifQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anansi/core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "React 18 Framework",
|
|
5
5
|
"homepage": "https://github.com/ntucker/anansi/tree/master/packages/core#readme",
|
|
6
6
|
"repository": {
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
"jest": "28.1.1",
|
|
78
78
|
"rimraf": "^3.0.0",
|
|
79
79
|
"webpack": "^5.72.1",
|
|
80
|
-
"webpack-cli": "
|
|
80
|
+
"webpack-cli": "4.10.0"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@anansi/router": "^0.6.
|
|
83
|
+
"@anansi/router": "^0.6.2",
|
|
84
84
|
"@babel/runtime": "^7.10.5",
|
|
85
85
|
"@rest-hooks/ssr": "^0.2.0",
|
|
86
86
|
"chalk": "^4.0.0",
|
|
@@ -30,7 +30,12 @@ export default function Document({
|
|
|
30
30
|
const policy = {
|
|
31
31
|
...csPolicy,
|
|
32
32
|
};
|
|
33
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
nonce &&
|
|
35
|
+
// nonces negate 'unsafe-inline' so do not add it if that directive exists
|
|
36
|
+
(!policy['script-src'] ||
|
|
37
|
+
!policy['script-src'].includes("'unsafe-inline'"))
|
|
38
|
+
) {
|
|
34
39
|
if (typeof policy['script-src'] === 'string') {
|
|
35
40
|
policy['script-src'] = [policy['script-src'], `'nonce-${nonce}'`];
|
|
36
41
|
} else {
|
package/src/spouts/json.tsx
CHANGED
|
@@ -20,6 +20,6 @@ export default function JSONSpout({
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
function getDatafromDOM(id: string): Record<string, unknown> {
|
|
23
|
-
const element = document.querySelector(`#${id}`);
|
|
24
|
-
return element?.
|
|
23
|
+
const element: HTMLScriptElement | null = document.querySelector(`#${id}`);
|
|
24
|
+
return element?.text ? JSON.parse(element?.text) : undefined;
|
|
25
25
|
}
|