@uniweb/kit 0.10.15 → 0.10.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/kit",
3
- "version": "0.10.15",
3
+ "version": "0.10.16",
4
4
  "description": "Standard component library for Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,6 +28,7 @@
28
28
  */
29
29
 
30
30
  import { emptyResult } from './providers/result.js'
31
+ import { resolveService } from '../utils/services.js'
31
32
 
32
33
  // Re-exported so existing importers of these keep working; they live with the
33
34
  // provider that owns them now.
@@ -92,7 +93,24 @@ export function createSearchClient(website, options = {}) {
92
93
  } = options
93
94
 
94
95
  const searchConfig = website.getSearchConfig?.() || {}
95
- const declared = providerOverride || searchConfig.provider || 'index'
96
+
97
+ // Where search is answered: the site's own `search.endpoint`, else the host's
98
+ // `services.search`, else nothing. Same rule every site service resolves by.
99
+ const service = resolveService(website, 'search')
100
+
101
+ // The AUTHORED provider, read from config rather than from getSearchConfig(),
102
+ // which fills in 'index' before kit sees it (core/website.js). That default
103
+ // would make "the author chose index" and "the author said nothing"
104
+ // indistinguishable — and the difference is precisely what decides whether a
105
+ // host's offer applies. An author who picked a provider means it; one who
106
+ // picked nothing gets whatever the host serves, and the local index if the
107
+ // host serves none.
108
+ const authoredProvider = website?.config?.search?.provider
109
+
110
+ const declared =
111
+ providerOverride ||
112
+ authoredProvider ||
113
+ (service.source === 'host' ? 'endpoint' : 'index')
96
114
 
97
115
  // One in-flight resolution shared by every caller.
98
116
  let providerPromise = null
@@ -115,7 +133,14 @@ export function createSearchClient(website, options = {}) {
115
133
  activeName = 'index'
116
134
  }
117
135
 
118
- return factory(website, { ...providerOptions, endpoint: searchConfig.endpoint })
136
+ // `service.url` is already joined to the base; the endpoint provider
137
+ // joins again, which is a no-op because the join is idempotent. Falls
138
+ // back to the raw authored value, and to the provider's own default when
139
+ // an author selects `endpoint` without naming one.
140
+ return factory(website, {
141
+ ...providerOptions,
142
+ endpoint: service.url || searchConfig.endpoint,
143
+ })
119
144
  })()
120
145
 
121
146
  return providerPromise