@unhead/bundler 3.0.0-rc.1

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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/devtools/bridge.d.mts +10 -0
  4. package/dist/devtools/bridge.d.ts +10 -0
  5. package/dist/devtools/bridge.mjs +324 -0
  6. package/dist/devtools-ui/200.html +1 -0
  7. package/dist/devtools-ui/404.html +1 -0
  8. package/dist/devtools-ui/_nuxt/B8PEiB0p.js +1 -0
  9. package/dist/devtools-ui/_nuxt/B9CgE5J6.js +1 -0
  10. package/dist/devtools-ui/_nuxt/BJ42UJro.js +1 -0
  11. package/dist/devtools-ui/_nuxt/BOzzsL9j.js +1 -0
  12. package/dist/devtools-ui/_nuxt/CC8iqwL_.js +1 -0
  13. package/dist/devtools-ui/_nuxt/CLj8gQPS.js +1 -0
  14. package/dist/devtools-ui/_nuxt/CUZFOKWE.js +1 -0
  15. package/dist/devtools-ui/_nuxt/CVGS_sMg.js +1 -0
  16. package/dist/devtools-ui/_nuxt/CVO1_9PV.js +1 -0
  17. package/dist/devtools-ui/_nuxt/Cp-IABpG.js +1 -0
  18. package/dist/devtools-ui/_nuxt/D0r3Knsf.js +1 -0
  19. package/dist/devtools-ui/_nuxt/D2XNJYSt.js +1 -0
  20. package/dist/devtools-ui/_nuxt/D2j1X0ma.js +181 -0
  21. package/dist/devtools-ui/_nuxt/DNXA5IKg.js +1 -0
  22. package/dist/devtools-ui/_nuxt/D_TuKxep.js +1 -0
  23. package/dist/devtools-ui/_nuxt/Deu7B_Ux.js +1 -0
  24. package/dist/devtools-ui/_nuxt/DevtoolsKeyValue.CGQNexGc.css +1 -0
  25. package/dist/devtools-ui/_nuxt/DevtoolsTagTable.Bi_gUiSE.css +1 -0
  26. package/dist/devtools-ui/_nuxt/DevtoolsTip.By8OtGoF.css +1 -0
  27. package/dist/devtools-ui/_nuxt/Dpg3GvfJ.js +1 -0
  28. package/dist/devtools-ui/_nuxt/DuAJIi38.js +1 -0
  29. package/dist/devtools-ui/_nuxt/OCodeBlock.cuqShMa1.css +1 -0
  30. package/dist/devtools-ui/_nuxt/QXSvvKqL.js +1 -0
  31. package/dist/devtools-ui/_nuxt/UQ4k7j0M.js +1 -0
  32. package/dist/devtools-ui/_nuxt/aDaU-lXw.js +1 -0
  33. package/dist/devtools-ui/_nuxt/builds/latest.json +1 -0
  34. package/dist/devtools-ui/_nuxt/builds/meta/cae94e84-32db-4da4-8b0f-478d21dcc68b.json +1 -0
  35. package/dist/devtools-ui/_nuxt/cBFzznMP.js +1 -0
  36. package/dist/devtools-ui/_nuxt/entry.clcQIxBm.css +1 -0
  37. package/dist/devtools-ui/_nuxt/error-404.Cu92rxSa.css +1 -0
  38. package/dist/devtools-ui/_nuxt/error-500.B9_6I3ju.css +1 -0
  39. package/dist/devtools-ui/_nuxt/identity.qqB_zwgO.css +1 -0
  40. package/dist/devtools-ui/_nuxt/schema-validation.CRmraV8c.css +1 -0
  41. package/dist/devtools-ui/_nuxt/schema.CFjU2dVl.css +1 -0
  42. package/dist/devtools-ui/_nuxt/scripts.UkRMfT5v.css +1 -0
  43. package/dist/devtools-ui/_nuxt/serp.CZGidvZH.css +1 -0
  44. package/dist/devtools-ui/_nuxt/wDzz0qaB.js +1 -0
  45. package/dist/devtools-ui/index.html +1 -0
  46. package/dist/index.d.mts +28 -0
  47. package/dist/index.d.ts +28 -0
  48. package/dist/index.mjs +79 -0
  49. package/dist/minify/esbuild.d.mts +5 -0
  50. package/dist/minify/esbuild.d.ts +5 -0
  51. package/dist/minify/esbuild.mjs +10 -0
  52. package/dist/minify/lightningcss.d.mts +5 -0
  53. package/dist/minify/lightningcss.d.ts +5 -0
  54. package/dist/minify/lightningcss.mjs +14 -0
  55. package/dist/minify/rolldown.d.mts +5 -0
  56. package/dist/minify/rolldown.d.ts +5 -0
  57. package/dist/minify/rolldown.mjs +10 -0
  58. package/dist/shared/bundler.BwKIGaKX.d.mts +60 -0
  59. package/dist/shared/bundler.BwKIGaKX.d.ts +60 -0
  60. package/dist/shared/bundler.DRWfqG8C.mjs +453 -0
  61. package/dist/vite.d.mts +6 -0
  62. package/dist/vite.d.ts +6 -0
  63. package/dist/vite.mjs +282 -0
  64. package/dist/webpack.d.mts +5 -0
  65. package/dist/webpack.d.ts +5 -0
  66. package/dist/webpack.mjs +31 -0
  67. package/package.json +111 -0
  68. package/vite.d.ts +1 -0
  69. package/webpack.d.ts +1 -0
@@ -0,0 +1,28 @@
1
+ import { HeadPluginInput } from 'unhead/types';
2
+ export { InferSeoMetaPlugin } from 'unhead/plugins';
3
+
4
+ declare const DefaultCriticalTags: {
5
+ htmlAttrs: {
6
+ lang: string;
7
+ };
8
+ meta: ({
9
+ charset: string;
10
+ name?: undefined;
11
+ content?: undefined;
12
+ } | {
13
+ name: string;
14
+ content: string;
15
+ charset?: undefined;
16
+ })[];
17
+ };
18
+
19
+ /**
20
+ * Unhead plugin that propagates source location metadata from entry options to tags.
21
+ *
22
+ * On the server, it also serializes the full devtools state into a
23
+ * `<script id="unhead:devtools">` payload so the client bridge can display
24
+ * server-only entries.
25
+ */
26
+ declare function devtoolsPlugin(): HeadPluginInput;
27
+
28
+ export { DefaultCriticalTags, devtoolsPlugin };
package/dist/index.mjs ADDED
@@ -0,0 +1,79 @@
1
+ export { InferSeoMetaPlugin } from 'unhead/plugins';
2
+
3
+ const DefaultCriticalTags = {
4
+ htmlAttrs: {
5
+ lang: "en"
6
+ },
7
+ meta: [
8
+ { charset: "utf-8" },
9
+ { name: "viewport", content: "width=device-width, initial-scale=1" }
10
+ ]
11
+ };
12
+
13
+ function devtoolsPlugin() {
14
+ return (head) => {
15
+ return {
16
+ key: "devtools",
17
+ hooks: {
18
+ "entries:normalize": function({ tags, entry }) {
19
+ const source = entry.options?._source;
20
+ if (!source)
21
+ return;
22
+ for (const tag of tags) {
23
+ if (!tag._source)
24
+ tag._source = source;
25
+ }
26
+ },
27
+ "tags:resolve": function(ctx) {
28
+ if (!head.ssr)
29
+ return;
30
+ const entries = [];
31
+ for (const [id, entry] of head.entries) {
32
+ let input = {};
33
+ try {
34
+ input = JSON.parse(JSON.stringify(entry.input || {}, (_k, v) => {
35
+ if (typeof v === "function")
36
+ return `\u0192 ${v.name || "anonymous"}()`;
37
+ if (typeof v === "undefined")
38
+ return "\u2298 undefined";
39
+ return v;
40
+ }));
41
+ } catch {
42
+ }
43
+ entries.push({
44
+ id,
45
+ source: entry.options?._source,
46
+ input,
47
+ tagCount: (entry._tags || []).length,
48
+ mode: "server"
49
+ });
50
+ }
51
+ const tags = [];
52
+ for (const tag of ctx.tags) {
53
+ if (tag.props?.id === "unhead:devtools" || tag.props?.id === "unhead:payload")
54
+ continue;
55
+ tags.push({
56
+ tag: tag.tag,
57
+ props: { ...tag.props },
58
+ innerHTML: tag.innerHTML,
59
+ textContent: tag.textContent,
60
+ position: tag.tagPosition,
61
+ priority: tag._w,
62
+ dedupeKey: tag._d,
63
+ source: tag._source,
64
+ mode: "server"
65
+ });
66
+ }
67
+ ctx.tags.push({
68
+ tag: "script",
69
+ // Escape `<` so a serialized `<\/script>` cannot close the inline JSON block early
70
+ innerHTML: JSON.stringify({ entries, tags }).replace(/</g, "\\u003C"),
71
+ props: { id: "unhead:devtools", type: "application/json" }
72
+ });
73
+ }
74
+ }
75
+ };
76
+ };
77
+ }
78
+
79
+ export { DefaultCriticalTags, devtoolsPlugin };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.mjs';
2
+
3
+ declare function createJSMinifier(): MinifyFn;
4
+
5
+ export { createJSMinifier };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.js';
2
+
3
+ declare function createJSMinifier(): MinifyFn;
4
+
5
+ export { createJSMinifier };
@@ -0,0 +1,10 @@
1
+ import { transform } from 'esbuild';
2
+
3
+ function createJSMinifier() {
4
+ return async (code) => {
5
+ const result = await transform(code, { minify: true, loader: "js" });
6
+ return result.code.trim();
7
+ };
8
+ }
9
+
10
+ export { createJSMinifier };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.mjs';
2
+
3
+ declare function createCSSMinifier(): MinifyFn;
4
+
5
+ export { createCSSMinifier };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.js';
2
+
3
+ declare function createCSSMinifier(): MinifyFn;
4
+
5
+ export { createCSSMinifier };
@@ -0,0 +1,14 @@
1
+ import { transform } from 'lightningcss';
2
+
3
+ function createCSSMinifier() {
4
+ return async (code) => {
5
+ const result = transform({
6
+ filename: "inline.css",
7
+ code: new TextEncoder().encode(code),
8
+ minify: true
9
+ });
10
+ return new TextDecoder().decode(result.code).trim();
11
+ };
12
+ }
13
+
14
+ export { createCSSMinifier };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.mjs';
2
+
3
+ declare function createJSMinifier(): MinifyFn;
4
+
5
+ export { createJSMinifier };
@@ -0,0 +1,5 @@
1
+ import { M as MinifyFn } from '../shared/bundler.BwKIGaKX.js';
2
+
3
+ declare function createJSMinifier(): MinifyFn;
4
+
5
+ export { createJSMinifier };
@@ -0,0 +1,10 @@
1
+ import { minify } from 'rolldown/experimental';
2
+
3
+ function createJSMinifier() {
4
+ return async (code) => {
5
+ const result = await minify("inline.js", code);
6
+ return result.code.trim();
7
+ };
8
+ }
9
+
10
+ export { createJSMinifier };
@@ -0,0 +1,60 @@
1
+ type MinifyFn = (code: string) => Promise<string | null>;
2
+ interface MinifyTransformOptions extends BaseTransformerTypes {
3
+ /**
4
+ * Custom JS minifier function, or `false` to disable JS minification.
5
+ *
6
+ * Use a subpath import to get a preconfigured minifier:
7
+ * - `@unhead/bundler/minify/rolldown` (Vite 8+)
8
+ * - `@unhead/bundler/minify/esbuild` (Vite 7)
9
+ */
10
+ js?: false | MinifyFn;
11
+ /**
12
+ * Custom CSS minifier function, or `false` to disable CSS minification.
13
+ *
14
+ * Use `@unhead/bundler/minify/lightningcss` for a preconfigured minifier.
15
+ */
16
+ css?: false | MinifyFn;
17
+ }
18
+
19
+ interface TreeshakeServerComposablesOptions extends BaseTransformerTypes {
20
+ /**
21
+ * @deprecated Use `treeshake: false` at the top level instead.
22
+ */
23
+ enabled?: boolean;
24
+ }
25
+
26
+ interface UseSeoMetaTransformOptions extends BaseTransformerTypes {
27
+ /**
28
+ * Whether to transform imports of `useSeoMeta` and `useServerSeoMeta` to `useHead` and `useServerHead`.
29
+ */
30
+ imports?: boolean;
31
+ /**
32
+ * Extra import paths to consider where `useSeoMeta()` may be imported from.
33
+ */
34
+ importPaths?: string[];
35
+ }
36
+
37
+ interface BaseTransformerTypes {
38
+ sourcemap?: boolean;
39
+ filter?: {
40
+ exclude?: RegExp[];
41
+ include?: RegExp[];
42
+ };
43
+ }
44
+ interface UnpluginOptions extends BaseTransformerTypes {
45
+ treeshake?: TreeshakeServerComposablesOptions | false;
46
+ transformSeoMeta?: UseSeoMetaTransformOptions | false;
47
+ minify?: MinifyTransformOptions | false;
48
+ }
49
+ interface VitePluginOptions extends UnpluginOptions {
50
+ /** Vite DevTools integration (dev-only). Enabled by default, set `false` to disable. */
51
+ devtools?: UnheadDevtoolsOptions | false;
52
+ /** Inject ValidatePlugin in dev to surface head tag warnings in the console. Enabled by default, set `false` to disable. */
53
+ validate?: boolean;
54
+ /** @internal */
55
+ _framework?: string;
56
+ }
57
+ interface UnheadDevtoolsOptions {
58
+ }
59
+
60
+ export type { MinifyFn as M, UnpluginOptions as U, VitePluginOptions as V };
@@ -0,0 +1,60 @@
1
+ type MinifyFn = (code: string) => Promise<string | null>;
2
+ interface MinifyTransformOptions extends BaseTransformerTypes {
3
+ /**
4
+ * Custom JS minifier function, or `false` to disable JS minification.
5
+ *
6
+ * Use a subpath import to get a preconfigured minifier:
7
+ * - `@unhead/bundler/minify/rolldown` (Vite 8+)
8
+ * - `@unhead/bundler/minify/esbuild` (Vite 7)
9
+ */
10
+ js?: false | MinifyFn;
11
+ /**
12
+ * Custom CSS minifier function, or `false` to disable CSS minification.
13
+ *
14
+ * Use `@unhead/bundler/minify/lightningcss` for a preconfigured minifier.
15
+ */
16
+ css?: false | MinifyFn;
17
+ }
18
+
19
+ interface TreeshakeServerComposablesOptions extends BaseTransformerTypes {
20
+ /**
21
+ * @deprecated Use `treeshake: false` at the top level instead.
22
+ */
23
+ enabled?: boolean;
24
+ }
25
+
26
+ interface UseSeoMetaTransformOptions extends BaseTransformerTypes {
27
+ /**
28
+ * Whether to transform imports of `useSeoMeta` and `useServerSeoMeta` to `useHead` and `useServerHead`.
29
+ */
30
+ imports?: boolean;
31
+ /**
32
+ * Extra import paths to consider where `useSeoMeta()` may be imported from.
33
+ */
34
+ importPaths?: string[];
35
+ }
36
+
37
+ interface BaseTransformerTypes {
38
+ sourcemap?: boolean;
39
+ filter?: {
40
+ exclude?: RegExp[];
41
+ include?: RegExp[];
42
+ };
43
+ }
44
+ interface UnpluginOptions extends BaseTransformerTypes {
45
+ treeshake?: TreeshakeServerComposablesOptions | false;
46
+ transformSeoMeta?: UseSeoMetaTransformOptions | false;
47
+ minify?: MinifyTransformOptions | false;
48
+ }
49
+ interface VitePluginOptions extends UnpluginOptions {
50
+ /** Vite DevTools integration (dev-only). Enabled by default, set `false` to disable. */
51
+ devtools?: UnheadDevtoolsOptions | false;
52
+ /** Inject ValidatePlugin in dev to surface head tag warnings in the console. Enabled by default, set `false` to disable. */
53
+ validate?: boolean;
54
+ /** @internal */
55
+ _framework?: string;
56
+ }
57
+ interface UnheadDevtoolsOptions {
58
+ }
59
+
60
+ export type { MinifyFn as M, UnpluginOptions as U, VitePluginOptions as V };