ubean 0.6.0 → 0.6.1-beta.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/dist/client.js CHANGED
@@ -1,734 +1,8 @@
1
1
  import { hydrateIslands as hydrateIslands$1 } from "@ubean/islands/runtime";
2
2
  import { islands } from "virtual:ubean-islands-registry";
3
3
  import { callAction, invokeServerFn, useAction, useFormAction } from "@ubean/routes/runtime";
4
- import { isRef, toValue } from "vue";
4
+ import { createServerHead } from "@ubean/client/server";
5
5
  export * from "@ubean/client";
6
- //#region ../../node_modules/.pnpm/unhead@3.4.2_@types+node@26.6.4_@vitejs+devtools@0.7.6_@devframes+json-render@1.2.0_@de_15009e0f764b121066881ba5914a1e8a/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs
7
- function registerPlugin(head, p) {
8
- if (typeof p === "function" && p.key && head.plugins.has(p.key)) return;
9
- const plugin = typeof p === "function" ? p(head) : p;
10
- const key = plugin.key || String(head.plugins.size + 1);
11
- if (!head.plugins.get(key)) {
12
- head.plugins.set(key, plugin);
13
- for (const k in plugin.hooks || {}) head.hooks?.hook(k, plugin.hooks[k]);
14
- }
15
- }
16
- // @__NO_SIDE_EFFECTS__
17
- function createUnhead(renderer, resolvedOptions = {}) {
18
- const ssr = !resolvedOptions.document;
19
- const entries = /* @__PURE__ */ new Map();
20
- const head = {
21
- _entryCount: 1,
22
- _h: 0,
23
- plugins: /* @__PURE__ */ new Map(),
24
- resolvedOptions,
25
- ssr,
26
- entries,
27
- hooks: void 0,
28
- render: () => renderer(head),
29
- use: (p) => registerPlugin(head, p),
30
- push(input, _options) {
31
- const _i = _options?._index ?? head._entryCount++;
32
- const options = _options ? { ..._options } : {};
33
- delete options.head;
34
- delete options.onRendered;
35
- delete options._index;
36
- const entry = {
37
- _i,
38
- input,
39
- options
40
- };
41
- entries.set(_i, entry);
42
- return {
43
- _i,
44
- dispose() {
45
- entries.delete(_i);
46
- },
47
- patch(input2) {
48
- if (ssr) {
49
- entry.input = input2;
50
- delete entry._tags;
51
- } else entry._pending = input2;
52
- if (!entries.has(_i)) entries.set(_i, entry);
53
- }
54
- };
55
- }
56
- };
57
- resolvedOptions.init?.forEach((e) => e && head.push(e));
58
- return head;
59
- }
60
- //#endregion
61
- //#region ../../node_modules/.pnpm/unhead@3.4.2_@types+node@26.6.4_@vitejs+devtools@0.7.6_@devframes+json-render@1.2.0_@de_15009e0f764b121066881ba5914a1e8a/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs
62
- const SelfClosingTags = /* @__PURE__ */ new Set([
63
- "meta",
64
- "link",
65
- "base"
66
- ]);
67
- const DupeableTags = /* @__PURE__ */ new Set([
68
- "link",
69
- "style",
70
- "script",
71
- "noscript"
72
- ]);
73
- const TagsWithInnerContent = /* @__PURE__ */ new Set([
74
- "title",
75
- "titleTemplate",
76
- "script",
77
- "style",
78
- "noscript"
79
- ]);
80
- const HasElementTags = /* @__PURE__ */ new Set([
81
- "base",
82
- "meta",
83
- "link",
84
- "style",
85
- "script",
86
- "noscript"
87
- ]);
88
- const ValidHeadTags = /* @__PURE__ */ new Set([
89
- "title",
90
- "base",
91
- "htmlAttrs",
92
- "bodyAttrs",
93
- "meta",
94
- "link",
95
- "style",
96
- "script",
97
- "noscript"
98
- ]);
99
- const UniqueTags = /* @__PURE__ */ new Set([
100
- "base",
101
- "title",
102
- "titleTemplate",
103
- "bodyAttrs",
104
- "htmlAttrs",
105
- "templateParams"
106
- ]);
107
- const TagConfigKeys = /* @__PURE__ */ new Set([
108
- "key",
109
- "tagPosition",
110
- "tagPriority",
111
- "tagDuplicateStrategy",
112
- "innerHTML",
113
- "textContent",
114
- "processTemplateParams"
115
- ]);
116
- const UsesMergeStrategy = /* @__PURE__ */ new Set([
117
- "templateParams",
118
- "htmlAttrs",
119
- "bodyAttrs"
120
- ]);
121
- const MetaTagsArrayable = /* @__PURE__ */ new Set([
122
- "theme-color",
123
- "google-site-verification",
124
- "author",
125
- "og:locale:alternate",
126
- "og:image",
127
- "og:video",
128
- "og:audio",
129
- "article:author",
130
- "article:tag",
131
- "book:author",
132
- "book:tag",
133
- "twitter:image"
134
- ]);
135
- const TagPriorityAliases = {
136
- critical: -8,
137
- high: -1,
138
- low: 2
139
- };
140
- const hasContent = (value) => typeof value === "number" ? Number.isFinite(value) : value;
141
- // @__NO_SIDE_EFFECTS__
142
- function isUnsafeKey(key) {
143
- return key === "__proto__" || key === "constructor" || key === "prototype";
144
- }
145
- //#endregion
146
- //#region ../../node_modules/.pnpm/hookable@6.1.2/node_modules/hookable/dist/index.mjs
147
- function callHooks(hooks, args, startIndex, task) {
148
- for (let i = startIndex; i < hooks.length; i += 1) try {
149
- const result = task ? task.run(() => hooks[i](...args)) : hooks[i](...args);
150
- if (result && typeof result.then === "function") return Promise.resolve(result).then(() => callHooks(hooks, args, i + 1, task));
151
- } catch (error) {
152
- return Promise.reject(error);
153
- }
154
- }
155
- var HookableCore = class {
156
- _hooks;
157
- constructor() {
158
- this._hooks = {};
159
- }
160
- hook(name, fn) {
161
- if (!name || typeof fn !== "function") return () => {};
162
- this._hooks[name] = this._hooks[name] || [];
163
- this._hooks[name].push(fn);
164
- return () => {
165
- if (fn) {
166
- this.removeHook(name, fn);
167
- fn = void 0;
168
- }
169
- };
170
- }
171
- removeHook(name, function_) {
172
- const hooks = this._hooks[name];
173
- if (hooks) {
174
- const index = hooks.indexOf(function_);
175
- if (index !== -1) hooks.splice(index, 1);
176
- if (hooks.length === 0) this._hooks[name] = void 0;
177
- }
178
- }
179
- callHook(name, ...args) {
180
- const hooks = this._hooks[name];
181
- if (!hooks || hooks.length === 0) return;
182
- return callHooks(hooks.slice(), args, 0);
183
- }
184
- };
185
- //#endregion
186
- //#region ../../node_modules/.pnpm/unhead@3.4.2_@types+node@26.6.4_@vitejs+devtools@0.7.6_@devframes+json-render@1.2.0_@de_15009e0f764b121066881ba5914a1e8a/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs
187
- function createHooks(hooks) {
188
- const instance = new HookableCore();
189
- for (const key in hooks || {}) instance.hook(key, hooks[key]);
190
- return instance;
191
- }
192
- function callHook(head, hook, ctx) {
193
- if (!(head.hooks?._hooks?.[hook])?.length) return;
194
- return head.hooks?.callHook(hook, ctx);
195
- }
196
- //#endregion
197
- //#region ../../node_modules/.pnpm/unhead@3.4.2_@types+node@26.6.4_@vitejs+devtools@0.7.6_@devframes+json-render@1.2.0_@de_15009e0f764b121066881ba5914a1e8a/node_modules/unhead/dist/shared/unhead.-hZVKou0.mjs
198
- const META_NOREWRITE_RE = /^(?:viewport|description|keywords|robots)$/;
199
- const META_KEY_ATTRS = [
200
- "name",
201
- "property",
202
- "http-equiv"
203
- ];
204
- function isMetaArrayDupeKey(v) {
205
- const i = v.indexOf(":");
206
- if (i === -1) return false;
207
- const key = v.slice(i + 1);
208
- return MetaTagsArrayable.has(key) || key.startsWith("og:image:") || key.startsWith("og:video:") || key.startsWith("og:audio:") || key.startsWith("twitter:image:");
209
- }
210
- function dedupeKey(tag) {
211
- const { props, tag: t, key } = tag;
212
- if (UniqueTags.has(t)) return t;
213
- if (t === "link") {
214
- if (props.rel === "canonical") return "canonical";
215
- if (props.rel === "alternate" && props.hreflang) return `alternate:${props.hreflang}`;
216
- }
217
- if (props.charset) return "charset";
218
- if (t === "meta") for (const n of META_KEY_ATTRS) {
219
- const v = props[n];
220
- if (v !== void 0) return `meta:${v}${(typeof v !== "string" || !v.includes(":")) && !META_NOREWRITE_RE.test(v) && key ? `:key:${key}` : ""}`;
221
- }
222
- if (key) return `${t}:key:${key}`;
223
- if (props.id) return `${t}:id:${props.id}`;
224
- if (t === "link" && props.rel && props.href) return `link:${props.rel}:${props.href}`;
225
- return TagsWithInnerContent.has(t) && (tag.textContent || tag.innerHTML) ? `${t}:content:${tag.textContent || tag.innerHTML}` : void 0;
226
- }
227
- function hashTag(tag) {
228
- const identity = tag._h || tag._d || tag.textContent || tag.innerHTML;
229
- if (identity) return identity;
230
- const keys = Object.keys(tag.props).sort();
231
- let hash = `${tag.tag}:`;
232
- let separator = "";
233
- for (const key of keys) {
234
- hash += `${separator}${key}:${String(tag.props[key])}`;
235
- separator = ",";
236
- }
237
- return hash;
238
- }
239
- function walkResolver(val, resolve, key) {
240
- if (key === "_resolver") return val;
241
- if (typeof val === "function" && (!key || key !== "titleTemplate" && !key.startsWith("on"))) val = val();
242
- const v = resolve ? resolve(key, val) : val;
243
- if (Array.isArray(v)) {
244
- let out;
245
- for (let i = 0; i < v.length; i++) {
246
- const r = walkResolver(v[i], resolve);
247
- if (out) out[i] = r;
248
- else if (r !== v[i]) {
249
- out = v.slice(0, i);
250
- out[i] = r;
251
- }
252
- }
253
- return out || v;
254
- }
255
- if (v?.constructor === Object) {
256
- let next;
257
- for (const k in v) {
258
- const unsafe = /* @__PURE__ */ isUnsafeKey(k);
259
- const r = unsafe ? void 0 : walkResolver(v[k], resolve, k);
260
- if (!next && (unsafe || r !== v[k])) {
261
- next = {};
262
- for (const pk in v) {
263
- if (pk === k) break;
264
- next[pk] = v[pk];
265
- }
266
- }
267
- if (next && !unsafe) next[k] = r;
268
- }
269
- return next || v;
270
- }
271
- return v;
272
- }
273
- const INVALID_ATTR_NAME_RE = /[\s"'<>/=\x00-\x1F\x7F]/;
274
- function normalizeStyleClassProps(key, value) {
275
- const isStyle = key === "style";
276
- const store = isStyle ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
277
- const add = (v) => {
278
- if (!v) return;
279
- if (isStyle) {
280
- const i = v.indexOf(":");
281
- i > 0 && store.set(v.slice(0, i).trim(), v.slice(i + 1).trim());
282
- } else v.split(" ").forEach((c) => c && store.add(c));
283
- };
284
- if (typeof value === "string") (isStyle ? value.split(";") : [value]).forEach(add);
285
- else if (Array.isArray(value)) value.forEach(add);
286
- else if (value && typeof value === "object") for (const k in value) {
287
- const v = value[k];
288
- v && v !== "false" && (isStyle ? store.set(k.trim(), String(v)) : add(k));
289
- }
290
- return store;
291
- }
292
- function normalizeProps(tag, input) {
293
- tag.props = tag.props || {};
294
- if (!input) return tag;
295
- if (tag.tag === "templateParams") {
296
- tag.props = input;
297
- return tag;
298
- }
299
- const isHtmlTag = HasElementTags.has(tag.tag) || tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs";
300
- for (const prop in input) {
301
- if (/* @__PURE__ */ isUnsafeKey(prop)) continue;
302
- const isData = prop.startsWith("data-");
303
- const isHtmlAttr = isHtmlTag && !TagConfigKeys.has(prop);
304
- const key = isHtmlAttr && !isData ? prop.toLowerCase() : prop;
305
- if (isHtmlAttr && (!key || INVALID_ATTR_NAME_RE.test(key))) continue;
306
- const value = input[prop];
307
- if (value === null) tag.props[key] = null;
308
- else if (prop === "class" || prop === "style") tag.props[prop] = normalizeStyleClassProps(prop, value);
309
- else if (TagConfigKeys.has(prop)) {
310
- if ((prop === "textContent" || prop === "innerHTML") && typeof value === "object") {
311
- const type = input.type || "application/json";
312
- if (type.endsWith("json") || type === "speculationrules" || type === "importmap") {
313
- tag.props.type = type;
314
- tag[prop] = JSON.stringify(value);
315
- }
316
- } else tag[prop] = value;
317
- } else if (value !== void 0) {
318
- const str = String(value);
319
- const isMeta = tag.tag === "meta" && key === "content";
320
- tag.props[key] = str === "true" || str === "" ? isData || isMeta ? str : true : !value && isData && str === "false" ? "false" : value;
321
- }
322
- }
323
- return tag;
324
- }
325
- function resolveHeadInput(input, propResolvers) {
326
- let resolve;
327
- if (propResolvers.length) {
328
- resolve = (key, val) => {
329
- for (let i = 0; i < propResolvers.length; i++) val = propResolvers[i](key, val);
330
- return val;
331
- };
332
- input = resolve(void 0, input);
333
- }
334
- return walkResolver(input, resolve);
335
- }
336
- function normalizeTag(tagName, _input) {
337
- const tag = normalizeProps({
338
- tag: tagName,
339
- props: {}
340
- }, typeof _input === "object" && typeof _input !== "function" ? _input : { [tagName === "script" || tagName === "noscript" || tagName === "style" ? "innerHTML" : "textContent"]: _input });
341
- if (tag.key && DupeableTags.has(tag.tag)) tag.props["data-hid"] = tag._h = tag.key;
342
- if (tag.tag === "script" && typeof tag.innerHTML === "object") {
343
- tag.innerHTML = JSON.stringify(tag.innerHTML);
344
- tag.props.type = tag.props.type || "application/json";
345
- }
346
- if (Array.isArray(tag.props.content)) {
347
- const tags = [];
348
- for (const content of tag.props.content) tags.push({
349
- ...tag,
350
- props: {
351
- ...tag.props,
352
- content
353
- }
354
- });
355
- return tags;
356
- }
357
- return tag;
358
- }
359
- function pushNormalizedTag(tags, tag) {
360
- if (Array.isArray(tag)) for (const t of tag) tags.push(t);
361
- else tags.push(tag);
362
- }
363
- function normalizeEntryToTags(input, propResolvers) {
364
- if (!input) return [];
365
- if (typeof input === "function") input = input();
366
- input = resolveHeadInput(input, propResolvers);
367
- const tags = [];
368
- for (const key in input) {
369
- const value = input[key];
370
- if (value !== void 0) {
371
- if (Array.isArray(value)) for (const v of value) pushNormalizedTag(tags, normalizeTag(key, v));
372
- else pushNormalizedTag(tags, normalizeTag(key, value));
373
- }
374
- }
375
- return tags;
376
- }
377
- const LT_RE = /</g;
378
- const SCRIPT_END_RE = /<\/script/g;
379
- const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
380
- const DEFAULT_TAG_WEIGHT = () => 100;
381
- function isEmptyProps(props) {
382
- for (const _ in props) return false;
383
- return true;
384
- }
385
- const TAG_MUTATING_HOOK_RE = /^tags:|:render/;
386
- function syncEntryHookCache(head, hooks) {
387
- const count = (hooks["entries:resolve"]?.length || 0) + (hooks["entries:normalize"]?.length || 0);
388
- if (head._h !== count) {
389
- head._h = count;
390
- for (const entry of head.entries.values()) delete entry._tags;
391
- }
392
- }
393
- function cloneTagsInPlace(tags) {
394
- for (let i = 0; i < tags.length; i++) {
395
- const t = tags[i];
396
- const props = { ...t.props };
397
- if (props.class instanceof Set) props.class = new Set(props.class);
398
- if (props.style instanceof Map) props.style = new Map(props.style);
399
- tags[i] = {
400
- ...t,
401
- props
402
- };
403
- }
404
- }
405
- function valuesToTags(ctx, sortFlatMeta) {
406
- const tags = ctx.tags;
407
- let w = 0;
408
- for (const value of ctx.tagMap.values()) if (Array.isArray(value)) for (const tag of value) tags[w++] = tag;
409
- else tags[w++] = value;
410
- tags.length = w;
411
- if (sortFlatMeta) tags.sort(sortTags);
412
- }
413
- function dedupeTags(ctx) {
414
- let hasFlatMeta = false;
415
- for (const next of ctx.tags.sort(sortTags)) {
416
- const k = next._d || hashTag(next);
417
- if (!k) continue;
418
- const prev = ctx.tagMap.get(k);
419
- if (!prev) {
420
- ctx.tagMap.set(k, next);
421
- continue;
422
- }
423
- if ((next.tagDuplicateStrategy || (UsesMergeStrategy.has(next.tag) ? "merge" : null) || (next.key && next.key === prev.key ? "merge" : null)) === "merge") {
424
- const props = { ...prev.props };
425
- for (const p in next.props) props[p] = p === "style" ? new Map([...prev.props.style || /* @__PURE__ */ new Map(), ...next.props[p]]) : p === "class" ? /* @__PURE__ */ new Set([...prev.props.class || [], ...next.props[p]]) : next.props[p];
426
- ctx.tagMap.set(k, {
427
- ...next,
428
- props
429
- });
430
- } else if (next._p >> 10 === prev._p >> 10 && next.tag === "meta" && isMetaArrayDupeKey(k)) {
431
- ctx.tagMap.set(k, Object.assign([...Array.isArray(prev) ? prev : [prev], next], next));
432
- hasFlatMeta = true;
433
- } else if (next._w === prev._w ? next._p > prev._p : next._w < prev._w) ctx.tagMap.set(k, next);
434
- }
435
- return hasFlatMeta;
436
- }
437
- function resolveTitleTemplate(ctx, head) {
438
- const title = ctx.tagMap.get("title");
439
- const tpl = ctx.tagMap.get("titleTemplate");
440
- head._title = title?.textContent;
441
- if (!tpl) return;
442
- const fn = tpl.textContent;
443
- head._titleTemplate = fn;
444
- if (!fn) return;
445
- let v = typeof fn === "function" ? fn(title?.textContent) : fn;
446
- if (typeof v === "string" && !head.plugins.has("template-params")) v = v.replace("%s", title?.textContent || "");
447
- if (title) v === null ? ctx.tagMap.delete("title") : ctx.tagMap.set("title", {
448
- ...title,
449
- textContent: v
450
- });
451
- else ctx.tagMap.set("titleTemplate", {
452
- ...tpl,
453
- tag: "title",
454
- textContent: v
455
- });
456
- }
457
- function sanitizeTagsInPlace(tags) {
458
- let w = 0;
459
- for (let t of tags) {
460
- const { innerHTML, tag, props } = t;
461
- if (!ValidHeadTags.has(tag) || isEmptyProps(props) && !hasContent(innerHTML) && !hasContent(t.textContent)) continue;
462
- if (tag === "meta") {
463
- if (!hasContent(props.content) && !props["http-equiv"] && !props.charset) continue;
464
- }
465
- if (tag === "script" && (innerHTML || t.textContent)) {
466
- const type = String(props.type);
467
- const isJsonLike = type.endsWith("json") || type === "importmap" || type === "speculationrules";
468
- const escape = (content) => isJsonLike ? (typeof content === "string" ? content : JSON.stringify(content)).replace(LT_RE, "\\u003C") : typeof content === "string" ? content.replace(SCRIPT_END_RE, "<\\/script") : content;
469
- t = { ...t };
470
- if (innerHTML) t.innerHTML = escape(innerHTML);
471
- if (t.textContent) t.textContent = escape(t.textContent);
472
- t._d = dedupeKey(t);
473
- }
474
- tags[w++] = t;
475
- }
476
- tags.length = w;
477
- return tags;
478
- }
479
- function resolveTags(head, options) {
480
- const weightFn = options?.tagWeight ?? head.resolvedOptions._tagWeight ?? DEFAULT_TAG_WEIGHT;
481
- const ctx = {
482
- tagMap: /* @__PURE__ */ new Map(),
483
- tags: []
484
- };
485
- const hooks = head.hooks?._hooks || {};
486
- syncEntryHookCache(head, hooks);
487
- for (const e of head.entries.values()) if (e._pending !== void 0) {
488
- e.input = e._pending;
489
- delete e._pending;
490
- delete e._tags;
491
- delete e._precomputedTags;
492
- }
493
- let entries;
494
- if (hooks["entries:resolve"]?.length || hooks["entries:normalize"]?.length) {
495
- entries = [...head.entries.values()];
496
- if (hooks["entries:resolve"]?.length) callHook(head, "entries:resolve", {
497
- entries,
498
- ...ctx
499
- });
500
- }
501
- syncEntryHookCache(head, hooks);
502
- for (const e of entries || head.entries.values()) {
503
- let tags = e._tags;
504
- if (!tags) {
505
- if (e._precomputedTags && weightFn === head.resolvedOptions._tagWeight && !hooks["entries:normalize"]?.length && !hooks["entries:resolve"]?.length && (!e.options || isEmptyProps(e.options))) tags = e._precomputedTags;
506
- else {
507
- tags = normalizeEntryToTags(e.input, head.resolvedOptions.propResolvers || []);
508
- if (e.options && !isEmptyProps(e.options)) for (const t of tags) Object.assign(t, e.options);
509
- if (hooks["entries:normalize"]?.length) {
510
- const normalizeCtx = {
511
- tags,
512
- entry: e
513
- };
514
- callHook(head, "entries:normalize", normalizeCtx);
515
- tags = normalizeCtx.tags;
516
- }
517
- for (let i = 0; i < tags.length; i++) {
518
- const t = tags[i];
519
- t._w = weightFn(t);
520
- t._p = (e._i << 10) + i;
521
- t._d = dedupeKey(t);
522
- if (!t._d) t._h = hashTag(t);
523
- }
524
- e._tags = tags;
525
- }
526
- }
527
- ctx.tags.push(...tags);
528
- }
529
- for (const name in hooks) if (hooks[name]?.length && TAG_MUTATING_HOOK_RE.test(name)) {
530
- cloneTagsInPlace(ctx.tags);
531
- break;
532
- }
533
- const hasFlatMeta = dedupeTags(ctx);
534
- resolveTitleTemplate(ctx, head);
535
- valuesToTags(ctx, hasFlatMeta);
536
- callHook(head, "tags:beforeResolve", ctx);
537
- callHook(head, "tags:resolve", ctx);
538
- callHook(head, "tags:afterResolve", ctx);
539
- return sanitizeTagsInPlace(ctx.tags);
540
- }
541
- //#endregion
542
- //#region ../../node_modules/.pnpm/unhead@3.4.2_@types+node@26.6.4_@vitejs+devtools@0.7.6_@devframes+json-render@1.2.0_@de_15009e0f764b121066881ba5914a1e8a/node_modules/unhead/dist/shared/unhead.Dssd7L5I.mjs
543
- const isTruthy = (v) => v === "" || v === true;
544
- function capoTagWeight(tag) {
545
- if (typeof tag.tagPriority === "number") return tag.tagPriority;
546
- let weight = 100;
547
- const offset = TagPriorityAliases[tag.tagPriority] || 0;
548
- if (tag.tag === "base") weight = -10;
549
- else if (tag.tag === "title") weight = 10;
550
- else if (tag.tag === "meta") weight = tag.props["http-equiv"] === "content-security-policy" ? -30 : tag.props.charset ? -20 : tag.props.name === "viewport" ? -15 : weight;
551
- else if (tag.tag === "link" && tag.props.rel) {
552
- const rel = tag.props.rel;
553
- weight = rel === "preconnect" ? 20 : rel === "stylesheet" ? 60 : rel === "preload" || rel === "modulepreload" ? 70 : rel === "prefetch" || rel === "dns-prefetch" || rel === "prerender" ? 90 : weight;
554
- } else if (tag.tag === "script") {
555
- const type = typeof tag.props.type === "string" ? tag.props.type : "";
556
- const json = type.endsWith("json");
557
- if (type === "importmap") weight = 25;
558
- else if (type === "speculationrules") weight = 90;
559
- else if (isTruthy(tag.props.async)) weight = 30;
560
- else if (tag.props.src && !isTruthy(tag.props.defer) && type !== "module" && !json || (tag.innerHTML || tag.textContent) && !json) weight = 50;
561
- else if (isTruthy(tag.props.defer) && tag.props.src || type === "module") weight = 80;
562
- } else if (tag.tag === "style") weight = tag.innerHTML && /@import/.test(tag.innerHTML) ? 40 : 60;
563
- return (weight || 100) + offset;
564
- }
565
- const DOUBLE_QUOTE_RE = /"/g;
566
- function encodeAttribute(value) {
567
- const s = typeof value === "string" ? value : String(value);
568
- return s.includes("\"") ? s.replace(DOUBLE_QUOTE_RE, "&quot;") : s;
569
- }
570
- function propsToString(props) {
571
- let attrs = "";
572
- for (const key in props) {
573
- if (!Object.hasOwn(props, key) || !key || INVALID_ATTR_NAME_RE.test(key)) continue;
574
- let value = props[key];
575
- if (typeof value !== "string") {
576
- if (key === "class") {
577
- let out = "";
578
- for (const c of value) out += out ? ` ${c}` : c;
579
- value = out;
580
- } else if (key === "style") {
581
- let out = "";
582
- for (const [k, v] of value) out += out ? `;${k}:${v}` : `${k}:${v}`;
583
- value = out;
584
- }
585
- }
586
- if (value !== false && value !== null) attrs += value === true ? ` ${key}` : ` ${key}="${encodeAttribute(value)}"`;
587
- }
588
- return attrs;
589
- }
590
- const ESCAPE_HTML_RE = /[&<>"'/]/g;
591
- const CLOSE_TAG_RE = {};
592
- const ESCAPE_HTML_MAP = {
593
- "&": "&amp;",
594
- "<": "&lt;",
595
- ">": "&gt;",
596
- "\"": "&quot;",
597
- "'": "&#x27;",
598
- "/": "&#x2F;"
599
- };
600
- function escapeHtml(str) {
601
- return str.replace(ESCAPE_HTML_RE, (c) => ESCAPE_HTML_MAP[c]);
602
- }
603
- function tagToString(tag) {
604
- const attrs = propsToString(tag.props);
605
- const openTag = `<${tag.tag}${attrs}>`;
606
- if (SelfClosingTags.has(tag.tag)) return openTag;
607
- if (!TagsWithInnerContent.has(tag.tag)) return `${openTag}</${tag.tag}>`;
608
- let content = String(tag.textContent ?? tag.innerHTML ?? "");
609
- content = tag.tag === "title" ? escapeHtml(content) : content.replace(CLOSE_TAG_RE[tag.tag] ||= new RegExp(`</${tag.tag}`, "gi"), `<\\/${tag.tag}`);
610
- return `${openTag}${content}</${tag.tag}>`;
611
- }
612
- function ssrRenderTags(tags, options) {
613
- const schema = {
614
- htmlAttrs: {},
615
- bodyAttrs: {},
616
- tags: {
617
- head: "",
618
- bodyClose: "",
619
- bodyOpen: ""
620
- }
621
- };
622
- const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
623
- for (const tag of tags) {
624
- if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
625
- Object.assign(schema[tag.tag], tag.props);
626
- continue;
627
- }
628
- const s = tagToString(tag);
629
- const tagPosition = tag.tagPosition || "head";
630
- schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
631
- }
632
- return {
633
- headTags: schema.tags.head,
634
- bodyTags: schema.tags.bodyClose,
635
- bodyTagsOpen: schema.tags.bodyOpen,
636
- htmlAttrs: propsToString(schema.htmlAttrs),
637
- bodyAttrs: propsToString(schema.bodyAttrs)
638
- };
639
- }
640
- // @__NO_SIDE_EFFECTS__
641
- function createServerRenderer(options = {}) {
642
- return (head) => {
643
- const beforeRenderCtx = { shouldRender: true };
644
- callHook(head, "ssr:beforeRender", beforeRenderCtx);
645
- if (!beforeRenderCtx.shouldRender) return ssrRenderTags([]);
646
- const ctx = {
647
- tags: options.resolvedTags || resolveTags(head, { tagWeight: options.tagWeight ?? capoTagWeight }),
648
- options: { ...options }
649
- };
650
- callHook(head, "ssr:render", ctx);
651
- const html = ssrRenderTags(ctx.tags, ctx.options);
652
- const renderCtx = {
653
- tags: ctx.tags,
654
- html
655
- };
656
- callHook(head, "ssr:rendered", renderCtx);
657
- return renderCtx.html;
658
- };
659
- }
660
- const DEFAULT_INIT = {
661
- htmlAttrs: { lang: "en" },
662
- meta: [{ charset: "utf-8" }, {
663
- name: "viewport",
664
- content: "width=device-width, initial-scale=1"
665
- }]
666
- };
667
- const serverPropResolver = /* @__PURE__ */ Object.assign((k, v) => {
668
- if (k && k.startsWith("on") && typeof v === "function") return `this.dataset.${k}fired = true`;
669
- return v;
670
- }, { _static: true });
671
- let defaultInitTags;
672
- function getDefaultInitTags() {
673
- if (!defaultInitTags) {
674
- defaultInitTags = normalizeEntryToTags(DEFAULT_INIT, []);
675
- for (let i = 0; i < defaultInitTags.length; i++) {
676
- const t = defaultInitTags[i];
677
- t._w = capoTagWeight(t);
678
- t._p = 1024 + i;
679
- t._d = dedupeKey(t);
680
- if (!t._d) t._h = hashTag(t);
681
- }
682
- }
683
- return defaultInitTags;
684
- }
685
- // @__NO_SIDE_EFFECTS__
686
- function createHead$1(options = {}) {
687
- const tagWeight = options.tagWeight || capoTagWeight;
688
- const core = /* @__PURE__ */ createUnhead(/* @__PURE__ */ createServerRenderer({
689
- tagWeight,
690
- omitLineBreaks: options.omitLineBreaks
691
- }), {
692
- _tagWeight: tagWeight,
693
- document: false,
694
- experimentalStreamKey: options.experimentalStreamKey,
695
- propResolvers: [...options.propResolvers || [], serverPropResolver],
696
- init: [options.disableDefaults ? void 0 : DEFAULT_INIT, ...options.init || []]
697
- });
698
- if (!options.disableDefaults && !options.tagWeight && !options.propResolvers?.some((r) => !r._static)) {
699
- const defaultEntry = core.entries.get(1);
700
- if (defaultEntry) defaultEntry._precomputedTags = getDefaultInitTags();
701
- }
702
- core.hooks = createHooks(options.hooks);
703
- options.plugins?.forEach((p) => core.use(p));
704
- return core;
705
- }
706
- //#endregion
707
- //#region ../../node_modules/.pnpm/@unhead+vue@3.4.2_@oxc-project+types@0.151.0_@types+node@26.6.4_@vitejs+devtools@0.7.6__b0e8f87cbcef34ce77ed0bd56756a679/node_modules/@unhead/vue/dist/shared/vue.DKb5ZKVl.mjs
708
- const headSymbol = "usehead";
709
- // @__NO_SIDE_EFFECTS__
710
- function vueInstall(head) {
711
- return { install(app) {
712
- app.config.globalProperties.$unhead = head;
713
- app.config.globalProperties.$head = head;
714
- app.provide(headSymbol, head);
715
- } }.install;
716
- }
717
- //#endregion
718
- //#region ../../node_modules/.pnpm/@unhead+vue@3.4.2_@oxc-project+types@0.151.0_@types+node@26.6.4_@vitejs+devtools@0.7.6__b0e8f87cbcef34ce77ed0bd56756a679/node_modules/@unhead/vue/dist/shared/vue.D2XR8FqS.mjs
719
- const VueResolver = /* @__PURE__ */ Object.assign((_, value) => isRef(value) ? toValue(value) : value, { _static: true });
720
- //#endregion
721
- //#region ../../node_modules/.pnpm/@unhead+vue@3.4.2_@oxc-project+types@0.151.0_@types+node@26.6.4_@vitejs+devtools@0.7.6__b0e8f87cbcef34ce77ed0bd56756a679/node_modules/@unhead/vue/dist/server.mjs
722
- // @__NO_SIDE_EFFECTS__
723
- function createHead(options = {}) {
724
- const head = /* @__PURE__ */ createHead$1({
725
- ...options,
726
- propResolvers: [VueResolver]
727
- });
728
- head.install = /* @__PURE__ */ vueInstall(head);
729
- return head;
730
- }
731
- //#endregion
732
6
  //#region src/client.ts
733
7
  /**
734
8
  * `hydrateIslands` 的桥接版本:自动合并虚拟注册表与手动 `components`。
@@ -747,4 +21,4 @@ function hydrateIslands(options = {}) {
747
21
  });
748
22
  }
749
23
  //#endregion
750
- export { callAction, createHead as createServerHead, hydrateIslands, invokeServerFn, useAction, useFormAction };
24
+ export { callAction, createServerHead, hydrateIslands, invokeServerFn, useAction, useFormAction };