unhead 2.0.0-alpha.0 → 2.0.0-alpha.10
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/README.md +13 -0
- package/dist/client.d.mts +7 -18
- package/dist/client.d.ts +7 -18
- package/dist/client.mjs +208 -16
- package/dist/index.d.mts +12 -21
- package/dist/index.d.ts +12 -21
- package/dist/index.mjs +6 -65
- package/dist/legacy.d.mts +14 -12
- package/dist/legacy.d.ts +14 -12
- package/dist/legacy.mjs +42 -73
- package/dist/plugins.d.mts +36 -18
- package/dist/plugins.d.ts +36 -18
- package/dist/plugins.mjs +79 -73
- package/dist/server.d.mts +12 -5
- package/dist/server.d.ts +12 -5
- package/dist/server.mjs +117 -17
- package/dist/shared/unhead.BX2ITVEM.mjs +107 -0
- package/dist/shared/unhead.BfOKU5JT.mjs +154 -0
- package/dist/shared/unhead.CGUU1vXi.mjs +177 -0
- package/dist/shared/unhead.Cixots_n.mjs +48 -0
- package/dist/shared/unhead.Cktr7sRK.mjs +144 -0
- package/dist/shared/unhead.CnmTxLaQ.d.mts +2201 -0
- package/dist/shared/unhead.CnmTxLaQ.d.ts +2201 -0
- package/dist/shared/unhead.CnyuWd5e.mjs +201 -0
- package/dist/shared/unhead.DgyS1B7b.mjs +21 -0
- package/dist/shared/unhead.Mt30Mzm-.mjs +144 -0
- package/dist/types.d.mts +27 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.mjs +1 -0
- package/dist/utils.d.mts +37 -0
- package/dist/utils.d.ts +37 -0
- package/dist/utils.mjs +4 -0
- package/package.json +33 -15
- package/types.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/dist/client.cjs +0 -29
- package/dist/client.d.cts +0 -25
- package/dist/index.cjs +0 -77
- package/dist/index.d.cts +0 -24
- package/dist/legacy.cjs +0 -316
- package/dist/legacy.d.cts +0 -107
- package/dist/plugins.cjs +0 -96
- package/dist/plugins.d.cts +0 -41
- package/dist/server.cjs +0 -119
- package/dist/server.d.cts +0 -22
- package/dist/shared/unhead.9459P6Us.mjs +0 -216
- package/dist/shared/unhead.B1vp-BN3.cjs +0 -63
- package/dist/shared/unhead.Bkkr-JOb.d.cts +0 -38
- package/dist/shared/unhead.Bkkr-JOb.d.mts +0 -38
- package/dist/shared/unhead.Bkkr-JOb.d.ts +0 -38
- package/dist/shared/unhead.BxCMBVrg.mjs +0 -15
- package/dist/shared/unhead.C1knnawv.cjs +0 -246
- package/dist/shared/unhead.CU1QS7En.cjs +0 -96
- package/dist/shared/unhead.DGQq1RAN.cjs +0 -58
- package/dist/shared/unhead.DJ2B9fZW.mjs +0 -94
- package/dist/shared/unhead.DTD44cG0.cjs +0 -19
- package/dist/shared/unhead.DbMOoWpX.cjs +0 -222
- package/dist/shared/unhead.Dk9EcP_t.mjs +0 -60
- package/dist/shared/unhead.YfQbj2z7.mjs +0 -55
- package/dist/shared/unhead.ovi5lkPs.mjs +0 -241
package/README.md
ADDED
package/dist/client.d.mts
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Head, CreateClientHeadOptions, Unhead,
|
|
1
|
+
import * as unhead_types from 'unhead/types';
|
|
2
|
+
import { a as Head, b as CreateClientHeadOptions, U as Unhead, R as RenderDomHeadOptions } from './shared/unhead.CnmTxLaQ.mjs';
|
|
3
|
+
import 'hookable';
|
|
3
4
|
|
|
4
|
-
declare function createHead<T extends Record<string, any> = Head>(options?: CreateClientHeadOptions):
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Queue a debounced update of the DOM head.
|
|
8
|
-
*/
|
|
9
|
-
declare function debouncedRenderDOMHead<T extends Unhead<any>>(head: T, options?: DomPluginOptions): Promise<void>;
|
|
10
|
-
|
|
11
|
-
declare function DomPlugin(options?: DomPluginOptions): _unhead_schema.HeadPluginInput;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Supports DOM event handlers (i.e `onload`) as functions.
|
|
15
|
-
*
|
|
16
|
-
* When SSR we need to strip out these values. On CSR we
|
|
17
|
-
*/
|
|
18
|
-
declare const ClientEventHandlerPlugin: _unhead_schema.HeadPluginInput;
|
|
5
|
+
declare function createHead<T extends Record<string, any> = Head>(options?: CreateClientHeadOptions): unhead_types.Unhead<T>;
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* Render the head tags to the DOM.
|
|
22
9
|
*/
|
|
23
10
|
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
|
24
11
|
|
|
25
|
-
|
|
12
|
+
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
13
|
+
|
|
14
|
+
export { createDebouncedFn, createHead, renderDOMHead };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Head, CreateClientHeadOptions, Unhead,
|
|
1
|
+
import * as unhead_types from 'unhead/types';
|
|
2
|
+
import { a as Head, b as CreateClientHeadOptions, U as Unhead, R as RenderDomHeadOptions } from './shared/unhead.CnmTxLaQ.js';
|
|
3
|
+
import 'hookable';
|
|
3
4
|
|
|
4
|
-
declare function createHead<T extends Record<string, any> = Head>(options?: CreateClientHeadOptions):
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Queue a debounced update of the DOM head.
|
|
8
|
-
*/
|
|
9
|
-
declare function debouncedRenderDOMHead<T extends Unhead<any>>(head: T, options?: DomPluginOptions): Promise<void>;
|
|
10
|
-
|
|
11
|
-
declare function DomPlugin(options?: DomPluginOptions): _unhead_schema.HeadPluginInput;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Supports DOM event handlers (i.e `onload`) as functions.
|
|
15
|
-
*
|
|
16
|
-
* When SSR we need to strip out these values. On CSR we
|
|
17
|
-
*/
|
|
18
|
-
declare const ClientEventHandlerPlugin: _unhead_schema.HeadPluginInput;
|
|
5
|
+
declare function createHead<T extends Record<string, any> = Head>(options?: CreateClientHeadOptions): unhead_types.Unhead<T>;
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* Render the head tags to the DOM.
|
|
22
9
|
*/
|
|
23
10
|
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
|
24
11
|
|
|
25
|
-
|
|
12
|
+
declare function createDebouncedFn(callee: () => void, delayer: (fn: () => void) => void): () => void;
|
|
13
|
+
|
|
14
|
+
export { createDebouncedFn, createHead, renderDOMHead };
|
package/dist/client.mjs
CHANGED
|
@@ -1,24 +1,216 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { D as DomPlugin, C as ClientEventHandlerPlugin } from './shared/unhead.ovi5lkPs.mjs';
|
|
5
|
-
export { d as debouncedRenderDOMHead, r as renderDOMHead } from './shared/unhead.ovi5lkPs.mjs';
|
|
6
|
-
import 'unctx';
|
|
1
|
+
import { c as createHeadCore } from './shared/unhead.BfOKU5JT.mjs';
|
|
2
|
+
import { H as HasElementTags } from './shared/unhead.BX2ITVEM.mjs';
|
|
3
|
+
import { h as hashTag, i as isMetaArrayDupeKey, a as normalizeProps, d as dedupeKey } from './shared/unhead.CGUU1vXi.mjs';
|
|
7
4
|
import 'hookable';
|
|
8
|
-
|
|
5
|
+
|
|
6
|
+
async function renderDOMHead(head, options = {}) {
|
|
7
|
+
const dom = options.document || head.resolvedOptions.document;
|
|
8
|
+
if (!dom || !head.dirty)
|
|
9
|
+
return;
|
|
10
|
+
const beforeRenderCtx = { shouldRender: true, tags: [] };
|
|
11
|
+
await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
|
|
12
|
+
if (!beforeRenderCtx.shouldRender)
|
|
13
|
+
return;
|
|
14
|
+
if (head._domUpdatePromise) {
|
|
15
|
+
return head._domUpdatePromise;
|
|
16
|
+
}
|
|
17
|
+
head._domUpdatePromise = new Promise(async (resolve) => {
|
|
18
|
+
const dupeKeyCounter = /* @__PURE__ */ new Map();
|
|
19
|
+
const resolveTagPromise = new Promise((resolve2) => {
|
|
20
|
+
head.resolveTags().then((tags2) => {
|
|
21
|
+
resolve2(
|
|
22
|
+
tags2.map((tag) => {
|
|
23
|
+
const count = dupeKeyCounter.get(tag._d) || 0;
|
|
24
|
+
const res = {
|
|
25
|
+
tag,
|
|
26
|
+
id: (count ? `${tag._d}:${count}` : tag._d) || hashTag(tag),
|
|
27
|
+
shouldRender: true
|
|
28
|
+
};
|
|
29
|
+
if (tag._d && isMetaArrayDupeKey(tag._d)) {
|
|
30
|
+
dupeKeyCounter.set(tag._d, count + 1);
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
let state = head._dom;
|
|
38
|
+
if (!state) {
|
|
39
|
+
state = {
|
|
40
|
+
elMap: (/* @__PURE__ */ new Map()).set("htmlAttrs", dom.documentElement).set("bodyAttrs", dom.body)
|
|
41
|
+
};
|
|
42
|
+
for (const key of ["body", "head"]) {
|
|
43
|
+
const children = dom[key]?.children;
|
|
44
|
+
for (const c of children) {
|
|
45
|
+
const tag = c.tagName.toLowerCase();
|
|
46
|
+
if (!HasElementTags.has(tag)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const next = normalizeProps({ tag, props: {} }, {
|
|
50
|
+
innerHTML: c.innerHTML,
|
|
51
|
+
...c.getAttributeNames().reduce((props, name) => {
|
|
52
|
+
props[name] = c.getAttribute(name);
|
|
53
|
+
return props;
|
|
54
|
+
}, {}) || {}
|
|
55
|
+
});
|
|
56
|
+
next.key = c.getAttribute("data-hid") || undefined;
|
|
57
|
+
next._d = dedupeKey(next) || hashTag(next);
|
|
58
|
+
if (state.elMap.has(next._d)) {
|
|
59
|
+
let count = 1;
|
|
60
|
+
let k = next._d;
|
|
61
|
+
while (state.elMap.has(k)) {
|
|
62
|
+
k = `${next._d}:${count++}`;
|
|
63
|
+
}
|
|
64
|
+
state.elMap.set(k, c);
|
|
65
|
+
} else {
|
|
66
|
+
state.elMap.set(next._d, c);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
state.pendingSideEffects = { ...state.sideEffects };
|
|
72
|
+
state.sideEffects = {};
|
|
73
|
+
function track(id, scope, fn) {
|
|
74
|
+
const k = `${id}:${scope}`;
|
|
75
|
+
state.sideEffects[k] = fn;
|
|
76
|
+
delete state.pendingSideEffects[k];
|
|
77
|
+
}
|
|
78
|
+
function trackCtx({ id, $el, tag }) {
|
|
79
|
+
const isAttrTag = tag.tag.endsWith("Attrs");
|
|
80
|
+
state.elMap.set(id, $el);
|
|
81
|
+
if (!isAttrTag) {
|
|
82
|
+
if (tag.textContent && tag.textContent !== $el.textContent) {
|
|
83
|
+
$el.textContent = tag.textContent;
|
|
84
|
+
}
|
|
85
|
+
if (tag.innerHTML && tag.innerHTML !== $el.innerHTML) {
|
|
86
|
+
$el.innerHTML = tag.innerHTML;
|
|
87
|
+
}
|
|
88
|
+
track(id, "el", () => {
|
|
89
|
+
$el?.remove();
|
|
90
|
+
state.elMap.delete(id);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
for (const k in tag.props) {
|
|
94
|
+
if (!Object.hasOwn(tag.props, k))
|
|
95
|
+
continue;
|
|
96
|
+
const value = tag.props[k];
|
|
97
|
+
if (k.startsWith("on") && typeof value === "function") {
|
|
98
|
+
const dataset = $el?.dataset;
|
|
99
|
+
if (dataset && dataset[`${k}fired`]) {
|
|
100
|
+
const ek = k.slice(0, -5);
|
|
101
|
+
value.call($el, new Event(ek.substring(2)));
|
|
102
|
+
}
|
|
103
|
+
if ($el.getAttribute(`data-${k}`) !== "") {
|
|
104
|
+
(tag.tag === "bodyAttrs" ? dom.defaultView : $el).addEventListener(
|
|
105
|
+
// onload -> load
|
|
106
|
+
k.substring(2),
|
|
107
|
+
value.bind($el)
|
|
108
|
+
);
|
|
109
|
+
$el.setAttribute(`data-${k}`, "");
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const ck = `attr:${k}`;
|
|
114
|
+
if (k === "class") {
|
|
115
|
+
if (!value) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
for (const c of value) {
|
|
119
|
+
isAttrTag && track(id, `${ck}:${c}`, () => $el.classList.remove(c));
|
|
120
|
+
!$el.classList.contains(c) && $el.classList.add(c);
|
|
121
|
+
}
|
|
122
|
+
} else if (k === "style") {
|
|
123
|
+
if (!value) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
for (const [k2, v] of value) {
|
|
127
|
+
track(id, `${ck}:${k2}`, () => {
|
|
128
|
+
$el.style.removeProperty(k2);
|
|
129
|
+
});
|
|
130
|
+
$el.style.setProperty(k2, v);
|
|
131
|
+
}
|
|
132
|
+
} else if (value !== false && value !== null) {
|
|
133
|
+
$el.getAttribute(k) !== value && $el.setAttribute(k, value === true ? "" : String(value));
|
|
134
|
+
isAttrTag && track(id, ck, () => $el.removeAttribute(k));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const pending = [];
|
|
139
|
+
const frag = {
|
|
140
|
+
bodyClose: undefined,
|
|
141
|
+
bodyOpen: undefined,
|
|
142
|
+
head: undefined
|
|
143
|
+
};
|
|
144
|
+
const tags = await resolveTagPromise;
|
|
145
|
+
for (const ctx of tags) {
|
|
146
|
+
const { tag, shouldRender, id } = ctx;
|
|
147
|
+
if (!shouldRender)
|
|
148
|
+
continue;
|
|
149
|
+
if (tag.tag === "title") {
|
|
150
|
+
dom.title = tag.textContent;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
ctx.$el = ctx.$el || state.elMap.get(id);
|
|
154
|
+
if (ctx.$el) {
|
|
155
|
+
trackCtx(ctx);
|
|
156
|
+
} else if (HasElementTags.has(tag.tag)) {
|
|
157
|
+
pending.push(ctx);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (const ctx of pending) {
|
|
161
|
+
const pos = ctx.tag.tagPosition || "head";
|
|
162
|
+
ctx.$el = dom.createElement(ctx.tag.tag);
|
|
163
|
+
trackCtx(ctx);
|
|
164
|
+
frag[pos] = frag[pos] || dom.createDocumentFragment();
|
|
165
|
+
frag[pos].appendChild(ctx.$el);
|
|
166
|
+
}
|
|
167
|
+
for (const ctx of tags)
|
|
168
|
+
await head.hooks.callHook("dom:renderTag", ctx, dom, track);
|
|
169
|
+
frag.head && dom.head.appendChild(frag.head);
|
|
170
|
+
frag.bodyOpen && dom.body.insertBefore(frag.bodyOpen, dom.body.firstChild);
|
|
171
|
+
frag.bodyClose && dom.body.appendChild(frag.bodyClose);
|
|
172
|
+
for (const k in state.pendingSideEffects) {
|
|
173
|
+
state.pendingSideEffects[k]();
|
|
174
|
+
}
|
|
175
|
+
head._dom = state;
|
|
176
|
+
await head.hooks.callHook("dom:rendered", { renders: tags });
|
|
177
|
+
resolve();
|
|
178
|
+
}).finally(() => {
|
|
179
|
+
head._domUpdatePromise = undefined;
|
|
180
|
+
head.dirty = false;
|
|
181
|
+
});
|
|
182
|
+
return head._domUpdatePromise;
|
|
183
|
+
}
|
|
9
184
|
|
|
10
185
|
function createHead(options = {}) {
|
|
11
186
|
const head = createHeadCore({
|
|
12
|
-
document:
|
|
13
|
-
...options
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
187
|
+
document: typeof window !== "undefined" ? document : undefined,
|
|
188
|
+
...options
|
|
189
|
+
});
|
|
190
|
+
const initialPayload = head.resolvedOptions.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
191
|
+
if (initialPayload) {
|
|
192
|
+
head.push(JSON.parse(initialPayload));
|
|
193
|
+
}
|
|
194
|
+
const render = options.domOptions?.render || renderDOMHead;
|
|
195
|
+
head.use({
|
|
196
|
+
key: "client",
|
|
197
|
+
hooks: {
|
|
198
|
+
"entries:updated": render
|
|
199
|
+
}
|
|
19
200
|
});
|
|
20
|
-
unheadCtx.set(head, true);
|
|
21
201
|
return head;
|
|
22
202
|
}
|
|
23
203
|
|
|
24
|
-
|
|
204
|
+
function createDebouncedFn(callee, delayer) {
|
|
205
|
+
let ctxId = 0;
|
|
206
|
+
return () => {
|
|
207
|
+
const delayFnCtxId = ++ctxId;
|
|
208
|
+
delayer(() => {
|
|
209
|
+
if (ctxId === delayFnCtxId) {
|
|
210
|
+
callee();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { createDebouncedFn, createHead, renderDOMHead };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'unctx/index';
|
|
1
|
+
import { U as Unhead, H as HeadEntryOptions, A as ActiveHeadEntry, h as UseSeoMetaInput, a as Head, C as CreateHeadOptions } from './shared/unhead.CnmTxLaQ.mjs';
|
|
2
|
+
import { HeadSafe } from './types.mjs';
|
|
3
|
+
import 'hookable';
|
|
5
4
|
|
|
6
|
-
declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}[];
|
|
5
|
+
declare function useHead<T extends Unhead<any>>(unhead: T, input: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
|
|
6
|
+
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
7
|
+
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
11
|
+
* and does not register DOM plugins.
|
|
12
|
+
*/
|
|
13
|
+
declare function createHeadCore<T extends Record<string, any> = Head>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
17
|
-
|
|
18
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
19
|
-
|
|
20
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T>;
|
|
21
|
-
|
|
22
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
23
|
-
|
|
24
|
-
export { type UseHeadInput, unheadComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
15
|
+
export { createHeadCore, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'unctx/index';
|
|
1
|
+
import { U as Unhead, H as HeadEntryOptions, A as ActiveHeadEntry, h as UseSeoMetaInput, a as Head, C as CreateHeadOptions } from './shared/unhead.CnmTxLaQ.js';
|
|
2
|
+
import { HeadSafe } from './types.js';
|
|
3
|
+
import 'hookable';
|
|
5
4
|
|
|
6
|
-
declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}[];
|
|
5
|
+
declare function useHead<T extends Unhead<any>>(unhead: T, input: Parameters<T['push']>[0], options?: HeadEntryOptions): ReturnType<T['push']>;
|
|
6
|
+
declare function useHeadSafe<T extends Unhead<any>>(unhead: T, input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe>;
|
|
7
|
+
declare function useSeoMeta<T extends Unhead<any>>(unhead: T, input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a core instance of unhead. Does not provide a global ctx for composables to work
|
|
11
|
+
* and does not register DOM plugins.
|
|
12
|
+
*/
|
|
13
|
+
declare function createHeadCore<T extends Record<string, any> = Head>(resolvedOptions?: CreateHeadOptions): Unhead<T>;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
17
|
-
|
|
18
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
19
|
-
|
|
20
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T>;
|
|
21
|
-
|
|
22
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any>;
|
|
23
|
-
|
|
24
|
-
export { type UseHeadInput, unheadComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
|
15
|
+
export { createHeadCore, useHead, useHeadSafe, useSeoMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1,66 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'unctx';
|
|
1
|
+
export { u as useHead, a as useHeadSafe, b as useSeoMeta } from './shared/unhead.DgyS1B7b.mjs';
|
|
2
|
+
export { c as createHeadCore } from './shared/unhead.BfOKU5JT.mjs';
|
|
3
|
+
import './shared/unhead.Cktr7sRK.mjs';
|
|
4
|
+
import './shared/unhead.CnyuWd5e.mjs';
|
|
5
|
+
import './shared/unhead.BX2ITVEM.mjs';
|
|
7
6
|
import 'hookable';
|
|
8
|
-
import './shared/unhead.
|
|
9
|
-
|
|
10
|
-
const unheadComposablesImports = [
|
|
11
|
-
{
|
|
12
|
-
from: "unhead",
|
|
13
|
-
imports: composableNames
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
function useHead(input, options = {}) {
|
|
18
|
-
const head = options.head || useUnhead();
|
|
19
|
-
return head.push(input, options);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function useHeadSafe(input, options) {
|
|
23
|
-
return useHead(input, {
|
|
24
|
-
...options,
|
|
25
|
-
transform: whitelistSafeInput
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function useSeoMeta(input, options) {
|
|
30
|
-
const { title, titleTemplate, ...meta } = input;
|
|
31
|
-
return useHead({
|
|
32
|
-
title,
|
|
33
|
-
titleTemplate,
|
|
34
|
-
// we need to input the meta so the reactivity will be resolved
|
|
35
|
-
// @ts-expect-error runtime type
|
|
36
|
-
_flatMeta: meta
|
|
37
|
-
}, {
|
|
38
|
-
...options,
|
|
39
|
-
transform(t) {
|
|
40
|
-
const meta2 = unpackMeta({ ...t._flatMeta });
|
|
41
|
-
delete t._flatMeta;
|
|
42
|
-
return {
|
|
43
|
-
// @ts-expect-error runtime type
|
|
44
|
-
...t,
|
|
45
|
-
meta: meta2
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function useServerHead(input, options = {}) {
|
|
52
|
-
return useHead(input, { ...options, mode: "server" });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function useServerHeadSafe(input, options = {}) {
|
|
56
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function useServerSeoMeta(input, options) {
|
|
60
|
-
return useSeoMeta(input, {
|
|
61
|
-
...options,
|
|
62
|
-
mode: "server"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { unheadComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta, useUnhead };
|
|
7
|
+
import './shared/unhead.CGUU1vXi.mjs';
|
package/dist/legacy.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '
|
|
1
|
+
export { createHeadCore, useHead, useHeadSafe, useSeoMeta } from './index.mjs';
|
|
2
|
+
import { S as Script, A as ActiveHeadEntry, H as HeadEntryOptions, U as Unhead, a as Head, C as CreateHeadOptions } from './shared/unhead.CnmTxLaQ.mjs';
|
|
3
|
+
import './types.mjs';
|
|
4
|
+
import 'hookable';
|
|
4
5
|
|
|
5
6
|
type UseScriptInput = string | (Omit<Script, 'src'> & {
|
|
6
7
|
src: string;
|
|
@@ -93,15 +94,16 @@ type UseFunctionType<T, U> = T extends {
|
|
|
93
94
|
*/
|
|
94
95
|
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
95
96
|
|
|
97
|
+
declare const activeHead: {
|
|
98
|
+
value: Unhead<any> | null;
|
|
99
|
+
};
|
|
100
|
+
declare function getActiveHead(): Unhead<any> | null;
|
|
101
|
+
declare const unheadComposablesImports: {
|
|
102
|
+
from: string;
|
|
103
|
+
imports: string[];
|
|
104
|
+
}[];
|
|
105
|
+
declare const composableNames: string[];
|
|
96
106
|
declare function createServerHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
97
107
|
declare function createHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
98
|
-
declare function getActiveHead(): Unhead<Head<MergeHead>> | null;
|
|
99
|
-
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
100
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
101
|
-
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe> | void;
|
|
102
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
103
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
104
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T> | void;
|
|
105
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
106
108
|
|
|
107
|
-
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type
|
|
109
|
+
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, activeHead, composableNames, createHead, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useScript };
|
package/dist/legacy.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '
|
|
1
|
+
export { createHeadCore, useHead, useHeadSafe, useSeoMeta } from './index.js';
|
|
2
|
+
import { S as Script, A as ActiveHeadEntry, H as HeadEntryOptions, U as Unhead, a as Head, C as CreateHeadOptions } from './shared/unhead.CnmTxLaQ.js';
|
|
3
|
+
import './types.js';
|
|
4
|
+
import 'hookable';
|
|
4
5
|
|
|
5
6
|
type UseScriptInput = string | (Omit<Script, 'src'> & {
|
|
6
7
|
src: string;
|
|
@@ -93,15 +94,16 @@ type UseFunctionType<T, U> = T extends {
|
|
|
93
94
|
*/
|
|
94
95
|
declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
|
|
95
96
|
|
|
97
|
+
declare const activeHead: {
|
|
98
|
+
value: Unhead<any> | null;
|
|
99
|
+
};
|
|
100
|
+
declare function getActiveHead(): Unhead<any> | null;
|
|
101
|
+
declare const unheadComposablesImports: {
|
|
102
|
+
from: string;
|
|
103
|
+
imports: string[];
|
|
104
|
+
}[];
|
|
105
|
+
declare const composableNames: string[];
|
|
96
106
|
declare function createServerHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
97
107
|
declare function createHead<T extends Record<string, any> = Head>(options?: CreateHeadOptions): Unhead<T>;
|
|
98
|
-
declare function getActiveHead(): Unhead<Head<MergeHead>> | null;
|
|
99
|
-
type UseHeadInput<T extends MergeHead> = Head<T>;
|
|
100
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
101
|
-
declare function useHeadSafe(input: HeadSafe, options?: HeadEntryOptions): ActiveHeadEntry<HeadSafe> | void;
|
|
102
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
103
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
104
|
-
declare function useServerHeadSafe<T extends HeadSafe>(input: T, options?: HeadEntryOptions): ActiveHeadEntry<T> | void;
|
|
105
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: HeadEntryOptions): ActiveHeadEntry<any> | void;
|
|
106
108
|
|
|
107
|
-
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type
|
|
109
|
+
export { type AsAsyncFunctionValues, type ScriptInstance, type UseFunctionType, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptResolvedInput, type UseScriptStatus, activeHead, composableNames, createHead, createServerHead, getActiveHead, resolveScriptKey, unheadComposablesImports, useScript };
|