@basementstudio/mitt-cli 0.0.0-stage → 0.1.0
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/LICENSE +15 -0
- package/dist/index-hem7j25r.js +2 -0
- package/dist/manifest-1m1kmakw.js +5 -0
- package/dist/mitt.js +187 -0
- package/package.json +50 -4
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) 2026 basement.studio. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its source code are proprietary and confidential to
|
|
4
|
+
basement.studio. No license, express or implied, is granted to use, copy,
|
|
5
|
+
modify, merge, publish, distribute, sublicense or sell this software, in
|
|
6
|
+
whole or in part, except under a separate written agreement with
|
|
7
|
+
basement.studio.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
10
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
11
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
12
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
13
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
14
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
15
|
+
SOFTWARE.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var H=Object.defineProperty;var V=(k)=>k;function X(k,q){this[k]=V.bind(null,q)}var I=(k,q)=>{for(var z in q)H(k,z,{get:q[z],enumerable:!0,configurable:!0,set:X.bind(q,z)})};var U=import.meta.require;var $="-dirty",Y=/^[0-9a-f]{7,64}$/,f=/^[0-9a-f]{7,64}(-dirty)?$/,h=/^[0-9a-f]{12}$/,D=/^[a-z0-9][a-z0-9-]{0,63}$/,_=/^[a-z][a-z0-9-]*$/,T=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;import{createHash as j}from"crypto";import{readFileSync as C}from"fs";import{join as m}from"path";var G="mitt.config.json",W="MITT_SECRET",b="**/*.{tsx,jsx}",O="mitt-dev-secret-not-for-production";function w(k){return j("sha256").update(`mitt-fp\x00${k}`).digest("hex").slice(0,16)}function N(k,q,{allowDev:z}){let B=q[k];if(B)return{secret:B,secretEnv:k,devFallback:!1};return z?{secret:O,secretEnv:k,devFallback:!0}:{secret:null,secretEnv:k,devFallback:!1}}function Q(k,q){return Error(`[mitt] ${k}: ${q}`)}function u(k){let q=m(k,G),z;try{z=C(q,"utf8")}catch(Z){if(Z.code==="ENOENT")return{secretEnv:W,project:void 0};throw Z}let B=JSON.parse(z);if(typeof B!=="object"||B===null||Array.isArray(B))throw Q(q,"expected a JSON object");let{secretEnv:K=W,include:J,project:P}=B;if(typeof K!=="string"||!/^[A-Z_][A-Z0-9_]*$/.test(K))throw Q(q,'"secretEnv" must be an environment variable name');if(J!==void 0&&!(Array.isArray(J)&&J.length===1&&J[0]===b))throw Q(q,`"include" only supports ["${b}"] for now`);return{secretEnv:K,project:P}}import{execFileSync as y}from"child_process";import{realpathSync as x}from"fs";import{relative as A,sep as L}from"path";function M(k,q,z={}){return y("git",q,{cwd:k,encoding:z.encoding==="buffer"?void 0:"utf8",input:z.input,maxBuffer:1073741824,stdio:["pipe","pipe","ignore"]})}function g(k){let q=x(M(k,["rev-parse","--show-toplevel"]).trim());return{root:q,appPrefix:A(q,x(k)).split(L).join("/")}}export{I as a,U as b,$ as c,Y as d,f as e,h as f,D as g,_ as h,T as i,G as j,W as k,O as l,w as m,N as n,u as o,M as p,g as q};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{c as y,j as Uq,k as jq,l as Gq,m as Lq,n as Dq,o as Oq,p as A,q as x}from"./index-hem7j25r.js";import{readFileSync as e,realpathSync as qq}from"fs";import{createHmac as w}from"crypto";import N from"magic-string";import{parseSync as f,visitorKeys as S}from"oxc-parser";var h=new Set(["head","script","style","meta","link","title","template","noscript","base"]),u=/^[\w.-]{1,80}$/,l=new Map([["next/image","img"],["next/image.js","img"],["next/legacy/image","img"],["next/legacy/image.js","img"],["next/link","a"],["next/link.js","a"]]),g=/<\s*[a-z]|['"]next\/(?:legacy\/)?(?:image|link)(?:\.js)?['"]/,c=12;function m(q,Q,Z,$){return w("sha256",q).update(`${Q}:${Z}:${$}`).digest("hex").slice(0,c)}function X(q){return typeof q==="object"&&q!==null&&typeof q.type==="string"}function D(q){return X(q)&&q.type==="Identifier"&&typeof q.name==="string"?q.name:null}var d=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]);function p(q,Q){let Z=q[Q];if(!Z)return null;let $=D(Z.id);if($)return $;let J=Q-1,B=q[J];while(B?.type==="CallExpression")J-=1,B=q[J];if(!B)return null;if(B.type==="VariableDeclarator")return D(B.id);if(B.type==="ExportDefaultDeclaration")return"default";if(B.type==="MethodDefinition"){let W=D(B.key);if(!W)return null;let V=D(q[J-2]?.id);return V?`${V}.${W}`:W}return null}function i(q){for(let Q=q.length-1;Q>=0;Q--){let Z=q[Q];if(Z&&d.has(Z.type)){let $=p(q,Q);if($)return $}}return null}function I(q){if(!X(q))return null;if(q.type==="Literal")return typeof q.value==="string"?q.value:null;return D(q)}function s(q){let Q=new Map,Z=Array.isArray(q.body)?q.body:[];for(let $ of Z){if(!X($)||$.type!=="ImportDeclaration")continue;if($.importKind==="type")continue;let J=l.get(I($.source)??"");if(!J||!Array.isArray($.specifiers))continue;for(let B of $.specifiers){if(!X(B)||B.importKind==="type")continue;let W=B.type==="ImportDefaultSpecifier"||B.type==="ImportSpecifier"&&I(B.imported)==="default",V=D(B.local);if(W&&V)Q.set(V,J)}}return Q}function C(q,Q){if(!X(q))return;switch(q.type){case"Identifier":if(typeof q.name==="string")Q.add(q.name);return;case"ObjectPattern":if(Array.isArray(q.properties)){for(let Z of q.properties)if(X(Z))C(Z.type==="Property"?Z.value:Z,Q)}return;case"ArrayPattern":if(Array.isArray(q.elements))for(let Z of q.elements)C(Z,Q);return;case"AssignmentPattern":C(q.left,Q);return;case"RestElement":C(q.argument,Q);return;case"TSParameterProperty":C(q.parameter,Q);return}}function o(q){let Q=new Set,Z=($)=>{if($.type==="ImportDeclaration")return;switch($.type){case"VariableDeclarator":C($.id,Q);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":if(C($.id,Q),Array.isArray($.params))for(let B of $.params)C(B,Q);break;case"ClassDeclaration":case"ClassExpression":case"TSEnumDeclaration":case"TSImportEqualsDeclaration":case"TSModuleDeclaration":C($.id,Q);break;case"CatchClause":C($.param,Q);break}let J=S[$.type];if(!J)return;for(let B of J){let W=$[B];if(Array.isArray(W)){for(let V of W)if(X(V))Z(V)}else if(X(W))Z(W)}};return Z(q),Q}function a(q,Q){let Z=q.name;if(!X(Z)||Z.type!=="JSXIdentifier"||typeof Z.name!=="string")return null;let $=Z.name,J=$.charCodeAt(0);if(J>=97&&J<=122)return $;let B=Q.get($);if(!B)return null;return F(q,"legacyBehavior")?null:B}function F(q,Q){let Z=q.attributes;if(!Array.isArray(Z))return!1;return Z.some(($)=>X($)&&$.type==="JSXAttribute"&&X($.name)&&$.name.type==="JSXIdentifier"&&$.name.name===Q)}function r(q){let Q=[0];for(let Z=q.indexOf(`
|
|
3
|
+
`);Z!==-1;Z=q.indexOf(`
|
|
4
|
+
`,Z+1))Q.push(Z+1);return Q}function n(q,Q){let Z=0,$=q.length-1;while(Z<$){let J=Z+$+1>>1;if((q[J]??0)<=Q)Z=J;else $=J-1}return{line:Z+1,column:Q-(q[Z]??0)}}function t(q){return/\.m?jsx?$/.test(q)?"jsx":"tsx"}function b(q,Q){return Q===void 0?{code:q,map:null,entries:[]}:{code:q,map:null,entries:[],warning:Q}}function R(q,Q){let{relPath:Z,secret:$}=Q,J,B=null;if(Q.commit)if(u.test(Q.commit))B=Q.commit;else J=`[mitt] ignored an unsafe commit value for ${Z}`;if(!g.test(q))return b(q,J);let W;try{let H=f(Z,q,{lang:t(Z),sourceType:"module",preserveParens:!1});if(H.errors.length>0){let Y=H.errors[0]?.message??"unknown error";return b(q,`[mitt] skipped ${Z}: could not parse it (${Y})`)}W=H.program}catch(H){let Y=H instanceof Error?H.message:String(H);return b(q,`[mitt] skipped ${Z}: could not parse it (${Y})`)}let V=new N(q),K=[],z=r(q),L=[],j=X(W)?s(W):new Map;if(j.size>0&&X(W))for(let H of o(W))j.delete(H);let O=(H)=>{let Y=a(H,j);if(!Y||h.has(Y))return;let v=X(H.typeArguments)?H.typeArguments.end:H.name.end,U="";if(!F(H,"data-fb")){let{line:M,column:E}=n(z,H.start),k=m($,Z,M,E);K.push({id:k,file:Z,line:M,column:E,tag:Y,component:i(L)}),U+=` data-fb="${k}"`}if(Y==="html"&&B&&!F(H,"data-fb-commit"))U+=` data-fb-commit="${B}"`;if(U)V.appendLeft(v,U)},G=(H)=>{if(H.type==="JSXOpeningElement")O(H);let Y=S[H.type];if(!Y)return;L.push(H);for(let v of Y){let U=H[v];if(Array.isArray(U)){for(let M of U)if(X(M))G(M)}else if(X(U))G(U)}L.pop()};if(X(W))G(W);if(!V.hasChanged())return b(q,J);let _=Q.sourceMap===!1?null:V.generateMap({hires:!0,source:Q.mapSource??Z,includeContent:!0}),T={code:V.toString(),map:_,entries:K};if(J!==void 0)T.warning=J;return T}var Qq=/\.[jt]sx$/;function P(q){return Qq.test(q)&&!q.split("/").includes("node_modules")}function Zq(q){let Q=A(q,["ls-files","-z","--cached","--others","--exclude-standard"]),Z=[];for(let $ of new Set(Q.split("\x00"))){if(!$||!P($))continue;let J;try{J=e(`${q}/${$}`,"utf8")}catch(B){if(B.code==="ENOENT")continue;throw B}Z.push({relPath:$,source:J})}return Z}function $q(q,Q,Z){let $=Q?[`${Q}/`]:[],B=A(q,["ls-tree","-r","-z","--name-only",Z,"--",...$]).split("\x00").filter((z)=>z&&P(z));if(B.length===0)return[];let W=A(q,["cat-file","--batch"],{input:B.map((z)=>`${Z}:${z}
|
|
5
|
+
`).join(""),encoding:"buffer"}),V=[],K=0;for(let z of B){let L=W.indexOf(10,K),j=W.toString("utf8",K,L),O=Number(j.split(" ")[2]);if(!j.includes(" blob ")||!Number.isInteger(O))throw Error(`[mitt] could not read ${z} at ${Z}: ${j}`);let G=L+1,_=W.toString("utf8",G,G+O);K=G+O+1,V.push({relPath:Q?z.slice(Q.length+1):z,source:_})}return V}function Kq({appRoot:q,commit:Q,secret:Z}){let $=qq(q),J;if(Q===null||Q.endsWith(y))J=Zq($);else{let W=x($);J=$q(W.root,W.appPrefix,Q)}let B=new Map;for(let{relPath:W,source:V}of J)for(let K of R(V,{relPath:W,secret:Z,sourceMap:!1}).entries){let z=B.get(K.id);if(z)throw Error(`[mitt] duplicate data-fb ID ${K.id}: ${z.file}:${z.line} and ${K.file}:${K.line}`);B.set(K.id,K)}return B}export{Lq as secretFingerprint,Dq as resolveSecret,x as repoLayout,Oq as readMittConfig,A as git,Kq as buildManifest,y as DIRTY_SUFFIX,Gq as DEV_SECRET,jq as DEFAULT_SECRET_ENV,Uq as CONFIG_FILE};
|