@highstate/designer 0.6.2 → 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.
- package/.output/nitro.json +3 -3
- package/.output/public/_nuxt/1_b4y8eQ.js +1 -0
- package/.output/public/_nuxt/BjOhMR1f.js +242 -0
- package/.output/public/_nuxt/CPAAHz3G.js +1 -0
- package/.output/public/_nuxt/{TC7QuZux.js → CmGpyJTe.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/d9ef4694-b71b-4675-9064-eba6ec8658b0.json +1 -0
- package/.output/public/_nuxt/{entry.DpeBhKHh.css → entry.Vs8IncyG.css} +1 -1
- package/.output/server/index.mjs +1876 -3051
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@babel/parser/lib/index.js +129 -97
- package/.output/server/node_modules/@babel/parser/package.json +2 -2
- package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs +74 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/index.mjs +1 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/incomingMessageToRequest.mjs +119 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/index.mjs +2 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +92 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/writeResponse.mjs +79 -0
- package/.output/server/node_modules/@trpc/server/dist/index.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/parser.mjs +4 -3
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs +3 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/package.json +6 -6
- package/.output/server/node_modules/unhead/dist/plugins.mjs +94 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +220 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C13swrCa.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs +148 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Cp0iF6eN.mjs +177 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DZbvapt-.mjs +70 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DeCxexjU.mjs +166 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Txd0XTIP.mjs +172 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/.output/server/node_modules/unhead/package.json +66 -11
- package/.output/server/package.json +1 -1
- package/package.json +8 -8
- package/.output/public/_nuxt/B3Ns2-bM.js +0 -1
- package/.output/public/_nuxt/DToExo9V.js +0 -1
- package/.output/public/_nuxt/builds/meta/07f083d2-7441-4589-a821-0cac347461bb.json +0 -1
- package/.output/public/_nuxt/u3nCRAjk.js +0 -244
- package/.output/server/node_modules/@trpc/server/dist/http.mjs +0 -7
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
- package/.output/server/node_modules/@unhead/dom/dist/index.mjs +0 -197
- package/.output/server/node_modules/@unhead/dom/package.json +0 -40
- package/.output/server/node_modules/@unhead/shared/dist/index.mjs +0 -641
- package/.output/server/node_modules/@unhead/shared/package.json +0 -45
- package/.output/server/node_modules/@unhead/ssr/dist/index.mjs +0 -95
- package/.output/server/node_modules/@unhead/ssr/package.json +0 -40
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/package.json +0 -63
- package/.output/server/node_modules/packrup/dist/index.mjs +0 -108
- package/.output/server/node_modules/packrup/package.json +0 -58
- package/.output/server/node_modules/unhead/dist/index.mjs +0 -748
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { TagsWithInnerContent, SelfClosingTags } from '@unhead/shared';
|
|
2
|
-
|
|
3
|
-
function encodeAttribute(value) {
|
|
4
|
-
return String(value).replace(/"/g, """);
|
|
5
|
-
}
|
|
6
|
-
function propsToString(props) {
|
|
7
|
-
let attrs = "";
|
|
8
|
-
for (const key in props) {
|
|
9
|
-
if (!Object.prototype.hasOwnProperty.call(props, key)) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const value = props[key];
|
|
13
|
-
if (value !== false && value !== null) {
|
|
14
|
-
attrs += value === true ? ` ${key}` : ` ${key}="${encodeAttribute(value)}"`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return attrs;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function ssrRenderTags(tags, options) {
|
|
21
|
-
const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
|
|
22
|
-
const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
|
|
23
|
-
for (const tag of tags) {
|
|
24
|
-
if (Object.keys(tag.props).length === 0 && !tag.innerHTML && !tag.textContent) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
|
28
|
-
Object.assign(schema[tag.tag], tag.props);
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const s = tagToString(tag);
|
|
32
|
-
const tagPosition = tag.tagPosition || "head";
|
|
33
|
-
schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
headTags: schema.tags.head,
|
|
37
|
-
bodyTags: schema.tags.bodyClose,
|
|
38
|
-
bodyTagsOpen: schema.tags.bodyOpen,
|
|
39
|
-
htmlAttrs: propsToString(schema.htmlAttrs),
|
|
40
|
-
bodyAttrs: propsToString(schema.bodyAttrs)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function escapeHtml(str) {
|
|
45
|
-
return str.replace(/[&<>"'/]/g, (char) => {
|
|
46
|
-
switch (char) {
|
|
47
|
-
case "&":
|
|
48
|
-
return "&";
|
|
49
|
-
case "<":
|
|
50
|
-
return "<";
|
|
51
|
-
case ">":
|
|
52
|
-
return ">";
|
|
53
|
-
case '"':
|
|
54
|
-
return """;
|
|
55
|
-
case "'":
|
|
56
|
-
return "'";
|
|
57
|
-
case "/":
|
|
58
|
-
return "/";
|
|
59
|
-
default:
|
|
60
|
-
return char;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function tagToString(tag) {
|
|
65
|
-
const attrs = propsToString(tag.props);
|
|
66
|
-
const openTag = `<${tag.tag}${attrs}>`;
|
|
67
|
-
if (!TagsWithInnerContent.has(tag.tag))
|
|
68
|
-
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}</${tag.tag}>`;
|
|
69
|
-
let content = String(tag.innerHTML || "");
|
|
70
|
-
if (tag.textContent)
|
|
71
|
-
content = escapeHtml(String(tag.textContent));
|
|
72
|
-
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function renderSSRHead(head, options) {
|
|
76
|
-
const beforeRenderCtx = { shouldRender: true };
|
|
77
|
-
await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
|
|
78
|
-
if (!beforeRenderCtx.shouldRender) {
|
|
79
|
-
return {
|
|
80
|
-
headTags: "",
|
|
81
|
-
bodyTags: "",
|
|
82
|
-
bodyTagsOpen: "",
|
|
83
|
-
htmlAttrs: "",
|
|
84
|
-
bodyAttrs: ""
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
const ctx = { tags: await head.resolveTags() };
|
|
88
|
-
await head.hooks.callHook("ssr:render", ctx);
|
|
89
|
-
const html = ssrRenderTags(ctx.tags, options);
|
|
90
|
-
const renderCtx = { tags: ctx.tags, html };
|
|
91
|
-
await head.hooks.callHook("ssr:rendered", renderCtx);
|
|
92
|
-
return renderCtx.html;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { escapeHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@unhead/ssr",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "1.11.19",
|
|
5
|
-
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"funding": "https://github.com/sponsors/harlan-zw",
|
|
8
|
-
"homepage": "https://unhead.unjs.io",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/unjs/unhead.git",
|
|
12
|
-
"directory": "packages/ssr"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/unjs/unhead/issues"
|
|
16
|
-
},
|
|
17
|
-
"sideEffects": false,
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.mjs",
|
|
22
|
-
"require": "./dist/index.cjs"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"main": "dist/index.cjs",
|
|
26
|
-
"module": "dist/index.mjs",
|
|
27
|
-
"types": "dist/index.d.ts",
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@unhead/schema": "1.11.19",
|
|
33
|
-
"@unhead/shared": "1.11.19"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "unbuild .",
|
|
37
|
-
"stub": "unbuild . --stub",
|
|
38
|
-
"export:sizes": "npx export-size . -r"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{Buffer}from"node:buffer";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{EventEmitter}from"node:events";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EventEmitter as f}from"node-mock-http/_polyfill/events";import{Buffer as h}from"node-mock-http/_polyfill/buffer";function o(n){throw new Error(`${n} is not implemented yet!`)}class i extends f{__unenv__={};readableEncoding=null;readableEnded=!0;readableFlowing=!1;readableHighWaterMark=0;readableLength=0;readableObjectMode=!1;readableAborted=!1;readableDidRead=!1;closed=!1;errored=null;readable=!1;destroyed=!1;static from(e,t){return new i(t)}constructor(e){super()}_read(e){}read(e){}setEncoding(e){return this}pause(){return this}resume(){return this}isPaused(){return!0}unpipe(e){return this}unshift(e,t){}wrap(e){return this}push(e,t){return!1}_destroy(e,t){this.removeAllListeners()}destroy(e){return this.destroyed=!0,this._destroy(e),this}pipe(e,t){return{}}compose(e,t){throw new Error("Method not implemented.")}[Symbol.asyncDispose](){return this.destroy(),Promise.resolve()}async*[Symbol.asyncIterator](){throw o("Readable.asyncIterator")}iterator(e){throw o("Readable.iterator")}map(e,t){throw o("Readable.map")}filter(e,t){throw o("Readable.filter")}forEach(e,t){throw o("Readable.forEach")}reduce(e,t,r){throw o("Readable.reduce")}find(e,t){throw o("Readable.find")}findIndex(e,t){throw o("Readable.findIndex")}some(e,t){throw o("Readable.some")}toArray(e){throw o("Readable.toArray")}every(e,t){throw o("Readable.every")}flatMap(e,t){throw o("Readable.flatMap")}drop(e,t){throw o("Readable.drop")}take(e,t){throw o("Readable.take")}asIndexedPairs(e){throw o("Readable.asIndexedPairs")}}class l extends f{__unenv__={};writable=!0;writableEnded=!1;writableFinished=!1;writableHighWaterMark=0;writableLength=0;writableObjectMode=!1;writableCorked=0;closed=!1;errored=null;writableNeedDrain=!1;destroyed=!1;_data;_encoding="utf8";constructor(e){super()}pipe(e,t){return{}}_write(e,t,r){if(this.writableEnded){r&&r();return}if(this._data===void 0)this._data=e;else{const s=typeof this._data=="string"?h.from(this._data,this._encoding||t||"utf8"):this._data,a=typeof e=="string"?h.from(e,t||this._encoding||"utf8"):e;this._data=h.concat([s,a])}this._encoding=t,r&&r()}_writev(e,t){}_destroy(e,t){}_final(e){}write(e,t,r){const s=typeof t=="string"?this._encoding:"utf8",a=typeof t=="function"?t:typeof r=="function"?r:void 0;return this._write(e,s,a),!0}setDefaultEncoding(e){return this}end(e,t,r){const s=typeof e=="function"?e:typeof t=="function"?t:typeof r=="function"?r:void 0;if(this.writableEnded)return s&&s(),this;const a=e===s?void 0:e;if(a){const u=t===s?void 0:t;this.write(a,u,s)}return this.writableEnded=!0,this.writableFinished=!0,this.emit("close"),this.emit("finish"),this}cork(){}uncork(){}destroy(e){return this.destroyed=!0,delete this._data,this.removeAllListeners(),this}compose(e,t){throw new Error("Method not implemented.")}}const c=class{allowHalfOpen=!0;_destroy;constructor(e=new i,t=new l){Object.assign(this,e),Object.assign(this,t),this._destroy=g(e._destroy,t._destroy)}};function _(){return Object.assign(c.prototype,i.prototype),Object.assign(c.prototype,l.prototype),c}function g(...n){return function(...e){for(const t of n)t(...e)}}const m=_();class A extends m{__unenv__={};bufferSize=0;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!1;localAddress="";localPort=0;remoteAddress="";remoteFamily="";remotePort=0;autoSelectFamilyAttemptedAddresses=[];readyState="readOnly";constructor(e){super()}write(e,t,r){return!1}connect(e,t,r){return this}end(e,t,r){return this}setEncoding(e){return this}pause(){return this}resume(){return this}setTimeout(e,t){return this}setNoDelay(e){return this}setKeepAlive(e,t){return this}address(){return{}}unref(){return this}ref(){return this}destroySoon(){this.destroy()}resetAndDestroy(){const e=new Error("ERR_SOCKET_CLOSED");return e.code="ERR_SOCKET_CLOSED",this.destroy(e),this}}class y extends i{aborted=!1;httpVersion="1.1";httpVersionMajor=1;httpVersionMinor=1;complete=!0;connection;socket;headers={};trailers={};method="GET";url="/";statusCode=200;statusMessage="";closed=!1;errored=null;readable=!1;constructor(e){super(),this.socket=this.connection=e||new A}get rawHeaders(){const e=this.headers,t=[];for(const r in e)if(Array.isArray(e[r]))for(const s of e[r])t.push(r,s);else t.push(r,e[r]);return t}get rawTrailers(){return[]}setTimeout(e,t){return this}get headersDistinct(){return p(this.headers)}get trailersDistinct(){return p(this.trailers)}}function p(n){const e={};for(const[t,r]of Object.entries(n))t&&(e[t]=(Array.isArray(r)?r:[r]).filter(Boolean));return e}class w extends l{statusCode=200;statusMessage="";upgrading=!1;chunkedEncoding=!1;shouldKeepAlive=!1;useChunkedEncodingByDefault=!1;sendDate=!1;finished=!1;headersSent=!1;strictContentLength=!1;connection=null;socket=null;req;_headers={};constructor(e){super(),this.req=e}assignSocket(e){e._httpMessage=this,this.socket=e,this.connection=e,this.emit("socket",e),this._flush()}_flush(){this.flushHeaders()}detachSocket(e){}writeContinue(e){}writeHead(e,t,r){e&&(this.statusCode=e),typeof t=="string"&&(this.statusMessage=t,t=void 0);const s=r||t;if(s&&!Array.isArray(s))for(const a in s)this.setHeader(a,s[a]);return this.headersSent=!0,this}writeProcessing(){}setTimeout(e,t){return this}appendHeader(e,t){e=e.toLowerCase();const r=this._headers[e],s=[...Array.isArray(r)?r:[r],...Array.isArray(t)?t:[t]].filter(Boolean);return this._headers[e]=s.length>1?s:s[0],this}setHeader(e,t){return this._headers[e.toLowerCase()]=t,this}setHeaders(e){for(const[t,r]of Object.entries(e))this.setHeader(t,r);return this}getHeader(e){return this._headers[e.toLowerCase()]}getHeaders(){return this._headers}getHeaderNames(){return Object.keys(this._headers)}hasHeader(e){return e.toLowerCase()in this._headers}removeHeader(e){delete this._headers[e.toLowerCase()]}addTrailers(e){}flushHeaders(){}writeEarlyHints(e,t){typeof t=="function"&&t()}}const E=(()=>{const n=function(){};return n.prototype=Object.create(null),n})();function R(n={}){const e=new E,t=Array.isArray(n)||H(n)?n:Object.entries(n);for(const[r,s]of t)if(s){if(e[r]===void 0){e[r]=s;continue}e[r]=[...Array.isArray(e[r])?e[r]:[e[r]],...Array.isArray(s)?s:[s]]}return e}function H(n){return typeof n?.entries=="function"}function S(n={}){if(n instanceof Headers)return n;const e=new Headers;for(const[t,r]of Object.entries(n))if(r!==void 0){if(Array.isArray(r)){for(const s of r)e.append(t,String(s));continue}e.set(t,String(r))}return e}const C=new Set([101,204,205,304]);async function b(n,e){const t=new y,r=new w(t);t.url=e.url?.toString()||"/";let s;if(!t.url.startsWith("/")){const d=new URL(t.url);s=d.host,t.url=d.pathname+d.search+d.hash}t.method=e.method||"GET",t.headers=R(e.headers||{}),t.headers.host||(t.headers.host=e.host||s||"localhost"),t.connection.encrypted=t.connection.encrypted||e.protocol==="https",t.body=e.body||null,t.__unenv__=e.context,await n(t,r);let a=r._data;(C.has(r.statusCode)||t.method.toUpperCase()==="HEAD")&&(a=null,delete r._headers["content-length"]);const u={status:r.statusCode,statusText:r.statusMessage,headers:r._headers,body:a};return t.destroy(),r.destroy(),u}async function O(n,e,t={}){try{const r=await b(n,{url:e,...t});return new Response(r.body,{status:r.status,statusText:r.statusText,headers:S(r.headers)})}catch(r){return new Response(r.toString(),{status:Number.parseInt(r.statusCode||r.code)||500,statusText:r.statusText})}}export{y as IncomingMessage,w as ServerResponse,b as callNodeRequestHandler,O as fetchNodeRequestHandler};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-mock-http",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"repository": "unjs/node-mock-http",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./dist/index.mjs",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
},
|
|
14
|
-
"./_polyfill/buffer": {
|
|
15
|
-
"import": {
|
|
16
|
-
"node": "./dist/_polyfill/buffer/node.mjs",
|
|
17
|
-
"default": "./dist/_polyfill/buffer/nodeless.mjs"
|
|
18
|
-
},
|
|
19
|
-
"require": {
|
|
20
|
-
"node": "./dist/_polyfill/buffer/node.cjs",
|
|
21
|
-
"default": "./dist/_polyfill/buffer/nodeless.cjs"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"./_polyfill/events": {
|
|
25
|
-
"import": {
|
|
26
|
-
"node": "./dist/_polyfill/events/node.mjs",
|
|
27
|
-
"default": "./dist/_polyfill/events/nodeless.mjs"
|
|
28
|
-
},
|
|
29
|
-
"require": {
|
|
30
|
-
"node": "./dist/_polyfill/events/node.cjs",
|
|
31
|
-
"default": "./dist/_polyfill/events/nodeless.cjs"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "unbuild --minify",
|
|
41
|
-
"dev": "vitest dev --coverage",
|
|
42
|
-
"lint": "eslint . && prettier -c .",
|
|
43
|
-
"lint:fix": "automd && eslint . --fix && prettier -w .",
|
|
44
|
-
"prepack": "pnpm build",
|
|
45
|
-
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
46
|
-
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
47
|
-
"test:types": "tsc --noEmit --skipLibCheck"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/node": "^22.12.0",
|
|
51
|
-
"@vitest/coverage-v8": "^3.0.4",
|
|
52
|
-
"automd": "^0.3.12",
|
|
53
|
-
"changelogen": "^0.5.7",
|
|
54
|
-
"eslint": "^9.19.0",
|
|
55
|
-
"eslint-config-unjs": "^0.4.2",
|
|
56
|
-
"jiti": "^2.4.2",
|
|
57
|
-
"prettier": "^3.4.2",
|
|
58
|
-
"typescript": "^5.7.3",
|
|
59
|
-
"unbuild": "^3.3.1",
|
|
60
|
-
"vitest": "^3.0.4"
|
|
61
|
-
},
|
|
62
|
-
"packageManager": "pnpm@10.2.0"
|
|
63
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
function asArray(input) {
|
|
2
|
-
return Array.isArray(input) ? input : [input];
|
|
3
|
-
}
|
|
4
|
-
const InternalKeySymbol = "_$key";
|
|
5
|
-
function packObject(input, options) {
|
|
6
|
-
const keys = Object.keys(input);
|
|
7
|
-
let [k, v] = keys;
|
|
8
|
-
options = options || {};
|
|
9
|
-
options.key = options.key || k;
|
|
10
|
-
options.value = options.value || v;
|
|
11
|
-
options.resolveKey = options.resolveKey || ((k2) => k2);
|
|
12
|
-
const resolveKey = (index) => {
|
|
13
|
-
const arr = asArray(options[index]);
|
|
14
|
-
return arr.find((k2) => {
|
|
15
|
-
if (typeof k2 === "string" && k2.includes(".")) {
|
|
16
|
-
return k2;
|
|
17
|
-
}
|
|
18
|
-
return k2 && keys.includes(k2);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const resolveValue = (k2, input2) => {
|
|
22
|
-
if (k2.includes(".")) {
|
|
23
|
-
const paths = k2.split(".");
|
|
24
|
-
let val = input2;
|
|
25
|
-
for (const path of paths)
|
|
26
|
-
val = val[path];
|
|
27
|
-
return val;
|
|
28
|
-
}
|
|
29
|
-
return input2[k2];
|
|
30
|
-
};
|
|
31
|
-
k = resolveKey("key") || k;
|
|
32
|
-
v = resolveKey("value") || v;
|
|
33
|
-
const dedupeKeyPrefix = input.key ? `${InternalKeySymbol}${input.key}-` : "";
|
|
34
|
-
let keyValue = resolveValue(k, input);
|
|
35
|
-
keyValue = options.resolveKey(keyValue);
|
|
36
|
-
return {
|
|
37
|
-
[`${dedupeKeyPrefix}${keyValue}`]: resolveValue(v, input)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function packArray(input, options) {
|
|
42
|
-
const packed = {};
|
|
43
|
-
for (const i of input) {
|
|
44
|
-
const packedObj = packObject(i, options);
|
|
45
|
-
const pKey = Object.keys(packedObj)[0];
|
|
46
|
-
const isDedupeKey = pKey.startsWith(InternalKeySymbol);
|
|
47
|
-
if (!isDedupeKey && packed[pKey]) {
|
|
48
|
-
packed[pKey] = Array.isArray(packed[pKey]) ? packed[pKey] : [packed[pKey]];
|
|
49
|
-
packed[pKey].push(Object.values(packedObj)[0]);
|
|
50
|
-
} else {
|
|
51
|
-
packed[isDedupeKey ? pKey.split("-").slice(1).join("-") || pKey : pKey] = packedObj[pKey];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return packed;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function packString(input) {
|
|
58
|
-
const output = {};
|
|
59
|
-
input.split(" ").forEach(
|
|
60
|
-
(item) => {
|
|
61
|
-
const val = item.replace(/"/g, "").split("=");
|
|
62
|
-
output[val[0]] = val[1];
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
return output;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function unpackToArray(input, options) {
|
|
69
|
-
const unpacked = [];
|
|
70
|
-
const kFn = options.resolveKeyData || ((ctx) => ctx.key);
|
|
71
|
-
const vFn = options.resolveValueData || ((ctx) => ctx.value);
|
|
72
|
-
for (const [k, v] of Object.entries(input)) {
|
|
73
|
-
unpacked.push(...(Array.isArray(v) ? v : [v]).map((i) => {
|
|
74
|
-
const ctx = { key: k, value: i };
|
|
75
|
-
const val = vFn(ctx);
|
|
76
|
-
if (typeof val === "object")
|
|
77
|
-
return unpackToArray(val, options);
|
|
78
|
-
if (Array.isArray(val))
|
|
79
|
-
return val;
|
|
80
|
-
return {
|
|
81
|
-
[typeof options.key === "function" ? options.key(ctx) : options.key]: kFn(ctx),
|
|
82
|
-
[typeof options.value === "function" ? options.value(ctx) : options.value]: val
|
|
83
|
-
};
|
|
84
|
-
}).flat());
|
|
85
|
-
}
|
|
86
|
-
return unpacked;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function unpackToString(value, options) {
|
|
90
|
-
return Object.entries(value).map(([key, value2]) => {
|
|
91
|
-
if (typeof value2 === "object")
|
|
92
|
-
value2 = unpackToString(value2, options);
|
|
93
|
-
if (options.resolve) {
|
|
94
|
-
const resolved = options.resolve({ key, value: value2 });
|
|
95
|
-
if (typeof resolved !== "undefined")
|
|
96
|
-
return resolved;
|
|
97
|
-
}
|
|
98
|
-
if (typeof value2 === "number")
|
|
99
|
-
value2 = value2.toString();
|
|
100
|
-
if (typeof value2 === "string" && options.wrapValue) {
|
|
101
|
-
value2 = value2.replace(new RegExp(options.wrapValue, "g"), `\\${options.wrapValue}`);
|
|
102
|
-
value2 = `${options.wrapValue}${value2}${options.wrapValue}`;
|
|
103
|
-
}
|
|
104
|
-
return `${key}${options.keyValueSeparator || ""}${value2}`;
|
|
105
|
-
}).join(options.entrySeparator || "");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { InternalKeySymbol, packArray, packObject, packString, unpackToArray, unpackToString };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "packrup",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.1.2",
|
|
5
|
-
"packageManager": "pnpm@8.15.4",
|
|
6
|
-
"description": "Node Schema.org for Simple and Automated Google Rich Results",
|
|
7
|
-
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"funding": "https://github.com/sponsors/harlan-zw",
|
|
10
|
-
"homepage": "https://github.com/harlan-zw/packrup#readme",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/harlan-zw/packrup.git"
|
|
14
|
-
},
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/harlan-zw/packrup/issues"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"pack object",
|
|
20
|
-
"pack string",
|
|
21
|
-
"pack array"
|
|
22
|
-
],
|
|
23
|
-
"sideEffects": false,
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"types": "./dist/index.d.ts",
|
|
27
|
-
"import": "./dist/index.mjs",
|
|
28
|
-
"require": "./dist/index.cjs"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"main": "dist/index.cjs",
|
|
32
|
-
"module": "dist/index.mjs",
|
|
33
|
-
"types": "dist/index.d.ts",
|
|
34
|
-
"files": [
|
|
35
|
-
"dist"
|
|
36
|
-
],
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@antfu/eslint-config": "^2.8.0",
|
|
39
|
-
"@types/fs-extra": "^11.0.4",
|
|
40
|
-
"@vitest/ui": "^1.3.1",
|
|
41
|
-
"bumpp": "^9.4.0",
|
|
42
|
-
"eslint": "^8.57.0",
|
|
43
|
-
"fs-extra": "^11.2.0",
|
|
44
|
-
"jsdom": "^24.0.0",
|
|
45
|
-
"typescript": "^5.4.2",
|
|
46
|
-
"unbuild": "^2.0.0",
|
|
47
|
-
"utility-types": "^3.11.0",
|
|
48
|
-
"vitest": "^1.3.1"
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "unbuild",
|
|
52
|
-
"stub": "unbuild --stub",
|
|
53
|
-
"test": "vitest",
|
|
54
|
-
"export:sizes": "npx export-size . -r",
|
|
55
|
-
"release": "pnpm build && bumpp && pnpm -r publish --no-git-checks",
|
|
56
|
-
"lint": "eslint . --fix"
|
|
57
|
-
}
|
|
58
|
-
}
|