@highstate/designer 0.7.0 → 0.7.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 (57) hide show
  1. package/.output/nitro.json +3 -3
  2. package/.output/public/_nuxt/1_b4y8eQ.js +1 -0
  3. package/.output/public/_nuxt/BjOhMR1f.js +242 -0
  4. package/.output/public/_nuxt/CPAAHz3G.js +1 -0
  5. package/.output/public/_nuxt/{TC7QuZux.js → CmGpyJTe.js} +1 -1
  6. package/.output/public/_nuxt/builds/latest.json +1 -1
  7. package/.output/public/_nuxt/builds/meta/d9ef4694-b71b-4675-9064-eba6ec8658b0.json +1 -0
  8. package/.output/public/_nuxt/{entry.DpeBhKHh.css → entry.Vs8IncyG.css} +1 -1
  9. package/.output/server/index.mjs +1876 -3051
  10. package/.output/server/index.mjs.map +1 -1
  11. package/.output/server/node_modules/@babel/parser/lib/index.js +129 -97
  12. package/.output/server/node_modules/@babel/parser/package.json +2 -2
  13. package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs +74 -0
  14. package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/index.mjs +1 -0
  15. package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/incomingMessageToRequest.mjs +119 -0
  16. package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/index.mjs +2 -0
  17. package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +92 -0
  18. package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/writeResponse.mjs +79 -0
  19. package/.output/server/node_modules/@trpc/server/dist/index.mjs +1 -1
  20. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs +1 -1
  21. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/parser.mjs +4 -3
  22. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs +3 -0
  23. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs +1 -1
  24. package/.output/server/node_modules/@trpc/server/package.json +6 -6
  25. package/.output/server/node_modules/unhead/dist/plugins.mjs +94 -0
  26. package/.output/server/node_modules/unhead/dist/server.mjs +220 -0
  27. package/.output/server/node_modules/unhead/dist/shared/unhead.C13swrCa.mjs +48 -0
  28. package/.output/server/node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs +148 -0
  29. package/.output/server/node_modules/unhead/dist/shared/unhead.Cp0iF6eN.mjs +177 -0
  30. package/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
  31. package/.output/server/node_modules/unhead/dist/shared/unhead.DZbvapt-.mjs +70 -0
  32. package/.output/server/node_modules/unhead/dist/shared/unhead.DeCxexjU.mjs +166 -0
  33. package/.output/server/node_modules/unhead/dist/shared/unhead.Txd0XTIP.mjs +172 -0
  34. package/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
  35. package/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
  36. package/.output/server/node_modules/unhead/package.json +66 -11
  37. package/.output/server/package.json +1 -1
  38. package/package.json +8 -8
  39. package/.output/public/_nuxt/B3Ns2-bM.js +0 -1
  40. package/.output/public/_nuxt/DToExo9V.js +0 -1
  41. package/.output/public/_nuxt/builds/meta/f64fe243-c5f1-4f5e-a593-05cf555884c2.json +0 -1
  42. package/.output/public/_nuxt/u3nCRAjk.js +0 -244
  43. package/.output/server/node_modules/@trpc/server/dist/http.mjs +0 -7
  44. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
  45. package/.output/server/node_modules/@unhead/dom/dist/index.mjs +0 -197
  46. package/.output/server/node_modules/@unhead/dom/package.json +0 -40
  47. package/.output/server/node_modules/@unhead/shared/dist/index.mjs +0 -641
  48. package/.output/server/node_modules/@unhead/shared/package.json +0 -45
  49. package/.output/server/node_modules/@unhead/ssr/dist/index.mjs +0 -95
  50. package/.output/server/node_modules/@unhead/ssr/package.json +0 -40
  51. package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +0 -1
  52. package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +0 -1
  53. package/.output/server/node_modules/node-mock-http/dist/index.mjs +0 -1
  54. package/.output/server/node_modules/node-mock-http/package.json +0 -63
  55. package/.output/server/node_modules/packrup/dist/index.mjs +0 -108
  56. package/.output/server/node_modules/packrup/package.json +0 -58
  57. package/.output/server/node_modules/unhead/dist/index.mjs +0 -748
@@ -0,0 +1,74 @@
1
+ import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
2
+ import '../../unstable-core-do-not-import/rootConfig.mjs';
3
+ import '../../vendor/unpromise/unpromise.mjs';
4
+ import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
5
+
6
+ /**
7
+ * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import type { AnyTRPCRouter } from '@trpc/server'
12
+ * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
13
+ * ```
14
+ */ // @trpc/server
15
+ const trimSlashes = (path)=>{
16
+ path = path.startsWith('/') ? path.slice(1) : path;
17
+ path = path.endsWith('/') ? path.slice(0, -1) : path;
18
+ return path;
19
+ };
20
+ async function fetchRequestHandler(opts) {
21
+ const resHeaders = new Headers();
22
+ const createContext = async (innerOpts)=>{
23
+ return opts.createContext?.({
24
+ req: opts.req,
25
+ resHeaders,
26
+ ...innerOpts
27
+ });
28
+ };
29
+ const url = new URL(opts.req.url);
30
+ const pathname = trimSlashes(url.pathname);
31
+ const endpoint = trimSlashes(opts.endpoint);
32
+ const path = trimSlashes(pathname.slice(endpoint.length));
33
+ return await resolveResponse({
34
+ ...opts,
35
+ req: opts.req,
36
+ createContext,
37
+ path,
38
+ error: null,
39
+ onError (o) {
40
+ opts?.onError?.({
41
+ ...o,
42
+ req: opts.req
43
+ });
44
+ },
45
+ responseMeta (data) {
46
+ const meta = opts.responseMeta?.(data);
47
+ if (meta?.headers) {
48
+ if (meta.headers instanceof Headers) {
49
+ for (const [key, value] of meta.headers.entries()){
50
+ resHeaders.append(key, value);
51
+ }
52
+ } else {
53
+ /**
54
+ * @deprecated, delete in v12
55
+ */ for (const [key, value] of Object.entries(meta.headers)){
56
+ if (Array.isArray(value)) {
57
+ for (const v of value){
58
+ resHeaders.append(key, v);
59
+ }
60
+ } else if (typeof value === 'string') {
61
+ resHeaders.set(key, value);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ return {
67
+ headers: resHeaders,
68
+ status: meta?.status
69
+ };
70
+ }
71
+ });
72
+ }
73
+
74
+ export { fetchRequestHandler };
@@ -0,0 +1 @@
1
+ export { fetchRequestHandler } from './fetchRequestHandler.mjs';
@@ -0,0 +1,119 @@
1
+ import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
2
+ import '../../vendor/unpromise/unpromise.mjs';
3
+ import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
4
+ import '../../unstable-core-do-not-import/rootConfig.mjs';
5
+
6
+ function createBody(req, opts) {
7
+ // Some adapters will pre-parse the body and add it to the request object
8
+ if ('body' in req) {
9
+ if (req.body === undefined) {
10
+ // If body property exists but is undefined, return undefined
11
+ return undefined;
12
+ }
13
+ // If the body is already a string, return it directly
14
+ if (typeof req.body === 'string') {
15
+ return req.body;
16
+ }
17
+ // If body exists but isn't a string, stringify it as JSON
18
+ return JSON.stringify(req.body);
19
+ }
20
+ let size = 0;
21
+ let hasClosed = false;
22
+ return new ReadableStream({
23
+ start (controller) {
24
+ const onData = (chunk)=>{
25
+ size += chunk.length;
26
+ if (!opts.maxBodySize || size <= opts.maxBodySize) {
27
+ controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
28
+ return;
29
+ }
30
+ controller.error(new TRPCError({
31
+ code: 'PAYLOAD_TOO_LARGE'
32
+ }));
33
+ hasClosed = true;
34
+ req.off('data', onData);
35
+ req.off('end', onEnd);
36
+ };
37
+ const onEnd = ()=>{
38
+ if (hasClosed) {
39
+ return;
40
+ }
41
+ hasClosed = true;
42
+ req.off('data', onData);
43
+ req.off('end', onEnd);
44
+ controller.close();
45
+ };
46
+ req.on('data', onData);
47
+ req.on('end', onEnd);
48
+ },
49
+ cancel () {
50
+ req.destroy();
51
+ }
52
+ });
53
+ }
54
+ function createURL(req) {
55
+ try {
56
+ const protocol = // http2
57
+ req.headers[':scheme'] && req.headers[':scheme'] === 'https' || // http1
58
+ req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
59
+ const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';
60
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
+ return new URL(req.url, `${protocol}//${host}`);
62
+ } catch (cause) {
63
+ throw new TRPCError({
64
+ code: 'BAD_REQUEST',
65
+ message: 'Invalid URL',
66
+ cause
67
+ });
68
+ }
69
+ }
70
+ function createHeaders(incoming) {
71
+ const headers = new Headers();
72
+ for(const key in incoming){
73
+ const value = incoming[key];
74
+ if (typeof key === 'string' && key.startsWith(':')) {
75
+ continue;
76
+ }
77
+ if (Array.isArray(value)) {
78
+ for (const item of value){
79
+ headers.append(key, item);
80
+ }
81
+ } else if (value != null) {
82
+ headers.append(key, value);
83
+ }
84
+ }
85
+ return headers;
86
+ }
87
+ /**
88
+ * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
89
+ */ function incomingMessageToRequest(req, res, opts) {
90
+ const ac = new AbortController();
91
+ const onAbort = ()=>{
92
+ res.off('close', onAbort);
93
+ req.socket?.off?.('close', onAbort);
94
+ // abort the request
95
+ ac.abort();
96
+ };
97
+ res.once('close', onAbort);
98
+ req.socket?.once?.('close', onAbort);
99
+ // Get host from either regular header or HTTP/2 pseudo-header
100
+ const url = createURL(req);
101
+ const init = {
102
+ headers: createHeaders(req.headers),
103
+ method: req.method,
104
+ signal: ac.signal
105
+ };
106
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
107
+ init.body = createBody(req, opts);
108
+ // init.duplex = 'half' must be set when body is a ReadableStream, and Node follows the spec.
109
+ // However, this property is not defined in the TypeScript types for RequestInit, so we have
110
+ // to cast it here in order to set it without a type error.
111
+ // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex
112
+ // @ts-expect-error this is fine
113
+ init.duplex = 'half';
114
+ }
115
+ const request = new Request(url, init);
116
+ return request;
117
+ }
118
+
119
+ export { createURL, incomingMessageToRequest };
@@ -0,0 +1,2 @@
1
+ export { internal_exceptionHandler, nodeHTTPRequestHandler } from './nodeHTTPRequestHandler.mjs';
2
+ export { createURL, incomingMessageToRequest } from './incomingMessageToRequest.mjs';
@@ -0,0 +1,92 @@
1
+ import { getErrorShape } from '../../unstable-core-do-not-import/error/getErrorShape.mjs';
2
+ import { getTRPCErrorFromUnknown } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
3
+ import { transformTRPCResponse } from '../../unstable-core-do-not-import/transformer.mjs';
4
+ import { run } from '../../unstable-core-do-not-import/utils.mjs';
5
+ import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
6
+ import '../../unstable-core-do-not-import/rootConfig.mjs';
7
+ import '../../vendor/unpromise/unpromise.mjs';
8
+ import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
9
+ import { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
10
+ import { writeResponse } from './writeResponse.mjs';
11
+
12
+ /**
13
+ * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import type { AnyTRPCRouter } from '@trpc/server'
18
+ * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
19
+ * ```
20
+ */ // @trpc/server
21
+ /**
22
+ * @internal
23
+ */ function internal_exceptionHandler(opts) {
24
+ return (cause)=>{
25
+ const { res, req } = opts;
26
+ const error = getTRPCErrorFromUnknown(cause);
27
+ const shape = getErrorShape({
28
+ config: opts.router._def._config,
29
+ error,
30
+ type: 'unknown',
31
+ path: undefined,
32
+ input: undefined,
33
+ ctx: undefined
34
+ });
35
+ opts.onError?.({
36
+ req,
37
+ error,
38
+ type: 'unknown',
39
+ path: undefined,
40
+ input: undefined,
41
+ ctx: undefined
42
+ });
43
+ const transformed = transformTRPCResponse(opts.router._def._config, {
44
+ error: shape
45
+ });
46
+ res.statusCode = shape.data.httpStatus;
47
+ res.end(JSON.stringify(transformed));
48
+ };
49
+ }
50
+ /**
51
+ * @remark the promise never rejects
52
+ */ async function nodeHTTPRequestHandler(opts) {
53
+ return new Promise((resolve)=>{
54
+ const handleViaMiddleware = opts.middleware ?? ((_req, _res, next)=>next());
55
+ opts.res.once('finish', ()=>{
56
+ resolve();
57
+ });
58
+ return handleViaMiddleware(opts.req, opts.res, (err)=>{
59
+ run(async ()=>{
60
+ const request = incomingMessageToRequest(opts.req, opts.res, {
61
+ maxBodySize: opts.maxBodySize ?? null
62
+ });
63
+ // Build tRPC dependencies
64
+ const createContext = async (innerOpts)=>{
65
+ return await opts.createContext?.({
66
+ ...opts,
67
+ ...innerOpts
68
+ });
69
+ };
70
+ const response = await resolveResponse({
71
+ ...opts,
72
+ req: request,
73
+ error: err ? getTRPCErrorFromUnknown(err) : null,
74
+ createContext,
75
+ onError (o) {
76
+ opts?.onError?.({
77
+ ...o,
78
+ req: opts.req
79
+ });
80
+ }
81
+ });
82
+ await writeResponse({
83
+ request,
84
+ response,
85
+ rawResponse: opts.res
86
+ });
87
+ }).catch(internal_exceptionHandler(opts));
88
+ });
89
+ });
90
+ }
91
+
92
+ export { internal_exceptionHandler, nodeHTTPRequestHandler };
@@ -0,0 +1,79 @@
1
+ import { isAbortError } from '../../unstable-core-do-not-import/http/abortError.mjs';
2
+ import '../../vendor/unpromise/unpromise.mjs';
3
+ import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
4
+ import '../../unstable-core-do-not-import/rootConfig.mjs';
5
+
6
+ // eslint-disable-next-line no-restricted-imports
7
+ async function writeResponseBodyChunk(res, chunk) {
8
+ // useful for debugging 🙃
9
+ // console.debug('writing', new TextDecoder().decode(chunk));
10
+ if (res.write(chunk) === false) {
11
+ await new Promise((resolve, reject)=>{
12
+ const onError = (err)=>{
13
+ reject(err);
14
+ cleanup();
15
+ };
16
+ const onDrain = ()=>{
17
+ resolve();
18
+ cleanup();
19
+ };
20
+ const cleanup = ()=>{
21
+ res.off('error', onError);
22
+ res.off('drain', onDrain);
23
+ };
24
+ res.once('error', onError);
25
+ res.once('drain', onDrain);
26
+ });
27
+ }
28
+ }
29
+ /**
30
+ * @internal
31
+ */ async function writeResponseBody(opts) {
32
+ const { res } = opts;
33
+ try {
34
+ const writableStream = new WritableStream({
35
+ async write (chunk) {
36
+ await writeResponseBodyChunk(res, chunk);
37
+ res.flush?.();
38
+ }
39
+ });
40
+ await opts.body.pipeTo(writableStream, {
41
+ signal: opts.signal
42
+ });
43
+ } catch (err) {
44
+ if (isAbortError(err)) {
45
+ return;
46
+ }
47
+ throw err;
48
+ }
49
+ }
50
+ /**
51
+ * @internal
52
+ */ async function writeResponse(opts) {
53
+ const { response, rawResponse } = opts;
54
+ // Only override status code if it hasn't been explicitly set in a procedure etc
55
+ if (rawResponse.statusCode === 200) {
56
+ rawResponse.statusCode = response.status;
57
+ }
58
+ for (const [key, value] of response.headers){
59
+ rawResponse.setHeader(key, value);
60
+ }
61
+ try {
62
+ if (response.body) {
63
+ await writeResponseBody({
64
+ res: rawResponse,
65
+ signal: opts.request.signal,
66
+ body: response.body
67
+ });
68
+ }
69
+ } catch (err) {
70
+ if (!rawResponse.headersSent) {
71
+ rawResponse.statusCode = 500;
72
+ }
73
+ throw err;
74
+ } finally{
75
+ rawResponse.end();
76
+ }
77
+ }
78
+
79
+ export { writeResponse, writeResponseBody };
@@ -1,7 +1,7 @@
1
1
  export { createFlatProxy as createTRPCFlatProxy, createRecursiveProxy as createTRPCRecursiveProxy } from './unstable-core-do-not-import/createProxy.mjs';
2
2
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
3
3
  export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
4
- export { callProcedure as callTRPCProcedure, lazy as experimental_lazy } from './unstable-core-do-not-import/router.mjs';
4
+ export { callProcedure as callTRPCProcedure, lazy as experimental_lazy, lazy } from './unstable-core-do-not-import/router.mjs';
5
5
  import './vendor/unpromise/unpromise.mjs';
6
6
  import './unstable-core-do-not-import/stream/utils/disposable.mjs';
7
7
  export { isTrackedEnvelope, sse, tracked } from './unstable-core-do-not-import/stream/tracked.mjs';
@@ -29,7 +29,7 @@ import { isObject } from './utils.mjs';
29
29
  /**
30
30
  * Create a standalone middleware
31
31
  * @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
32
- * @deprecated use `.unstable_concat()` instead
32
+ * @deprecated use `.concat()` instead
33
33
  */ const experimental_standaloneMiddleware = ()=>({
34
34
  create: createMiddlewareFactory()
35
35
  });
@@ -2,13 +2,14 @@ import { StandardSchemaV1Error } from '../vendor/standard-schema-v1/error.mjs';
2
2
 
3
3
  function getParseFn(procedureParser) {
4
4
  const parser = procedureParser;
5
+ const isStandardSchema = '~standard' in parser;
5
6
  if (typeof parser === 'function' && typeof parser.assert === 'function') {
6
7
  // ParserArkTypeEsque - arktype schemas shouldn't be called as a function because they return a union type instead of throwing
7
8
  return parser.assert.bind(parser);
8
9
  }
9
- if (typeof parser === 'function') {
10
+ if (typeof parser === 'function' && !isStandardSchema) {
10
11
  // ParserValibotEsque (>= v0.31.0)
11
- // ParserCustomValidatorEsque
12
+ // ParserCustomValidatorEsque - note the check for standard-schema conformance - some libraries like `effect` use function schemas which are *not* a "parse" function.
12
13
  return parser;
13
14
  }
14
15
  if (typeof parser.parseAsync === 'function') {
@@ -35,7 +36,7 @@ function getParseFn(procedureParser) {
35
36
  return value;
36
37
  };
37
38
  }
38
- if ('~standard' in parser) {
39
+ if (isStandardSchema) {
39
40
  // StandardSchemaEsque
40
41
  return async (value)=>{
41
42
  const result = await parser['~standard'].validate(value);
@@ -68,6 +68,9 @@ function createBuilder(initDef = {}) {
68
68
  unstable_concat (builder) {
69
69
  return createNewBuilder(_def, builder._def);
70
70
  },
71
+ concat (builder) {
72
+ return createNewBuilder(_def, builder._def);
73
+ },
71
74
  query (resolver) {
72
75
  return createResolver({
73
76
  ..._def,
@@ -27,7 +27,7 @@ function once(fn) {
27
27
  }
28
28
  const routers = Object.values(mod);
29
29
  if (routers.length !== 1 || !isRouter(routers[0])) {
30
- throw new Error("Invalid router module - either define exactly 1 export or return the router directly.\nExample: `experimental_lazy(() => import('./slow.js').then((m) => m.slowRouter))`");
30
+ throw new Error("Invalid router module - either define exactly 1 export or return the router directly.\nExample: `lazy(() => import('./slow.js').then((m) => m.slowRouter))`");
31
31
  }
32
32
  return routers[0];
33
33
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.808+4df1eb8fa",
3
+ "version": "11.0.1",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -118,7 +118,7 @@
118
118
  },
119
119
  "devDependencies": {
120
120
  "@fastify/websocket": "^10.0.1",
121
- "@tanstack/react-query": "^5.66.0",
121
+ "@tanstack/react-query": "^5.67.1",
122
122
  "@types/aws-lambda": "^8.10.137",
123
123
  "@types/express": "^5.0.0",
124
124
  "@types/hash-sum": "^1.0.0",
@@ -133,15 +133,15 @@
133
133
  "fastify-plugin": "^5.0.0",
134
134
  "hash-sum": "^2.0.0",
135
135
  "myzod": "^1.3.1",
136
- "next": "^15.1.3",
136
+ "next": "^15.1.7",
137
137
  "react": "^19.0.0",
138
138
  "react-dom": "^19.0.0",
139
139
  "rollup": "^4.34.8",
140
140
  "superjson": "^1.12.4",
141
141
  "superstruct": "^2.0.0",
142
142
  "tsx": "^4.19.3",
143
- "typescript": "^5.7.2",
144
- "valibot": "1.0.0-rc.1",
143
+ "typescript": "^5.8.2",
144
+ "valibot": "1.0.0",
145
145
  "ws": "^8.0.0",
146
146
  "yup": "^1.0.0",
147
147
  "zod": "^3.24.2"
@@ -152,5 +152,5 @@
152
152
  "peerDependencies": {
153
153
  "typescript": ">=5.7.2"
154
154
  },
155
- "gitHead": "4df1eb8fa820341db81bc7cb9907f30dfebbf4d7"
155
+ "gitHead": "662da0bb0a2766125e3f7eced3576f05a850a069"
156
156
  }
@@ -0,0 +1,94 @@
1
+ export { A as AliasSortingPlugin, D as DeprecationsPlugin, P as PromisesPlugin, T as TemplateParamsPlugin } from './shared/unhead.DeCxexjU.mjs';
2
+ import { d as defineHeadPlugin } from './shared/unhead.CApf5sj3.mjs';
3
+ export { F as FlatMetaPlugin, S as SafeInputPlugin } from './shared/unhead.CApf5sj3.mjs';
4
+ import './shared/unhead.DZbvapt-.mjs';
5
+ import './shared/unhead.C13swrCa.mjs';
6
+ import './shared/unhead.DQc16pHI.mjs';
7
+ import './shared/unhead.yem5I2v_.mjs';
8
+
9
+ function CanonicalPlugin(options) {
10
+ return (head) => {
11
+ function resolvePath(path) {
12
+ if (options?.customResolver) {
13
+ return options.customResolver(path);
14
+ }
15
+ let host = options.canonicalHost || (!head.ssr ? window.location.origin : "");
16
+ if (!host.startsWith("http") && !host.startsWith("//")) {
17
+ host = `https://${host}`;
18
+ }
19
+ host = new URL(host).origin;
20
+ if (path.startsWith("http") || path.startsWith("//"))
21
+ return path;
22
+ try {
23
+ return new URL(path, host).toString();
24
+ } catch {
25
+ return path;
26
+ }
27
+ }
28
+ return {
29
+ key: "canonical",
30
+ hooks: {
31
+ "tags:resolve": (ctx) => {
32
+ for (const tag of ctx.tags) {
33
+ if (tag.tag === "meta") {
34
+ if (tag.props.property?.startsWith("og:image") || tag.props.name?.startsWith("twitter:image")) {
35
+ tag.props.content = resolvePath(tag.props.content);
36
+ } else if (tag.props?.property === "og:url") {
37
+ tag.props.content = resolvePath(tag.props.content);
38
+ }
39
+ } else if (tag.tag === "link" && tag.props.rel === "canonical") {
40
+ tag.props.href = resolvePath(tag.props.href);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ };
46
+ };
47
+ }
48
+
49
+ function InferSeoMetaPlugin(options = {}) {
50
+ return defineHeadPlugin((head) => {
51
+ head.push({
52
+ meta: [
53
+ {
54
+ name: "twitter:card",
55
+ content: options.twitterCard || "summary_large_image",
56
+ tagPriority: "low"
57
+ },
58
+ {
59
+ "property": "og:title",
60
+ "tagPriority": "low",
61
+ "data-infer": ""
62
+ },
63
+ {
64
+ "property": "og:description",
65
+ "tagPriority": "low",
66
+ "data-infer": ""
67
+ }
68
+ ]
69
+ });
70
+ return {
71
+ key: "infer-seo-meta",
72
+ hooks: {
73
+ "tags:beforeResolve": ({ tagMap }) => {
74
+ let title = head._title || "";
75
+ const titleTemplate = head._titleTemplate;
76
+ const ogTitle = tagMap.get("meta:og:title");
77
+ if (typeof ogTitle?.props["data-infer"] !== "undefined") {
78
+ if (titleTemplate) {
79
+ title = typeof titleTemplate === "function" ? titleTemplate(title) : titleTemplate.replace("%s", title);
80
+ }
81
+ ogTitle.props.content = options.ogTitle ? options.ogTitle(title) : title || "";
82
+ }
83
+ const description = tagMap.get("meta:description")?.props?.content;
84
+ const ogDescription = tagMap.get("meta:og:description");
85
+ if (typeof ogDescription?.props["data-infer"] !== "undefined") {
86
+ ogDescription.props.content = options.ogDescription ? options.ogDescription(description) : description || "";
87
+ }
88
+ }
89
+ }
90
+ };
91
+ });
92
+ }
93
+
94
+ export { CanonicalPlugin, InferSeoMetaPlugin, defineHeadPlugin };