@_linked/server 2.14.0 → 2.14.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 +34 -0
- package/lib/esm/backend.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/ontologies/lincd-server.js.map +1 -1
- package/lib/esm/ontologies/lincd-server.register.js.map +1 -1
- package/lib/esm/package.js.map +1 -1
- package/lib/esm/shapes/LincdAPI.js +4 -1
- package/lib/esm/shapes/LincdAPI.js.map +1 -1
- package/lib/esm/shapes/LincdWebApp.js +4 -1
- package/lib/esm/shapes/LincdWebApp.js.map +1 -1
- package/lib/esm/shapes/LinkedServer.d.ts +22 -1
- package/lib/esm/shapes/LinkedServer.js +159 -79
- package/lib/esm/shapes/LinkedServer.js.map +1 -1
- package/lib/esm/shapes/filestores/LocalFileStore.js.map +1 -1
- package/lib/esm/shapes/quadstores/BackendAPIStore.js.map +1 -1
- package/lib/esm/types/RouteConfig.js.map +1 -1
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/utils/NodeQuadStore.js.map +1 -1
- package/lib/esm/utils/Shapes.js.map +1 -1
- package/lib/esm/utils/accessUrl.js.map +1 -1
- package/lib/esm/utils/bootstrapEntry.d.ts +30 -2
- package/lib/esm/utils/bootstrapEntry.js +32 -2
- package/lib/esm/utils/bootstrapEntry.js.map +1 -1
- package/lib/esm/utils/releaseManifest.js.map +1 -1
- package/lib/esm/utils/resizeSource.js.map +1 -1
- package/lib/esm/utils/resizedImagesPurpose.js.map +1 -1
- package/lib/esm/utils/routeAssets.js.map +1 -1
- package/lib/esm/utils/spaFallback.js.map +1 -1
- package/lib/esm/utils/ssrCss.d.ts +55 -0
- package/lib/esm/utils/ssrCss.js +153 -0
- package/lib/esm/utils/ssrCss.js.map +1 -0
- package/lib/esm/utils/syncShapes.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @\_linked/server
|
|
2
2
|
|
|
3
|
+
## 2.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#104](https://github.com/linked-fw/server/pull/104) [`cf1b14d`](https://github.com/linked-fw/server/commit/cf1b14dfa9c834c2503f7ad4689e66e5f5f24a58) Thanks [@flyon](https://github.com/flyon)! - Dev SSR inlines only the CSS the rendered page needs. The dev server preloads every page into
|
|
8
|
+
Vite's module graph, so `<style id="ssr-css">` carried every page's stylesheets on every page
|
|
9
|
+
(2.3 MB in Create Now). It now holds what the app module and the matched routes' pages import
|
|
10
|
+
statically — what a production build puts in the entry CSS plus the route's CSS (0.78–1.1 MB in
|
|
11
|
+
Create Now, most of it Tailwind's output). Falls back to the whole graph when the page cannot be
|
|
12
|
+
determined, such as a route rendered through a `render` function.
|
|
13
|
+
|
|
14
|
+
## 2.14.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#103](https://github.com/linked-fw/server/pull/103) [`96504ef`](https://github.com/linked-fw/server/commit/96504ef9485b1a193c757fdbcc5a923c1a799fb9) Thanks [@flyon](https://github.com/flyon)! - Dev SSR styling fixes. A development server no longer reads a build manifest left on disk by an
|
|
19
|
+
earlier `vite build`, so it stops linking that stale built CSS next to Vite's live styles. The SSR
|
|
20
|
+
CSS collector skips `?direct` ids and files under Vite's `publicDir` (which failed with "Parse
|
|
21
|
+
failure" when loaded as a module) and loads each stylesheet once. The collected CSS is no longer
|
|
22
|
+
serialised into `assetManifest` as well as the inline `<style>`; that copy was about half of a dev page.
|
|
23
|
+
|
|
24
|
+
- [#103](https://github.com/linked-fw/server/pull/103) [`277e01a`](https://github.com/linked-fw/server/commit/277e01a979d14535e8edcdfc0a84d3ce50c72c82) Thanks [@flyon](https://github.com/flyon)! - Name the `LincdAPI`, `LinkedServer` and `LincdWebApp` shapes explicitly. Their IRIs were derived
|
|
25
|
+
from the class name, which an esbuild pass over the compiled JS (Vite's dev-SSR `define` step)
|
|
26
|
+
renames to `LincdAPI2` / `LinkedServer2`, so dev and production minted different IRIs.
|
|
27
|
+
|
|
28
|
+
- [#103](https://github.com/linked-fw/server/pull/103) [`1332aae`](https://github.com/linked-fw/server/commit/1332aaec4eba795bd0d132252ca4f156d6517bd2) Thanks [@flyon](https://github.com/flyon)! - Embed the TypeScript sources in the published sourcemaps (`inlineSources`). The maps pointed at
|
|
29
|
+
`src/*.ts`, which the tarball does not contain, so Vite dev warned that each sourcemap "points to
|
|
30
|
+
missing source files".
|
|
31
|
+
|
|
32
|
+
- [#103](https://github.com/linked-fw/server/pull/103) [`ecb97e6`](https://github.com/linked-fw/server/commit/ecb97e6aba759e6ee39841069fe2d272ba293257) Thanks [@flyon](https://github.com/flyon)! - The render path now reuses the dev/build decision `start()` makes instead of re-deriving it from a
|
|
33
|
+
manifest field that was never set. A server started outside development with a Vite build on disk
|
|
34
|
+
now boots the built entry and preloads route chunks, instead of emitting the Vite dev preamble
|
|
35
|
+
next to the built CSS.
|
|
36
|
+
|
|
3
37
|
## 2.14.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/lib/esm/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,0BAA2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QACL,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,aAAa,EAAE,CAAC;IACzB,CAAC;IAED,4EAA4E;IAC5E,EAAE;IACF,2DAA2D;IAC3D,gFAAgF;IAChF,6EAA6E;IAC7E,EAAE;IACF,mFAAmF;IACnF,qFAAqF;IACrF,uFAAuF;IACvF,uFAAuF;IACvF,4DAA4D;IAC5D,EAAE;IACF,sFAAsF;IACtF,4EAA4E;IAC5E,uFAAuF;IACvF,qEAAqE;IAErE,WAAW,CAAC,IAAS;QACnB,OAAO,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ,CAAC,IAAS;QAChB,OAAO,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAQ,CAAC,CAAC;IACvD,CAAC;IAED,WAAW,CAAC,IAAS;QACnB,OAAO,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,WAAW,CAAC,IAAS;QACnB,OAAO,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,WAAW,CAAC,IAAS;QACnB,OAAO,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAQ,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { BackendProvider } from '@_linked/server-utils/utils/BackendProvider';\nimport { LinkedFileStorage } from '@_linked/core/utils/LinkedFileStorage';\nimport { LinkedStorage } from '@_linked/core/utils/LinkedStorage';\nimport { fromJSON } from '@_linked/core';\nimport { LocalFileStore } from './shapes/filestores/LocalFileStore.js';\nimport { getShapeIndex } from './utils/Shapes.js';\nimport path from 'path';\nimport fs from 'fs/promises';\n\nexport default class LincdServerBackendProvider extends BackendProvider {\n async setupBeforeControllers() {\n if (!LinkedFileStorage.getDefaultStore()) {\n LinkedFileStorage.setDefaultStore(\n new LocalFileStore(process.env.NODE_ENV + '-filestore')\n );\n }\n let fileSystemUploadPath = path.join('data', 'filestores');\n try {\n await fs.access(fileSystemUploadPath);\n } catch (err) {\n await fs.mkdir(path.join(fileSystemUploadPath, 'filestores'), {\n recursive: true,\n });\n }\n }\n\n getShapes() {\n return getShapeIndex();\n }\n\n // ── BackendAPIStore query execution ──────────────────────────────────────\n //\n // These answer the frontend `BackendAPIStore`, which calls\n // `Server.call(packageName, {method}, json)` — the PACKAGE form, so the request\n // arrives here on the generic provider rather than through Shape resolution.\n //\n // They used to live on `BackendAPIStoreProvider`, a `ShapeProvider`, whose methods\n // took the store as a first argument and never read it. Reaching that provider meant\n // the transport had to carry a `shapeURI` and an `instanceNode`, and the server had to\n // rebuild the store with `new (providerShapeClass)({id})` — instantiating a Shape only\n // to discard it. Addressing by package removes all of that.\n //\n // A query cannot cross the wire live (core 2.10.0 contract flip), so the client ships\n // `toJSON()` and `fromJSON()` rehydrates it here into a live, closed query.\n // `LinkedStorage` then routes it by the QUERY's shape — which is, and always was, what\n // decides the target dataset. The store instance never participated.\n\n selectQuery(json: any) {\n return LinkedStorage.selectQuery(fromJSON(json) as any);\n }\n\n askQuery(json: any) {\n return LinkedStorage.askQuery(fromJSON(json) as any);\n }\n\n updateQuery(json: any) {\n return LinkedStorage.updateQuery(fromJSON(json) as any);\n }\n\n createQuery(json: any) {\n return LinkedStorage.createQuery(fromJSON(json) as any);\n }\n\n deleteQuery(json: any) {\n return LinkedStorage.deleteQuery(fromJSON(json) as any);\n }\n}\n"]}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,uCAAuC,CAAC;AAE/C,cAAc;AACd,OAAO,0BAA0B,CAAC;AAClC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wCAAwC,CAAC;AAChD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,yBAAyB,CAAC;AAEjC,iBAAiB;AACjB,OAAO,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,uCAAuC,CAAC;AAE/C,cAAc;AACd,OAAO,0BAA0B,CAAC;AAClC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wCAAwC,CAAC;AAChD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,yBAAyB,CAAC;AAEjC,iBAAiB;AACjB,OAAO,sBAAsB,CAAC","sourcesContent":["import './types.js';\nimport './ontologies/lincd-server.register.js';\n\n//SHAPES FIRST\nimport './shapes/LinkedServer.js';\nimport './shapes/LincdAPI.js';\nimport './shapes/quadstores/BackendAPIStore.js';\nimport './shapes/filestores/LocalFileStore.js';\nimport './shapes/LincdWebApp.js';\n\n//THEN COMPONENTS\nimport './utils/accessUrl.js';\n\n//TYPES — re-exported from @_linked/server-utils (canonical location)\nexport type {\n RouteConfig,\n RoutesConfig,\n RoutesModule,\n} from '@_linked/server-utils/types/RouteConfig';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lincd-server.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,IAAI,QAAQ,GAAG,KAAK,IAAI,EAAE;IAC/B,YAAY;IACZ,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,2BAA2B,EAAE;QACrD,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;KACvB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,CAAC,IAAI,EAAE,GAAG,eAAe,CAAC,oCAAoC,CAAC,CAAC;AAEtE,MAAM,CAAC,IAA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linked/core, loadData returns the raw JSON import — no JSONLD.parse() needed.\n */\nexport var loadData = async () => {\n //@ts-ignore\n const data = await import('../data/lincd-server.json', {\n with: { type: 'json' },\n });\n return data.default || data;\n};\n\nexport var ns = createNameSpace('http://lincd.org/ont/lincd-server/');\n\nexport var _self = ns('');\n\n// Terms are properties of the namespace object below, not module-scope\n// exports. Most of these names are also SHAPE CLASS names in this package\n// (BackendAPIStore, LincdWebApp, LincdAPI, ...). Two bindings of the same name\n// in one bundle scope make the bundler rename one of them, and when the loser\n// is the class, `constructor.name` becomes `BackendAPIStore2` -- which is the\n// shape's IRI and the name `Server.call` routes on. The client then asks a\n// backend that has no such shape, and every store round-trip answers 501.\nconst LincdServer = ns('LincdServer');\nconst BackendFileStore = ns('BackendFileStore');\nconst NodeFileStore = ns('NodeFileStore');\nconst BackendStore = ns('BackendStore');\nconst BackendAPIStore = ns('BackendAPIStore');\nconst LincdWebApp = ns('LincdWebApp');\nconst ownPackage = ns('ownPackage');\nconst maintainsPackage = ns('maintainsPackage');\nconst N3FileStore = ns('N3FileStore');\nconst LincdAPI = ns('LincdAPI');\nconst hasAPI = ns('hasAPI');\n\nexport const lincdServer = {\n LincdServer,\n BackendFileStore,\n NodeFileStore,\n BackendStore,\n N3FileStore,\n BackendAPIStore,\n LincdWebApp,\n ownPackage,\n maintainsPackage,\n LincdAPI,\n hasAPI,\n};\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lincd-server.register.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-server.register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,cAAc,CACZ,KAAK,EACL,EAAE,EACF,cAAc,EACd,QAAQ,EACR,2BAA2B,CAC5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"lincd-server.register.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-server.register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,cAAc,CACZ,KAAK,EACL,EAAE,EACF,cAAc,EACd,QAAQ,EACR,2BAA2B,CAC5B,CAAC","sourcesContent":["/**\n * Registers this ontology.\n *\n * Kept out of `lincd-server.ts` because registration needs that module's whole export\n * namespace, and a module cannot import itself once a bundler is involved: Rollup\n * treats a static self-reference as a circular import and elides it, so the binding is\n * undefined at runtime and the consuming app dies at boot with `_this is not\n * defined`. `tsc` preserves it, which is why the pattern survived for as long as\n * packages were built with `tsc` alone.\n *\n * From a sibling module the same import is ordinary and survives.\n */\nimport * as terms from './lincd-server.js';\nimport {loadData, ns} from './lincd-server.js';\nimport {linkedOntology} from '../package.js';\n\nlinkedOntology(\n terms,\n ns,\n 'lincd-server',\n loadData,\n '../data/lincd-server.json'\n);\n"]}
|
package/lib/esm/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,MAAM,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,GACZ,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,MAAM,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,GACZ,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import { linkedPackage } from '@_linked/core/utils/Package';\n\nexport const {\n linkedShape,\n linkedUtil,\n linkedOntology,\n packageExports,\n packageName,\n} = linkedPackage('@_linked/server');\n"]}
|
|
@@ -13,6 +13,9 @@ import { JSONWriter } from '@_linked/server-utils/utils/JSONWriter';
|
|
|
13
13
|
import { cached } from '@_linked/core/utils/cached';
|
|
14
14
|
import { getShapeIndex } from '../utils/Shapes.js';
|
|
15
15
|
const cacheTime = process.env.NODE_ENV === 'development' ? 0 : Infinity;
|
|
16
|
+
// Named explicitly: tsc emits `let X = class X`, and any later esbuild pass over that JS (Vite's
|
|
17
|
+
// SSR `define` replacement runs one on every file mentioning a defined `process.env.*`) renames
|
|
18
|
+
// the inner binding to `X2`, which would otherwise become this shape's IRI.
|
|
16
19
|
let LincdAPI = class LincdAPI extends Shape {
|
|
17
20
|
async process(request, response, httpMethod) {
|
|
18
21
|
let { method, action } = request.params;
|
|
@@ -108,7 +111,7 @@ let LincdAPI = class LincdAPI extends Shape {
|
|
|
108
111
|
};
|
|
109
112
|
LincdAPI.targetClass = lincdServer.LincdAPI;
|
|
110
113
|
LincdAPI = __decorate([
|
|
111
|
-
linkedShape
|
|
114
|
+
linkedShape({ name: 'LincdAPI' })
|
|
112
115
|
], LincdAPI);
|
|
113
116
|
export { LincdAPI };
|
|
114
117
|
//# sourceMappingURL=LincdAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LincdAPI.js","sourceRoot":"","sources":["../../../src/shapes/LincdAPI.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAw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,EAAE,UAAU,EAAC,CAAC;GACnB,QAAQ,CAmIpB","sourcesContent":["import { Shape } from '@_linked/core/shapes/Shape';\nimport { linkedShape } from '../package.js';\nimport { lincdServer } from '../ontologies/lincd-server.js';\nimport { JSONParser } from '@_linked/server-utils/utils/JSONParser';\nimport { LinkedStorage } from '@_linked/core/utils/LinkedStorage';\nimport { JSONWriter } from '@_linked/server-utils/utils/JSONWriter';\nimport { cached } from '@_linked/core/utils/cached';\nimport { getShapeIndex, ShapeDetails } from '../utils/Shapes.js';\nimport { SparqlDataset as SPARQLStore } from '@_linked/core/sparql/SparqlDataset';\n\nconst cacheTime = process.env.NODE_ENV === 'development' ? 0 : Infinity;\nexport type ShapeSummary = {\n id: string;\n label: string;\n description: string;\n target: { id: string };\n extends?: { id: string };\n numInstances: number;\n};\n// Named explicitly: tsc emits `let X = class X`, and any later esbuild pass over that JS (Vite's\n// SSR `define` replacement runs one on every file mentioning a defined `process.env.*`) renames\n// the inner binding to `X2`, which would otherwise become this shape's IRI.\n@linkedShape({name: 'LincdAPI'})\nexport class LincdAPI extends Shape {\n static targetClass = lincdServer.LincdAPI;\n\n async process(\n request,\n response,\n httpMethod: 'get' | 'post' | 'put' | 'delete'\n ) {\n let { method, action } = request.params;\n const body = JSONParser.parseObject<any>(request.body);\n\n //replace - with _ in action names\n let localMethod = httpMethod + '_' + method.replace(/-/g, '_');\n if (typeof this[localMethod] !== 'function') {\n throw new Error('Unknown method: ' + localMethod);\n }\n\n //TODO: access rights, check if the current user is allowed to execute this method\n try {\n const result = await this[localMethod](body, request, response);\n if (typeof result !== 'undefined' || !response.headersSent) {\n const jsonObject = JSONWriter.toJsObject(result);\n response.json(jsonObject);\n }\n } catch (error) {\n console.error(`Error while processing ${localMethod}:`, error);\n if (!response.headersSent) {\n const message =\n error instanceof Error ? error.message : 'Unknown server error';\n response.status(500).json({ error: message });\n }\n }\n }\n\n get_shape_details({\n shapes,\n }: {\n shapes: string[];\n }): Record<string, ShapeDetails> {\n return cached(\n () => {\n const shapeIndex = getShapeIndex();\n const filteredShapeIndex = {};\n for (const shapeId of shapes) {\n if (shapeIndex[shapeId]) {\n filteredShapeIndex[shapeId] = shapeIndex[shapeId];\n }\n }\n return filteredShapeIndex;\n },\n [shapes],\n cacheTime\n );\n }\n\n get_all_shapes(): Promise<{\n shapes: Record<string, ShapeDetails>;\n defaultGraph: string;\n }> {\n return cached(\n async () => {\n const shapeIndex = getShapeIndex();\n\n const typesWithInstances = new Map<string, number>();\n this.checkRawQuerySupport();\n await (LinkedStorage.getDefaultDataset() as unknown as SPARQLStore)\n .rawQuery(\n `SELECT (COUNT(?s) AS ?count) ?type WHERE { ?s a ?type } GROUP BY ?type`\n )\n .then((results) => {\n // rawQuery also types ASK results (a boolean envelope); this is a SELECT.\n if (!results || !('results' in results)) return;\n results.results.bindings.forEach((binding) => {\n if (binding.type && binding.type.value) {\n typesWithInstances.set(\n binding.type.value,\n parseInt(binding.count.value)\n );\n }\n });\n })\n .catch(console.error);\n\n const shapesWithInstances: Record<string, ShapeDetails> = {};\n for (const shapeId in shapeIndex) {\n const shape = shapeIndex[shapeId];\n shapesWithInstances[shapeId] = {\n ...shape,\n numInstances: typesWithInstances.get(shape.targetClass?.id) || 0,\n };\n }\n return {\n shapes: shapesWithInstances,\n defaultGraph: process.env.DATA_ROOT,\n };\n },\n [],\n cacheTime\n );\n }\n\n post_select({ query }) {\n return LinkedStorage.selectQuery(query);\n }\n post_create({ query }) {\n return LinkedStorage.createQuery(query);\n }\n post_update({ query }) {\n return LinkedStorage.updateQuery(query);\n }\n post_delete({ query }) {\n return LinkedStorage.deleteQuery(query);\n }\n\n post_select_raw({ query }) {\n this.checkRawQuerySupport();\n return (LinkedStorage.getDefaultDataset() as unknown as SPARQLStore).rawQuery(\n query\n );\n }\n\n private checkRawQuerySupport() {\n if (!(LinkedStorage.getDefaultDataset() as unknown as SPARQLStore).rawQuery) {\n throw new Error(\n `Default store (${\n Object.getPrototypeOf(LinkedStorage.getDefaultDataset()).constructor\n .name\n }) does not support raw SPARQL queries`\n );\n }\n }\n}\n"]}
|
|
@@ -13,6 +13,9 @@ import { lincdServer } from '../ontologies/lincd-server.js';
|
|
|
13
13
|
import { Shape } from '@_linked/core/shapes/Shape';
|
|
14
14
|
import { objectProperty } from '@_linked/core/shapes/SHACL';
|
|
15
15
|
import { Lincd_API_Client } from '@_linked/server-utils/shapes/Lincd_API_Client';
|
|
16
|
+
// Named explicitly: tsc emits `let X = class X`, and any later esbuild pass over that JS (Vite's
|
|
17
|
+
// SSR `define` replacement runs one on every file mentioning a defined `process.env.*`) renames
|
|
18
|
+
// the inner binding to `X2`, which would otherwise become this shape's IRI.
|
|
16
19
|
let LincdWebApp = LincdWebApp_1 = class LincdWebApp extends Shape {
|
|
17
20
|
static get localApp() {
|
|
18
21
|
return new LincdWebApp_1({ id: process.env.SITE_ROOT });
|
|
@@ -34,7 +37,7 @@ __decorate([
|
|
|
34
37
|
__metadata("design:paramtypes", [])
|
|
35
38
|
], LincdWebApp.prototype, "api", null);
|
|
36
39
|
LincdWebApp = LincdWebApp_1 = __decorate([
|
|
37
|
-
linkedShape
|
|
40
|
+
linkedShape({ name: 'LincdWebApp' })
|
|
38
41
|
], LincdWebApp);
|
|
39
42
|
export { LincdWebApp };
|
|
40
43
|
//# sourceMappingURL=LincdWebApp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LincdWebApp.js","sourceRoot":"","sources":["../../../src/shapes/LincdWebApp.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"LincdWebApp.js","sourceRoot":"","sources":["../../../src/shapes/LincdWebApp.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEjF,iGAAiG;AACjG,gGAAgG;AAChG,4EAA4E;AAErE,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,KAAK;IAGpC,MAAM,KAAK,QAAQ;QACjB,OAAO,IAAI,aAAW,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,4EAA4E;IAC5E,8FAA8F;IAE9F,IAKI,GAAG;QACL,OAAO,SAAgB,CAAC;IAC1B,CAAC;;AAhBM,uBAAW,GAAG,WAAW,CAAC,WAAW,AAA1B,CAA2B;AAS7C;IAAC,cAAc,CAAC;QACd,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE,CAAC;KACZ,CAAC;8BACS,gBAAgB;;sCAE1B;AAjBU,WAAW;IADvB,WAAW,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;GACtB,WAAW,CAkBvB","sourcesContent":["import { linkedShape } from '../package.js';\nimport { lincdServer } from '../ontologies/lincd-server.js';\nimport { Shape } from '@_linked/core/shapes/Shape';\nimport { objectProperty } from '@_linked/core/shapes/SHACL';\nimport { Lincd_API_Client } from '@_linked/server-utils/shapes/Lincd_API_Client';\n\n// Named explicitly: tsc emits `let X = class X`, and any later esbuild pass over that JS (Vite's\n// SSR `define` replacement runs one on every file mentioning a defined `process.env.*`) renames\n// the inner binding to `X2`, which would otherwise become this shape's IRI.\n@linkedShape({name: 'LincdWebApp'})\nexport class LincdWebApp extends Shape {\n static targetClass = lincdServer.LincdWebApp;\n\n static get localApp() {\n return new LincdWebApp({ id: process.env.SITE_ROOT });\n }\n\n // Module and packages properties removed — lincd-modules is in modules_old.\n // These will be re-added when the shape is properly migrated to @_linked/core query patterns.\n\n @objectProperty({\n path: lincdServer.hasAPI,\n shape: Lincd_API_Client,\n maxCount: 1,\n })\n get api(): Lincd_API_Client {\n return undefined as any;\n }\n}\n"]}
|
|
@@ -10,7 +10,12 @@ export declare class LinkedServer extends Shape {
|
|
|
10
10
|
private config;
|
|
11
11
|
private cachedPaths;
|
|
12
12
|
private assets;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Whether pages are served by the live Vite dev server rather than a
|
|
15
|
+
* `vite build` on disk. Decided once in `start()` — see
|
|
16
|
+
* utils/bootstrapEntry `resolveViteServingMode`.
|
|
17
|
+
*/
|
|
18
|
+
private viteDevServer;
|
|
14
19
|
/**
|
|
15
20
|
* Base URL every asset this build produced is served from — resolved once in
|
|
16
21
|
* `start()` and kept so per-request route chunks land on the same base as
|
|
@@ -116,6 +121,22 @@ export declare class LinkedServer extends Shape {
|
|
|
116
121
|
handleErrors(fn: any): (req: any, res: any, next: any) => Promise<any>;
|
|
117
122
|
handleErrorsJson(fn: any): (req: any, res: any, next: any) => Promise<any>;
|
|
118
123
|
sendError(res: any, statusCode: number, message: any, logMessage?: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* The stylesheets a dev (Vite) page render needs, inlined into
|
|
126
|
+
* `<style id="ssr-css">` so the first paint is styled before Vite's client
|
|
127
|
+
* injects the same CSS.
|
|
128
|
+
*
|
|
129
|
+
* Scoped to what the app module and the matched routes' pages import
|
|
130
|
+
* statically (see utils/ssrCss `ssrCssScope`). The dev server preloads every
|
|
131
|
+
* page into the module graph, so the whole graph is every page's CSS —
|
|
132
|
+
* megabytes per request in a large app. When the scope cannot be
|
|
133
|
+
* established (no routes config, a route rendered through a function, a
|
|
134
|
+
* module not found) it falls back to the whole graph.
|
|
135
|
+
*
|
|
136
|
+
* Ids are kept in the combined graph's order, so the cascade order of what
|
|
137
|
+
* remains is unchanged.
|
|
138
|
+
*/
|
|
139
|
+
private collectViteSsrCss;
|
|
119
140
|
render(req: any, res: any): Promise<void>;
|
|
120
141
|
sendJson(res: any, obj: any): void;
|
|
121
142
|
initRequest(request: any, response: any): Promise<void>;
|
|
@@ -47,8 +47,9 @@ import { CookieJar } from 'tough-cookie';
|
|
|
47
47
|
import { lincdServer } from '../ontologies/lincd-server.js';
|
|
48
48
|
import { linkedShape } from '../package.js';
|
|
49
49
|
import { resolveStaticAccessURL, staticAssetURL, } from '../utils/releaseManifest.js';
|
|
50
|
-
import {
|
|
50
|
+
import { resolveBootstrapEntry, resolveViteMainEntry, resolveViteServingMode, } from '../utils/bootstrapEntry.js';
|
|
51
51
|
import { resolveRouteAssets } from '../utils/routeAssets.js';
|
|
52
|
+
import { resolveRouteComponent, ssrCssInlineUrls, ssrCssScope, } from '../utils/ssrCss.js';
|
|
52
53
|
import { indexShapesIntoMemory } from '../utils/Shapes.js';
|
|
53
54
|
import { installSpaFallback, repinSpaFallback, } from '../utils/spaFallback.js';
|
|
54
55
|
import { LincdAPI } from './LincdAPI.js';
|
|
@@ -86,6 +87,9 @@ events.EventEmitter.prototype.setMaxListeners(500);
|
|
|
86
87
|
// global['document'] = document;
|
|
87
88
|
global['reactStaticRenderer'] = renderToStaticMarkup;
|
|
88
89
|
autoLoadOntologyData(true);
|
|
90
|
+
// Named explicitly: tsc emits `let X = class X`, and any later esbuild pass over that JS (Vite's
|
|
91
|
+
// SSR `define` replacement runs one on every file mentioning a defined `process.env.*`) renames
|
|
92
|
+
// the inner binding to `X2`, which would otherwise become this shape's IRI.
|
|
89
93
|
let LinkedServer = class LinkedServer extends Shape {
|
|
90
94
|
/**
|
|
91
95
|
* yarn linked start sends the contents of linked.config.js as an object to this constructor
|
|
@@ -96,7 +100,12 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
96
100
|
? config
|
|
97
101
|
: undefined);
|
|
98
102
|
this.cachedPaths = new Map();
|
|
99
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Whether pages are served by the live Vite dev server rather than a
|
|
105
|
+
* `vite build` on disk. Decided once in `start()` — see
|
|
106
|
+
* utils/bootstrapEntry `resolveViteServingMode`.
|
|
107
|
+
*/
|
|
108
|
+
this.viteDevServer = false;
|
|
100
109
|
/**
|
|
101
110
|
* Base URL every asset this build produced is served from — resolved once in
|
|
102
111
|
* `start()` and kept so per-request route chunks land on the same base as
|
|
@@ -235,7 +244,7 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
235
244
|
// })
|
|
236
245
|
// }
|
|
237
246
|
async start() {
|
|
238
|
-
var _a, _b, _c, _d
|
|
247
|
+
var _a, _b, _c, _d;
|
|
239
248
|
this.initPackage();
|
|
240
249
|
// Static assets should come from the static store URL (versioned path),
|
|
241
250
|
// not the upload store URL. An explicit STATIC_ACCESS_URL still wins;
|
|
@@ -260,36 +269,44 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
260
269
|
'main.js': staticAsset('/bundles/main.bundle.js') + '?v=' + this.package.version,
|
|
261
270
|
'main.css': staticAsset('/bundles/main.css'),
|
|
262
271
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
// Dev or built, decided once and reused by the render path — see
|
|
273
|
+
// utils/bootstrapEntry. In development the build manifest is not read:
|
|
274
|
+
// one left on disk by an earlier `vite build` would otherwise swap in
|
|
275
|
+
// stale built CSS while Vite serves the live styles.
|
|
276
|
+
const servingMode = resolveViteServingMode({
|
|
277
|
+
viteConfig: (_a = this.config.server) === null || _a === void 0 ? void 0 : _a.vite,
|
|
278
|
+
nodeEnv: process.env.NODE_ENV,
|
|
279
|
+
readManifest: () => {
|
|
280
|
+
try {
|
|
281
|
+
const viteManifestPath = path.resolve(process.cwd(), 'public/bundles/.vite/manifest.json');
|
|
282
|
+
if (!fsNative.existsSync(viteManifestPath))
|
|
283
|
+
return null;
|
|
284
|
+
return JSON.parse(fsNative.readFileSync(viteManifestPath, 'utf-8'));
|
|
275
285
|
}
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
catch (err) {
|
|
287
|
+
console.warn('Could not load bundle manifest:', err);
|
|
288
|
+
return null;
|
|
278
289
|
}
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
this.viteDevServer = servingMode.viteDevServer;
|
|
293
|
+
if (servingMode.manifest) {
|
|
294
|
+
const viteManifest = servingMode.manifest;
|
|
295
|
+
this.assets.manifest = viteManifest;
|
|
296
|
+
// Resolve main entry per Vite manifest shape:
|
|
297
|
+
// { "src/index.tsx": { file: "assets/main-<hash>.js", css: [...] } }
|
|
298
|
+
const mainEntry = resolveViteMainEntry(viteManifest);
|
|
299
|
+
if (mainEntry === null || mainEntry === void 0 ? void 0 : mainEntry.file) {
|
|
300
|
+
this.assets['main.js'] = staticAsset(`/bundles/${mainEntry.file}`);
|
|
301
|
+
this.mainEntryIsModule = true;
|
|
302
|
+
}
|
|
303
|
+
if ((_b = mainEntry === null || mainEntry === void 0 ? void 0 : mainEntry.css) === null || _b === void 0 ? void 0 : _b[0]) {
|
|
304
|
+
this.assets['main.css'] = staticAsset(`/bundles/${mainEntry.css[0]}`);
|
|
279
305
|
}
|
|
280
306
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// Vite dev marker: when Vite is in use AND no Vite manifest exists yet
|
|
285
|
-
// (= dev mode, no `vite build` run), the HTML renderer skips
|
|
286
|
-
// pre-built CSS/JS link tags. Vite handles asset injection itself.
|
|
287
|
-
// Same test as the entry bootstrap and the route preloads — see
|
|
288
|
-
// utils/bootstrapEntry.
|
|
289
|
-
if (isViteDevServer({
|
|
290
|
-
viteConfig: (_b = this.config.server) === null || _b === void 0 ? void 0 : _b.vite,
|
|
291
|
-
buildOutput: resolveViteMainEntry((_c = this.assets.manifest) !== null && _c !== void 0 ? _c : {}),
|
|
292
|
-
})) {
|
|
307
|
+
// Vite dev marker: the HTML renderer skips pre-built CSS/JS link tags,
|
|
308
|
+
// because Vite handles asset injection itself.
|
|
309
|
+
if (this.viteDevServer) {
|
|
293
310
|
this.assets['__viteDev'] = '1';
|
|
294
311
|
}
|
|
295
312
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
@@ -335,7 +352,7 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
335
352
|
// (`linked start --vite`), the orchestrator passes the Vite handle
|
|
336
353
|
// through config.server.viteMiddleware. We mount it and skip the
|
|
337
354
|
// entire webpack-dev-middleware setup below.
|
|
338
|
-
const viteMiddleware = (
|
|
355
|
+
const viteMiddleware = (_c = this.config.server) === null || _c === void 0 ? void 0 : _c.viteMiddleware;
|
|
339
356
|
if (viteMiddleware) {
|
|
340
357
|
this.server.use(viteMiddleware);
|
|
341
358
|
}
|
|
@@ -442,7 +459,7 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
442
459
|
// answering them with the client shell at status 200.
|
|
443
460
|
// An API-only backend (`linked start --api-only`) has no app to render:
|
|
444
461
|
// without the catch-all, page requests get express's plain 404.
|
|
445
|
-
if (!((
|
|
462
|
+
if (!((_d = this.config.server) === null || _d === void 0 ? void 0 : _d.apiOnly)) {
|
|
446
463
|
this.installSpaFallback();
|
|
447
464
|
}
|
|
448
465
|
//remove http(s):// and remove port :[port]
|
|
@@ -1306,8 +1323,78 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1306
1323
|
console.warn(chalk.red(logMessage || message));
|
|
1307
1324
|
}
|
|
1308
1325
|
}
|
|
1326
|
+
/**
|
|
1327
|
+
* The stylesheets a dev (Vite) page render needs, inlined into
|
|
1328
|
+
* `<style id="ssr-css">` so the first paint is styled before Vite's client
|
|
1329
|
+
* injects the same CSS.
|
|
1330
|
+
*
|
|
1331
|
+
* Scoped to what the app module and the matched routes' pages import
|
|
1332
|
+
* statically (see utils/ssrCss `ssrCssScope`). The dev server preloads every
|
|
1333
|
+
* page into the module graph, so the whole graph is every page's CSS —
|
|
1334
|
+
* megabytes per request in a large app. When the scope cannot be
|
|
1335
|
+
* established (no routes config, a route rendered through a function, a
|
|
1336
|
+
* module not found) it falls back to the whole graph.
|
|
1337
|
+
*
|
|
1338
|
+
* Ids are kept in the combined graph's order, so the cascade order of what
|
|
1339
|
+
* remains is unchanged.
|
|
1340
|
+
*/
|
|
1341
|
+
async collectViteSsrCss(vite, App, matchedRoutes) {
|
|
1342
|
+
var _a, _b, _c, _d;
|
|
1343
|
+
if (!((_a = vite === null || vite === void 0 ? void 0 : vite.moduleGraph) === null || _a === void 0 ? void 0 : _a.idToModuleMap))
|
|
1344
|
+
return '';
|
|
1345
|
+
// Note: Tailwind v4 `@theme` directives in app theme CSS files are
|
|
1346
|
+
// NOT processed at SSR collection time — the @tailwindcss/vite
|
|
1347
|
+
// plugin expands them at production build only. In dev mode, the
|
|
1348
|
+
// theme variables (—color-primary-*, etc.) are injected by Vite's
|
|
1349
|
+
// runtime AFTER client hydration, which causes a brief flash of
|
|
1350
|
+
// unthemed content (logos render black until ~hydration+200ms).
|
|
1351
|
+
// Production (vite build) is unaffected — the static main.css
|
|
1352
|
+
// contains expanded :root variables.
|
|
1353
|
+
let scope = null;
|
|
1354
|
+
const ssrGraph = (_c = (_b = vite.environments) === null || _b === void 0 ? void 0 : _b.ssr) === null || _c === void 0 ? void 0 : _c.moduleGraph;
|
|
1355
|
+
if ((ssrGraph === null || ssrGraph === void 0 ? void 0 : ssrGraph.idToModuleMap) && App && matchedRoutes) {
|
|
1356
|
+
const pages = [];
|
|
1357
|
+
let known = true;
|
|
1358
|
+
for (const route of matchedRoutes) {
|
|
1359
|
+
const component = await resolveRouteComponent(route);
|
|
1360
|
+
if (component === undefined) {
|
|
1361
|
+
known = false;
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
if (component !== null)
|
|
1365
|
+
pages.push(component);
|
|
1366
|
+
}
|
|
1367
|
+
if (known) {
|
|
1368
|
+
scope = ssrCssScope(ssrGraph.idToModuleMap.values(), {
|
|
1369
|
+
app: App,
|
|
1370
|
+
pages,
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
// Read only now: resolving a lazy route above can load its page, and the
|
|
1375
|
+
// combined graph's id map is a view built when it is read.
|
|
1376
|
+
const graphIds = [
|
|
1377
|
+
...vite.moduleGraph.idToModuleMap.keys(),
|
|
1378
|
+
];
|
|
1379
|
+
const ids = scope ? graphIds.filter((id) => scope.has(id)) : graphIds;
|
|
1380
|
+
// Only real stylesheets, once per file — see utils/ssrCss.
|
|
1381
|
+
const inlineUrls = ssrCssInlineUrls(ids, {
|
|
1382
|
+
publicDir: (_d = vite.config) === null || _d === void 0 ? void 0 : _d.publicDir,
|
|
1383
|
+
});
|
|
1384
|
+
const cssChunks = [];
|
|
1385
|
+
for (const inlineUrl of inlineUrls) {
|
|
1386
|
+
try {
|
|
1387
|
+
const cssModule = await vite.ssrLoadModule(inlineUrl);
|
|
1388
|
+
if (typeof (cssModule === null || cssModule === void 0 ? void 0 : cssModule.default) === 'string') {
|
|
1389
|
+
cssChunks.push(cssModule.default);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
catch ( /* skip */_e) { /* skip */ }
|
|
1393
|
+
}
|
|
1394
|
+
return cssChunks.join('\n');
|
|
1395
|
+
}
|
|
1309
1396
|
async render(req, res) {
|
|
1310
|
-
var _a, _b, _c, _d, _e, _f
|
|
1397
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1311
1398
|
res.socket.on('error', (error) => {
|
|
1312
1399
|
console.error('Fatal socket error', error);
|
|
1313
1400
|
});
|
|
@@ -1341,8 +1428,9 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1341
1428
|
// enter Vite's moduleGraph BEFORE we collect CSS. Without this,
|
|
1342
1429
|
// only App's eager imports are in the graph and lazy routes'
|
|
1343
1430
|
// CSS would be missing — page renders unstyled until hydration.
|
|
1344
|
-
// 2.
|
|
1345
|
-
//
|
|
1431
|
+
// 2. Once the route is matched, collect the CSS the app and that route's
|
|
1432
|
+
// page import (collectViteSsrCss), each loaded via `?inline` (Vite
|
|
1433
|
+
// returns the processed CSS as the default export).
|
|
1346
1434
|
// 3. Inject as inline <style> in HTML head (Html.tsx).
|
|
1347
1435
|
const vite = (_c = this.config.server) === null || _c === void 0 ? void 0 : _c.vite;
|
|
1348
1436
|
// Vite SSR module preload (plan-010 iter1 gap A):
|
|
@@ -1361,43 +1449,12 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1361
1449
|
try {
|
|
1362
1450
|
await vite.ssrLoadModule(p);
|
|
1363
1451
|
}
|
|
1364
|
-
catch ( /* skip — page may not exist or have ssr errors */
|
|
1452
|
+
catch ( /* skip — page may not exist or have ssr errors */_g) { /* skip — page may not exist or have ssr errors */ }
|
|
1365
1453
|
}
|
|
1366
1454
|
}
|
|
1367
|
-
catch ( /* ignore */
|
|
1455
|
+
catch ( /* ignore */_h) { /* ignore */ }
|
|
1368
1456
|
this._viteSsrPreloaded = true;
|
|
1369
1457
|
}
|
|
1370
|
-
let ssrCss = '';
|
|
1371
|
-
if ((_e = vite === null || vite === void 0 ? void 0 : vite.moduleGraph) === null || _e === void 0 ? void 0 : _e.idToModuleMap) {
|
|
1372
|
-
const cssChunks = [];
|
|
1373
|
-
const seen = new Set();
|
|
1374
|
-
// Walk the moduleGraph for CSS modules pulled in by app/pages.
|
|
1375
|
-
// Note: Tailwind v4 `@theme` directives in app theme CSS files are
|
|
1376
|
-
// NOT processed at SSR collection time — the @tailwindcss/vite
|
|
1377
|
-
// plugin expands them at production build only. In dev mode, the
|
|
1378
|
-
// theme variables (—color-primary-*, etc.) are injected by Vite's
|
|
1379
|
-
// runtime AFTER client hydration, which causes a brief flash of
|
|
1380
|
-
// unthemed content (logos render black until ~hydration+200ms).
|
|
1381
|
-
// Production (vite build) is unaffected — the static main.css
|
|
1382
|
-
// contains expanded :root variables.
|
|
1383
|
-
for (const [id] of vite.moduleGraph.idToModuleMap) {
|
|
1384
|
-
if (seen.has(id))
|
|
1385
|
-
continue;
|
|
1386
|
-
if (!/\.(module\.)?css(\?(?!.*inline)[^?]*)?$/.test(id))
|
|
1387
|
-
continue;
|
|
1388
|
-
seen.add(id);
|
|
1389
|
-
try {
|
|
1390
|
-
const inlineUrl = id + (id.includes('?') ? '&' : '?') + 'inline';
|
|
1391
|
-
const cssModule = await vite.ssrLoadModule(inlineUrl);
|
|
1392
|
-
if (typeof (cssModule === null || cssModule === void 0 ? void 0 : cssModule.default) === 'string') {
|
|
1393
|
-
cssChunks.push(cssModule.default);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
catch ( /* skip */_l) { /* skip */ }
|
|
1397
|
-
}
|
|
1398
|
-
ssrCss = cssChunks.join('\n');
|
|
1399
|
-
}
|
|
1400
|
-
this.assets['__viteSsrCss'] = ssrCss;
|
|
1401
1458
|
await this.initRequest(req, res);
|
|
1402
1459
|
let { requestLD, requestObject } = await this.getRequestData(req, res);
|
|
1403
1460
|
//on the backend we need to inform the hook of the request-data value
|
|
@@ -1418,28 +1475,32 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1418
1475
|
// }
|
|
1419
1476
|
// timedout = true;
|
|
1420
1477
|
// }, 8_000);
|
|
1421
|
-
let manifest = this.
|
|
1478
|
+
let manifest = this.assets.manifest || {};
|
|
1422
1479
|
let preloadScripts = [];
|
|
1423
1480
|
let preloadStyles = [];
|
|
1424
1481
|
let matchedRouteKey = null;
|
|
1482
|
+
// Null until the routes config has loaded: without it, what renders is unknown.
|
|
1483
|
+
let matchedRoutes = null;
|
|
1425
1484
|
// Plan-010 Vite dev mode: skip preload resolution entirely. Vite
|
|
1426
1485
|
// handles dynamic import() at runtime — there are no pre-built
|
|
1427
1486
|
// chunks to preload, and the webpack-shape fallback would pick up
|
|
1428
1487
|
// stale bundles on disk (public/bundles/*.bundle.js from a prior
|
|
1429
1488
|
// webpack build) and link them, breaking hydration.
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1489
|
+
// The same decision start() made for the `__viteDev` marker. This used
|
|
1490
|
+
// to be re-derived from `latestManifest`, which nothing ever set, so it
|
|
1491
|
+
// answered "dev" whenever Vite was attached — even when start() had
|
|
1492
|
+
// chosen the build — and the page mixed built CSS with the dev preamble.
|
|
1493
|
+
const usingViteDev = this.viteDevServer;
|
|
1434
1494
|
// Load routes config if available and extract preload chunks for the current route
|
|
1435
|
-
if ((
|
|
1495
|
+
if ((_e = this.config.server) === null || _e === void 0 ? void 0 : _e.loadRoutes) {
|
|
1436
1496
|
try {
|
|
1437
1497
|
const routesModule = await this.config.server.loadRoutes();
|
|
1438
1498
|
const ROUTES = routesModule.ROUTES ||
|
|
1439
|
-
((
|
|
1499
|
+
((_f = routesModule.default) === null || _f === void 0 ? void 0 : _f.ROUTES) ||
|
|
1440
1500
|
routesModule;
|
|
1441
1501
|
// Match the current request path to a route
|
|
1442
1502
|
let matchedRoute = null;
|
|
1503
|
+
const allMatches = [];
|
|
1443
1504
|
for (const [key, route] of Object.entries(ROUTES)) {
|
|
1444
1505
|
if (!(route === null || route === void 0 ? void 0 : route.path))
|
|
1445
1506
|
continue;
|
|
@@ -1448,11 +1509,17 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1448
1509
|
.replace(/\*/g, '.*');
|
|
1449
1510
|
const regex = new RegExp('^' + pathPattern + '$');
|
|
1450
1511
|
if (regex.test(req.path)) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1512
|
+
// Every match, not only the first: React Router may pick a more
|
|
1513
|
+
// specific route than this first-match loop, and the dev CSS
|
|
1514
|
+
// scope must cover whichever page actually renders.
|
|
1515
|
+
allMatches.push(route);
|
|
1516
|
+
if (!matchedRoute) {
|
|
1517
|
+
matchedRoute = route;
|
|
1518
|
+
matchedRouteKey = key;
|
|
1519
|
+
}
|
|
1454
1520
|
}
|
|
1455
1521
|
}
|
|
1522
|
+
matchedRoutes = allMatches;
|
|
1456
1523
|
// If we found a matching route with preloadChunks, resolve them to URLs (both JS and CSS).
|
|
1457
1524
|
// Manifest format detection: Vite manifest entries are objects with .file/.css; webpack
|
|
1458
1525
|
// manifest entries are bare strings. Try Vite shape first, fall back to webpack.
|
|
@@ -1475,9 +1542,22 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1475
1542
|
}
|
|
1476
1543
|
// Add matched route key to request object for Html component
|
|
1477
1544
|
req['matchedRouteKey'] = matchedRouteKey;
|
|
1545
|
+
const ssrCss = await this.collectViteSsrCss(vite, App, matchedRoutes);
|
|
1546
|
+
// Per request, and not enumerable: Html reads `assets.__viteSsrCss` for
|
|
1547
|
+
// the inline <style>, but also serialises the whole assets object into
|
|
1548
|
+
// `assetManifest` for the client, which never uses it. Enumerable, the
|
|
1549
|
+
// collected CSS — megabytes in a large app — went into every page twice.
|
|
1550
|
+
// A per-request copy also keeps one render's CSS out of another's.
|
|
1551
|
+
const assets = { ...this.assets };
|
|
1552
|
+
if (ssrCss) {
|
|
1553
|
+
Object.defineProperty(assets, '__viteSsrCss', {
|
|
1554
|
+
value: ssrCss,
|
|
1555
|
+
enumerable: false,
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1478
1558
|
stream = renderToPipeableStream(React.createElement(React.StrictMode, null,
|
|
1479
1559
|
React.createElement(StaticRouter, { location: req.url },
|
|
1480
|
-
React.createElement(AppContextProvider, { assets:
|
|
1560
|
+
React.createElement(AppContextProvider, { assets: assets, requestLD: requestLD, requestObject: requestObject, preloadScripts: preloadScripts, preloadStyles: preloadStyles, expressRequest: req, expressResponse: res },
|
|
1481
1561
|
React.createElement(App, null)))), {
|
|
1482
1562
|
// How the client entry boots — dev preamble, ES module, or classic
|
|
1483
1563
|
// script. See utils/bootstrapEntry.
|
|
@@ -1650,7 +1730,7 @@ let LinkedServer = class LinkedServer extends Shape {
|
|
|
1650
1730
|
*/
|
|
1651
1731
|
LinkedServer.targetClass = lincdServer.LincdServer;
|
|
1652
1732
|
LinkedServer = __decorate([
|
|
1653
|
-
linkedShape,
|
|
1733
|
+
linkedShape({ name: 'LinkedServer' }),
|
|
1654
1734
|
__metadata("design:paramtypes", [Object])
|
|
1655
1735
|
], LinkedServer);
|
|
1656
1736
|
export { LinkedServer };
|