@uniweb/runtime 0.13.6 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/default-fetcher.js +22 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"node": ">=20.19"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@uniweb/core": "^0.
|
|
39
|
+
"@uniweb/core": "^0.19.0",
|
|
40
40
|
"@uniweb/theming": "^0.1.15"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"esbuild": "^0.21.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.27.0",
|
|
45
45
|
"vite": "^7.3.1",
|
|
46
46
|
"vitest": "^4.1.7",
|
|
47
|
-
"@uniweb/build": "0.
|
|
47
|
+
"@uniweb/build": "0.35.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": "^19.0.0",
|
package/src/default-fetcher.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* X-Tenant: acme
|
|
17
17
|
* Accept: application/vnd.example+json
|
|
18
18
|
* envelope:
|
|
19
|
-
*
|
|
19
|
+
* list: data.items
|
|
20
20
|
* item: data.article
|
|
21
21
|
* error: errors.0.message
|
|
22
22
|
*
|
|
@@ -64,10 +64,11 @@ import {
|
|
|
64
64
|
resolveServiceUrl,
|
|
65
65
|
} from '@uniweb/core'
|
|
66
66
|
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
67
|
+
// The request style is the wire dialect operators are encoded in. One
|
|
68
|
+
// ships — json-body, the framework's own — and `resolveRequestStyle` is
|
|
69
|
+
// loud on any other name: it throws in dev and logs once in production.
|
|
70
|
+
// Another dialect is a named transport, from the foundation or from an
|
|
71
|
+
// extension the site selects; it is never a second built-in style.
|
|
71
72
|
|
|
72
73
|
// Operators the default fetcher knows how to handle. When listed in
|
|
73
74
|
// `config.supports`, they're shipped to the source as part of the
|
|
@@ -86,8 +87,9 @@ const KNOWN_OPERATORS = new Set(['where', 'limit', 'sort'])
|
|
|
86
87
|
* `request.rename`. Unknown keys are ignored (foundations may use the
|
|
87
88
|
* same block for their own keys). Default behavior (empty config)
|
|
88
89
|
* matches today's plain GET + JSON.
|
|
89
|
-
* @param {boolean} [options.dev=false] - Enable dev-mode
|
|
90
|
-
* style
|
|
90
|
+
* @param {boolean} [options.dev=false] - Enable dev-mode diagnostics: an
|
|
91
|
+
* unknown request style throws; a rename entry for an operator the wire
|
|
92
|
+
* does not carry warns.
|
|
91
93
|
* @returns {{ resolve: (req: Object, ctx: Object) => Promise<{ data, error? }> }}
|
|
92
94
|
*/
|
|
93
95
|
export function createDefaultFetcher({ basePath = '', config = {}, dev = false } = {}) {
|
|
@@ -108,9 +110,10 @@ export function createDefaultFetcher({ basePath = '', config = {}, dev = false }
|
|
|
108
110
|
// default fetcher serving static files supports nothing natively.
|
|
109
111
|
const supports = normalizeSupports(config?.supports)
|
|
110
112
|
|
|
111
|
-
// Request style —
|
|
112
|
-
//
|
|
113
|
-
// to the
|
|
113
|
+
// Request style — the wire dialect operators are encoded in. Read from
|
|
114
|
+
// `site.yml fetcher.request.style`; `null`/absent and `json-body` both
|
|
115
|
+
// resolve to the one shipped style, and any other name is loud (see
|
|
116
|
+
// `resolveRequestStyle`).
|
|
114
117
|
const requestConfig = (config?.request && typeof config.request === 'object') ? config.request : {}
|
|
115
118
|
const styleName = typeof requestConfig.style === 'string' ? requestConfig.style : null
|
|
116
119
|
const style = resolveRequestStyle(styleName, { dev })
|
|
@@ -129,9 +132,9 @@ export function createDefaultFetcher({ basePath = '', config = {}, dev = false }
|
|
|
129
132
|
// - envelope.error — extract error text from non-2xx response body.
|
|
130
133
|
//
|
|
131
134
|
// Priority (highest wins): per-fetch request.envelope > site-level
|
|
132
|
-
// config.envelope > style.defaultEnvelope.
|
|
133
|
-
// envelope
|
|
134
|
-
//
|
|
135
|
+
// config.envelope > style.defaultEnvelope. json-body declares no
|
|
136
|
+
// envelope; the slot is the encoder's to fill, and a site-level value
|
|
137
|
+
// always wins over it.
|
|
135
138
|
const siteEnvelope = (config?.envelope && typeof config.envelope === 'object')
|
|
136
139
|
? config.envelope
|
|
137
140
|
: null
|
|
@@ -155,9 +158,8 @@ export function createDefaultFetcher({ basePath = '', config = {}, dev = false }
|
|
|
155
158
|
// style will actually push for this request. deriveCacheKey already
|
|
156
159
|
// covers the always-keyed fields.
|
|
157
160
|
//
|
|
158
|
-
// The key also
|
|
159
|
-
//
|
|
160
|
-
// their responses must not alias.
|
|
161
|
+
// The key also carries the style name. With one shipped style it is
|
|
162
|
+
// a constant segment, kept so that key shapes do not move.
|
|
161
163
|
const base = deriveCacheKey(request)
|
|
162
164
|
const projected = {}
|
|
163
165
|
for (const op of supports) {
|
|
@@ -230,10 +232,10 @@ export function createDefaultFetcher({ basePath = '', config = {}, dev = false }
|
|
|
230
232
|
// style didn't push get applied as a JS fallback after the response
|
|
231
233
|
// (see the post-fetch block below).
|
|
232
234
|
//
|
|
233
|
-
// The style owns the wire format
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
235
|
+
// The style owns the wire format: json-body encodes GET pushdown as
|
|
236
|
+
// `?_where=<JSON>&_limit=&_sort=` and POST pushdown as top-level keys
|
|
237
|
+
// merged into an object body. It is the only shipped wire — another
|
|
238
|
+
// dialect is a named transport.
|
|
237
239
|
const pushCandidates = new Set()
|
|
238
240
|
if (isRemote) {
|
|
239
241
|
for (const op of KNOWN_OPERATORS) {
|