@donotdev/core 0.0.23 → 0.0.25
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/functions/index.d.ts +45 -4
- package/functions/index.js +79 -15
- package/index.d.ts +1644 -444
- package/index.js +39 -39
- package/next/index.js +26 -26
- package/package.json +9 -20
- package/server.d.ts +10669 -9495
- package/server.js +1 -1
- package/vite/index.js +40 -37
package/functions/index.d.ts
CHANGED
|
@@ -381,12 +381,18 @@ declare function detectSecretsFromEnv(envPath?: string): string[];
|
|
|
381
381
|
/**
|
|
382
382
|
* Generate functions.yaml content from config
|
|
383
383
|
*/
|
|
384
|
-
declare function generateFunctionsYaml(
|
|
384
|
+
declare function generateFunctionsYaml(
|
|
385
|
+
config: FunctionsConfig,
|
|
386
|
+
options?: AutoDetectOptions
|
|
387
|
+
): string;
|
|
385
388
|
|
|
386
389
|
/**
|
|
387
390
|
* Generate yaml and return metadata
|
|
388
391
|
*/
|
|
389
|
-
declare function generateFunctionsYamlWithInfo(
|
|
392
|
+
declare function generateFunctionsYamlWithInfo(
|
|
393
|
+
config: FunctionsConfig,
|
|
394
|
+
options?: AutoDetectOptions
|
|
395
|
+
): {
|
|
390
396
|
yaml: string;
|
|
391
397
|
functions: string[];
|
|
392
398
|
staticFunctions: string[];
|
|
@@ -404,5 +410,40 @@ declare function filterEnvSecrets(config: FunctionsConfig): {
|
|
|
404
410
|
kept: number;
|
|
405
411
|
};
|
|
406
412
|
|
|
407
|
-
|
|
408
|
-
|
|
413
|
+
/** Build options for buildFunctions */
|
|
414
|
+
interface BuildFunctionsOptions {
|
|
415
|
+
/** Entry point file (default: 'src/index.ts') */
|
|
416
|
+
entry?: string;
|
|
417
|
+
/** Output directory (default: 'lib') */
|
|
418
|
+
outDir?: string;
|
|
419
|
+
/** Minify output (default: true in production) */
|
|
420
|
+
minify?: boolean;
|
|
421
|
+
/** Generate source maps (default: true) */
|
|
422
|
+
sourcemap?: boolean;
|
|
423
|
+
/** Print bundle analysis (default: false) */
|
|
424
|
+
analyze?: boolean;
|
|
425
|
+
/** Entry file for auto-detection (default: 'src/index.ts') */
|
|
426
|
+
entryFile?: string;
|
|
427
|
+
/** .env path for secret detection (default: '.env') */
|
|
428
|
+
envPath?: string;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Build Firebase Functions in one call.
|
|
433
|
+
* Handles: esbuild bundling, functions.yaml generation, .env secret filtering.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```js
|
|
437
|
+
* import { buildFunctions } from '@donotdev/core/functions';
|
|
438
|
+
* import { functionsConfig } from './functions.config.js';
|
|
439
|
+
*
|
|
440
|
+
* buildFunctions(functionsConfig);
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
declare function buildFunctions(
|
|
444
|
+
functionsConfig: FunctionsConfig,
|
|
445
|
+
options?: BuildFunctionsOptions
|
|
446
|
+
): Promise<void>;
|
|
447
|
+
|
|
448
|
+
export { buildFunctions, createAppFunctionsConfig, createFunctionsEsbuildConfig, createRootFunctionsConfig, detectExportedFunctions, detectSecretsFromEnv, filterEnvSecrets, generateFunctionsYaml, generateFunctionsYamlWithInfo };
|
|
449
|
+
export type { AutoDetectOptions, BuildFunctionsOptions, EsbuildOptions };
|
package/functions/index.js
CHANGED
|
@@ -1,20 +1,84 @@
|
|
|
1
|
-
import F from"node:fs";import y from"node:path";import{fileURLToPath as re}from"node:url";var se=re(import.meta.url),ye=y.dirname(se);function W(){let c=process.cwd(),e=10;for(let t=0;t<e;t++){let o=y.join(c,"package.json");if(F.existsSync(o))try{let s=JSON.parse(F.readFileSync(o,"utf8")),r=s.workspaces&&Array.isArray(s.workspaces);if(r&&s.workspaces.some(a=>a==="packages/**"||a.startsWith("packages/"))&&(F.existsSync(y.join(c,"packages","core"))||F.existsSync(y.join(c,"packages","functions"))))return{type:"dndev",root:c};if(r&&s.workspaces.some(a=>a.includes("dndev/packages"))){let u=s.workspaces.find(m=>m.includes("dndev/packages")).replace(/\/packages.*$/,""),f=y.resolve(c,u);if(F.existsSync(y.join(f,"packages","core")))return{type:"dndev",root:f}}}catch{}let n=y.dirname(c);if(n===c)break;c=n}return{type:"npm",root:process.cwd()}}function oe(c){return c.type==="dndev"?c.root:null}function U(c){let e={};if(c.type==="dndev"){let t=oe(c);t&&(e["@donotdev/types"]=y.join(t,"packages","core","types","src"),e["@donotdev/functions"]=y.join(t,"packages","functions","src"),e["@donotdev/utils"]=y.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=y.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=y.join(t,"packages","core"))}return e}import*as h from"node:fs";import"node:fs";import{createRequire as ie}from"node:module";import{resolve as z,join as P,dirname as x,relative as H,normalize as ae,sep as Y,extname as ce}from"node:path";import{fileURLToPath as le}from"node:url";import ue from"fast-glob";var O={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},E={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${O.SOURCE_EAGER}/*_*.json`],lazy:[`${O.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]};var B={base:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore}};function G(c,e=null){let t=E[c];if(!t)throw new Error(`Unknown pattern type: ${c}`);return e&&t.framework?{...t,framework:t.framework.map(o=>`${e}/${o}`)}:t}function M(c){return B[c]||B.base}var w={getGlobOptionsFor:M||void 0,SCAN_PATTERNS:E||void 0,getPatternsFor:G||void 0,I18N_PATHS:O||void 0},g={error:(c,e)=>{},warn:(c,e)=>{},info:c=>{}};function V(c,e){return c().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var J={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},$=class c{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return c._instance||(c._instance=new c(e)),c._instance}static _reset(){c._instance=null}constructor(e={}){if(c._instance)return c._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,c._instance=this}normalizePath(e){if(!e)return"";try{return ae(e).split(Y).join("/")}catch{return String(e).split(Y).join("/")}}getRelativePath(e){let t=this.getAppRoot(),o=H(t,e);return this.normalizePath(o)}getBasename(e){if(!e)return"";let o=this.normalizePath(e).split("/");return o[o.length-1]||""}getDirname(e){return e?this.normalizePath(x(e)):""}resolvePackage(e,t=null){try{let o=t||this.getAppRoot(),s=ie(P(o,"package.json")).resolve(e);return this.normalizePath(s)}catch{return null}}resolveFrameworkPackage(e,t=null){let o=this.resolvePackage(`${e}/package.json`,t);if(o)return this.getDirname(o);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let r=e.replace("@donotdev/",""),i=this.resolveRepoPath(`packages/${r}`);if(this.pathExists(i))return i;if(["auth","billing","crud","oauth"].includes(r)){let l=this.resolveRepoPath(`packages/features/${r}`);if(this.pathExists(l))return l}if(r==="firebase"){let l=this.resolveRepoPath(`packages/providers/${r}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(n))return n;let s=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(s)?s:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),o=z(t,e);return this.normalizePath(o)}resolveRepoPath(e){let t=this.getRepoRoot(),o=this.normalizePath(e),n=z(t,o);return this.normalizePath(n)}resolvePath(e,t){let o=this.normalizePath(t),n=this.normalizePath(e),s=z(o,n);return this.normalizePath(s)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=h.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:ce(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return await h.promises.readFile(e);let r=await h.promises.readFile(e,n),i=this.stripBom(r);return s==="json"?JSON.parse(i):i}catch(r){return this.options.debug&&g.warn(`Failed to read file: ${e}`,r),null}}readSync(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return h.readFileSync(e);let r=h.readFileSync(e,n),i=this.stripBom(r);return s==="json"?JSON.parse(i):i}catch(r){return this.options.debug&&g.warn(`Failed to read file: ${e}`,r),null}}async write(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:i=!1}=o,l=this.normalizePath(e),p=this.normalizePath(x(l)),a=this.pathExists(l);if(a&&!s)return i&&g.info(`Skipping existing file: ${l}`),!1;if(r)return g.info(`[DRY RUN] Would write file: ${l}`),!0;try{await h.promises.mkdir(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return await V(async()=>(Buffer.isBuffer(f)?await h.promises.writeFile(l,f):await h.promises.writeFile(l,f,"utf8"),i&&g.info(`${a?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:i=!1}=o,l=this.normalizePath(e),p=this.normalizePath(x(l)),a=this.pathExists(l);if(a&&!s)return i&&g.info(`Skipping existing file: ${l}`),!1;if(r)return g.info(`[DRY RUN] Would write file: ${l}`),!0;try{h.mkdirSync(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return Buffer.isBuffer(f)?h.writeFileSync(l,f):h.writeFileSync(l,f,"utf8"),i&&g.info(`${a?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!n)return r&&g.info(`Skipping existing file: ${i}`),!1;if(s)return g.info(`[DRY RUN] Would copy file: ${i}`),!0;let p=this.normalizePath(x(i));try{await h.promises.mkdir(p,{recursive:!0})}catch(a){if(a?.code!=="EEXIST")throw a}try{return await V(async()=>(await h.promises.copyFile(e,i),r&&g.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!n)return r&&g.info(`Skipping existing file: ${i}`),!1;if(s)return g.info(`[DRY RUN] Would copy file: ${i}`),!0;let p=this.normalizePath(x(i));try{h.mkdirSync(p,{recursive:!0})}catch(a){if(a?.code!=="EEXIST")throw a}try{return h.copyFileSync(e,i),r&&g.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return h.existsSync(e)}catch(o){return t||g.error(`Error checking path existence: ${e}`,o),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return h.existsSync(t)||h.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return h.readdirSync(e,t)}catch(o){return this.options.debug&&g.warn(`Failed to read directory: ${e}`,o),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return h.statSync(e)}catch(t){return this.options.debug&&g.warn(`Failed to stat file: ${e}`,t),null}}lstatSync(e){try{return h.lstatSync(e)}catch(t){return this.options.debug&&g.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await h.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{h.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await h.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){h.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return h.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=P(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(z(e)),o=this.getAppRoot(),n=H(o,t),s=this.normalizePath(n);return!s.startsWith("../")&&!s.startsWith("/")}async findFiles(e,t,o={}){let n=this.normalizePath(P(e,t)),s=this.getAppRoot(),r=this.normalizePath(s),i=n.startsWith(r)?n.slice(r.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:w.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...o})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=w.I18N_PATHS;if(!t)return null;let o=e.replace(t.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let s=this.normalizePath(P(n,t.PUBLISHED_ROOT,o)),r=s.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),s}async _globWithNormalization(e,t){return(await ue(e,t)).map(n=>{let s=typeof n=="string"?n:n.path;return this.normalizePath(s)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let o=[...e.framework,...e.consumer];for(let a of o)if(typeof a!="string"||a.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),s=w.getGlobOptionsFor?w.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(n),i=e.framework.map(a=>{let u=this.normalizePath(a);return u.startsWith(r)?u.slice(r.length+1):u}),l=e.consumer.map(a=>{let u=this.normalizePath(a);return u.startsWith(r)?u.slice(r.length+1):u}),p={...s,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let a=i.length>0?await this._globWithNormalization(i,p):[],u=await this._globWithNormalization(l,p);return{frameworkFiles:a,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!w.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),o=this.getRepoRoot();if(e==="i18n"&&(!t||t===o))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${o}). Ensure configResolved hook has run before discovery.`);let n=w.getPatternsFor(e),s=this.isMonorepo();if(e==="i18n"){let l=n,p={eager:l.eager.map(a=>a.startsWith("!")?"!"+this.resolveAppPath(a.slice(1)):this.resolveAppPath(a)),lazy:l.lazy.map(a=>a.startsWith("!")?"!"+this.resolveAppPath(a.slice(1)):this.resolveAppPath(a)),framework:{eager:s?(l.framework?.eager||[]).map(a=>this.resolveRepoPath(a)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(a=>this._resolveFrameworkI18nPattern(a))).then(a=>a.filter(Boolean)),lazy:s?(l.framework?.lazy||[]).map(a=>this.resolveRepoPath(a)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(a=>this._resolveFrameworkI18nPattern(a))).then(a=>a.filter(Boolean))},all:[]};return p.all=[...p.eager,...p.lazy,...p.framework.eager,...p.framework.lazy],p}let r=n,i={framework:s?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let o=x(le(import.meta.url));return this.normalizePath(P(o,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),o=0,n=this.options.maxLevels;for(;o<n;){let s=this.normalizePath(P(t,J.TOOLING)),r=this.normalizePath(P(t,J.CORE));if(this.pathExists(s)&&this.pathExists(r))return t;let i=P(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(P(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(x(t))===t)return t;let p=this.normalizePath(x(t));if(p===t)break;t=p,o++}return this.normalizePath(e)}};function K(c={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",workspace:r,bundleWorkspaceDeps:i=!1,importFramework:l=!1,external:p=!1,...a}=c,u=$.getInstance(),f=U(r),m={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:o,sourcemap:n,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...a};i&&Object.keys(f).length>0&&(m.alias=Object.fromEntries(Object.entries(f).map(([k,d])=>[k,u.normalizePath(d)]))),m.mainFields=["module","main"],m.conditions=["import","module","node"];let D=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],C=[];if(i)try{let k=r?.root||process.cwd(),d=process.cwd(),v=10;for(let b=0;b<v;b++){let T=u.normalizePath(`${d}/package.json`);if(u.pathExists(T)){let S=u.readSync(T,{format:"json"});if(S&&Array.isArray(S.workspaces)){k=u.normalizePath(d);for(let R of S.workspaces)R==="apps/*"||R==="functions"||!R.includes("*")&&!R.includes("/")&&C.push(R);break}}let A=u.getDirname(d);if(A===d)break;d=A}}catch{}let te={name:"external-node-modules",setup(k){k.onResolve({filter:/^firebase($|\/)/},d=>{if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return null;let v;if(r?.type==="dndev"&&r.root)v=u.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let b=import.meta.url,A=new URL(b).pathname.replace(/^\/([A-Z]:)/i,"$1"),S=u.getDirname(A);v=u.normalizePath(`${S}/firebase-stub.js`)}return{path:v}}),k.onResolve({filter:/.*/},d=>{if(d.kind==="entry-point")return null;if(d.path.match(/@donotdev\/functions\/.+/)&&i&&r?.type==="dndev"){let v=d.path.replace("@donotdev/functions/","");return{path:u.normalizePath(`${r.root}/packages/functions/src/${v}/index.ts`)}}if(d.path==="@donotdev/utils")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:k.resolve("@donotdev/utils/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let v=d.path.replace("@donotdev/utils/","");return{path:u.normalizePath(`${r.root}/packages/core/utils/src/${v}/index.ts`)}}if(d.path==="@donotdev/core")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/server.ts`)}:k.resolve("@donotdev/core/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/core\/.+/)&&i&&r?.type==="dndev"){let v=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${v}.ts`)}}if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return{path:d.path,external:!0};if(d.path.match(/@donotdev\/core\/.+/)&&i&&r?.type==="dndev"){let v=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${v}.ts`)}}if(d.path.startsWith("@donotdev/")||d.path==="valibot"||d.path.startsWith("valibot/"))return null;if(C.length>0){let v=d.path.split("/")[0];if(C.includes(v))return null}return d.path.startsWith(".")||d.path.startsWith("/")?null:{path:d.path,external:!0}})}};if(m.external=[...D,"firebase-admin","firebase-functions"],m.plugins=[te,...m.plugins||[]],m.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...m.define||{}},l&&r.type==="dndev"){let k=r.root,d=u.normalizePath(`${k}/functions/lib`);m.alias={...m.alias,"@donotdev/functions":d}}return s==="framework"&&(m.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),m}import{readFileSync as j,writeFileSync as N,existsSync as I}from"fs";import"path";var L=["create","get","list","listCard","update","delete"];function q(c,e=0){let t=" ".repeat(e),o="";for(let[n,s]of Object.entries(c))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))Object.keys(s).length===0?o+=`${t}${n}: {}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`;for(let a=1;a<i.length;a++){let[u,f]=i[a];o+=`${t} ${u}: ${f}
|
|
7
|
-
`}}
|
|
8
|
-
`}
|
|
9
|
-
|
|
1
|
+
var Zt=Object.create;var ut=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var J=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var nr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ir=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of er(e))!rr.call(t,o)&&o!==r&&ut(t,o,{get:()=>e[o],enumerable:!(n=Qt(e,o))||n.enumerable});return t};var ft=(t,e,r)=>(r=t!=null?Zt(tr(t)):{},ir(e||!t||!t.__esModule?ut(r,"default",{value:t,enumerable:!0}):r,t));var ct=nr((_n,Vt)=>{"use strict";var lt=Object.defineProperty,gr=Object.getOwnPropertyDescriptor,yr=Object.getOwnPropertyNames,vr=Object.prototype.hasOwnProperty,wr=(t,e)=>{for(var r in e)lt(t,r,{get:e[r],enumerable:!0})},br=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yr(e))!vr.call(t,o)&&o!==r&<(t,o,{get:()=>e[o],enumerable:!(n=gr(e,o))||n.enumerable});return t},xr=t=>br(lt({},"__esModule",{value:!0}),t),Ce={};wr(Ce,{analyzeMetafile:()=>Kr,analyzeMetafileSync:()=>en,build:()=>Hr,buildSync:()=>Xr,context:()=>qr,default:()=>on,formatMessages:()=>Jr,formatMessagesSync:()=>Qr,initialize:()=>rn,stop:()=>tn,transform:()=>Vr,transformSync:()=>Zr,version:()=>Yr});Vt.exports=xr(Ce);function St(t){let e=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(se(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let o of n)e(o)}else{let o=Object.keys(n);r.write8(6),r.write32(o.length);for(let s of o)r.write(se(s)),e(n[s])}},r=new Ct;return r.write32(0),r.write32(t.id<<1|+!t.isRequest),e(t.value),ot(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function kr(t){let e=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return De(r.read());case 4:return r.read();case 5:{let i=r.read32(),c=[];for(let a=0;a<i;a++)c.push(e());return c}case 6:{let i=r.read32(),c={};for(let a=0;a<i;a++)c[De(r.read())]=e();return c}default:throw new Error("Invalid packet")}},r=new Ct(t),n=r.read32(),o=(n&1)===0;n>>>=1;let s=e();if(r.ptr!==t.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:s}}var Ct=class{constructor(t=new Uint8Array(1024)){this.buf=t,this.len=0,this.ptr=0}_write(t){if(this.len+t>this.buf.length){let e=new Uint8Array((this.len+t)*2);e.set(this.buf),this.buf=e}return this.len+=t,this.len-t}write8(t){let e=this._write(1);this.buf[e]=t}write32(t){let e=this._write(4);ot(this.buf,t,e)}write(t){let e=this._write(4+t.length);ot(this.buf,t.length,e),this.buf.set(t,e+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return Tt(this.buf,this._read(4))}read(){let t=this.read32(),e=new Uint8Array(t),r=this._read(e.length);return e.set(this.buf.subarray(r,r+t)),e}},se,De,it;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let t=new TextEncoder,e=new TextDecoder;se=r=>t.encode(r),De=r=>e.decode(r),it='new TextEncoder().encode("")'}else if(typeof Buffer<"u")se=t=>Buffer.from(t),De=t=>{let{buffer:e,byteOffset:r,byteLength:n}=t;return Buffer.from(e,r,n).toString()},it='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(se("")instanceof Uint8Array))throw new Error(`Invariant violation: "${it} instanceof Uint8Array" is incorrectly false
|
|
2
|
+
|
|
3
|
+
This indicates that your JavaScript environment is broken. You cannot use
|
|
4
|
+
esbuild in this environment because esbuild relies on this invariant. This
|
|
5
|
+
is not a problem with esbuild. You need to fix your environment instead.
|
|
6
|
+
`);function Tt(t,e){return t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24}function ot(t,e,r){t[r++]=e,t[r++]=e>>8,t[r++]=e>>16,t[r++]=e>>24}var q=JSON.stringify,Pt="warning",$t="silent";function Se(t,e){let r=[];for(let n of t){if(Q(n,e),n.indexOf(",")>=0)throw new Error(`Invalid ${e}: ${n}`);r.push(n)}return r.join(",")}var Ye=()=>null,G=t=>typeof t=="boolean"?null:"a boolean",E=t=>typeof t=="string"?null:"a string",He=t=>t instanceof RegExp?null:"a RegExp object",ve=t=>typeof t=="number"&&t===(t|0)?null:"an integer",Er=t=>typeof t=="number"&&t===(t|0)&&t>=0&&t<=65535?null:"a valid port number",It=t=>typeof t=="function"?null:"a function",de=t=>Array.isArray(t)?null:"an array",ee=t=>Array.isArray(t)&&t.every(e=>typeof e=="string")?null:"an array of strings",te=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)?null:"an object",Sr=t=>typeof t=="object"&&t!==null?null:"an array or an object",Pr=t=>t instanceof WebAssembly.Module?null:"a WebAssembly.Module",At=t=>typeof t=="object"&&!Array.isArray(t)?null:"an object or null",zt=t=>typeof t=="string"||typeof t=="boolean"?null:"a string or a boolean",$r=t=>typeof t=="string"||typeof t=="object"&&t!==null&&!Array.isArray(t)?null:"a string or an object",Lt=t=>typeof t=="string"||Array.isArray(t)&&t.every(e=>typeof e=="string")?null:"a string or an array of strings",Nt=t=>typeof t=="string"||t instanceof Uint8Array?null:"a string or a Uint8Array",Ar=t=>typeof t=="string"||t instanceof URL?null:"a string or a URL";function l(t,e,r,n){let o=t[r];if(e[r+""]=!0,o===void 0)return;let s=n(o);if(s!==null)throw new Error(`${q(r)} must be ${s}`);return o}function H(t,e,r){for(let n in t)if(!(n in e))throw new Error(`Invalid option ${r}: ${q(n)}`)}function Fr(t){let e=Object.create(null),r=l(t,e,"wasmURL",Ar),n=l(t,e,"wasmModule",Pr),o=l(t,e,"worker",G);return H(t,e,"in initialize() call"),{wasmURL:r,wasmModule:n,worker:o}}function Mt(t){let e;if(t!==void 0){e=Object.create(null);for(let r in t){let n=t[r];if(typeof n=="string"||n===!1)e[r]=n;else throw new Error(`Expected ${q(r)} in mangle cache to map to either a string or false`)}}return e}function Xe(t,e,r,n,o){let s=l(e,r,"color",G),i=l(e,r,"logLevel",E),c=l(e,r,"logLimit",ve);s!==void 0?t.push(`--color=${s}`):n&&t.push("--color=true"),t.push(`--log-level=${i||o}`),t.push(`--log-limit=${c||0}`)}function Q(t,e,r){if(typeof t!="string")throw new Error(`Expected value for ${e}${r!==void 0?" "+q(r):""} to be a string, got ${typeof t} instead`);return t}function Bt(t,e,r){let n=l(e,r,"legalComments",E),o=l(e,r,"sourceRoot",E),s=l(e,r,"sourcesContent",G),i=l(e,r,"target",Lt),c=l(e,r,"format",E),a=l(e,r,"globalName",E),f=l(e,r,"mangleProps",He),u=l(e,r,"reserveProps",He),d=l(e,r,"mangleQuoted",G),y=l(e,r,"minify",G),k=l(e,r,"minifySyntax",G),M=l(e,r,"minifyWhitespace",G),U=l(e,r,"minifyIdentifiers",G),_=l(e,r,"lineLimit",ve),I=l(e,r,"drop",ee),b=l(e,r,"dropLabels",ee),w=l(e,r,"charset",E),v=l(e,r,"treeShaking",G),m=l(e,r,"ignoreAnnotations",G),p=l(e,r,"jsx",E),P=l(e,r,"jsxFactory",E),A=l(e,r,"jsxFragment",E),C=l(e,r,"jsxImportSource",E),R=l(e,r,"jsxDev",G),h=l(e,r,"jsxSideEffects",G),g=l(e,r,"define",te),$=l(e,r,"logOverride",te),O=l(e,r,"supported",te),T=l(e,r,"pure",ee),j=l(e,r,"keepNames",G),F=l(e,r,"platform",E),D=l(e,r,"tsconfigRaw",$r),W=l(e,r,"absPaths",ee);if(n&&t.push(`--legal-comments=${n}`),o!==void 0&&t.push(`--source-root=${o}`),s!==void 0&&t.push(`--sources-content=${s}`),i&&t.push(`--target=${Se(Array.isArray(i)?i:[i],"target")}`),c&&t.push(`--format=${c}`),a&&t.push(`--global-name=${a}`),F&&t.push(`--platform=${F}`),D&&t.push(`--tsconfig-raw=${typeof D=="string"?D:JSON.stringify(D)}`),y&&t.push("--minify"),k&&t.push("--minify-syntax"),M&&t.push("--minify-whitespace"),U&&t.push("--minify-identifiers"),_&&t.push(`--line-limit=${_}`),w&&t.push(`--charset=${w}`),v!==void 0&&t.push(`--tree-shaking=${v}`),m&&t.push("--ignore-annotations"),I)for(let x of I)t.push(`--drop:${Q(x,"drop")}`);if(b&&t.push(`--drop-labels=${Se(b,"drop label")}`),W&&t.push(`--abs-paths=${Se(W,"abs paths")}`),f&&t.push(`--mangle-props=${qe(f)}`),u&&t.push(`--reserve-props=${qe(u)}`),d!==void 0&&t.push(`--mangle-quoted=${d}`),p&&t.push(`--jsx=${p}`),P&&t.push(`--jsx-factory=${P}`),A&&t.push(`--jsx-fragment=${A}`),C&&t.push(`--jsx-import-source=${C}`),R&&t.push("--jsx-dev"),h&&t.push("--jsx-side-effects"),g)for(let x in g){if(x.indexOf("=")>=0)throw new Error(`Invalid define: ${x}`);t.push(`--define:${x}=${Q(g[x],"define",x)}`)}if($)for(let x in $){if(x.indexOf("=")>=0)throw new Error(`Invalid log override: ${x}`);t.push(`--log-override:${x}=${Q($[x],"log override",x)}`)}if(O)for(let x in O){if(x.indexOf("=")>=0)throw new Error(`Invalid supported: ${x}`);let B=O[x];if(typeof B!="boolean")throw new Error(`Expected value for supported ${q(x)} to be a boolean, got ${typeof B} instead`);t.push(`--supported:${x}=${B}`)}if(T)for(let x of T)t.push(`--pure:${Q(x,"pure")}`);j&&t.push("--keep-names")}function Rr(t,e,r,n,o){var s;let i=[],c=[],a=Object.create(null),f=null,u=null;Xe(i,e,a,r,n),Bt(i,e,a);let d=l(e,a,"sourcemap",zt),y=l(e,a,"bundle",G),k=l(e,a,"splitting",G),M=l(e,a,"preserveSymlinks",G),U=l(e,a,"metafile",G),_=l(e,a,"outfile",E),I=l(e,a,"outdir",E),b=l(e,a,"outbase",E),w=l(e,a,"tsconfig",E),v=l(e,a,"resolveExtensions",ee),m=l(e,a,"nodePaths",ee),p=l(e,a,"mainFields",ee),P=l(e,a,"conditions",ee),A=l(e,a,"external",ee),C=l(e,a,"packages",E),R=l(e,a,"alias",te),h=l(e,a,"loader",te),g=l(e,a,"outExtension",te),$=l(e,a,"publicPath",E),O=l(e,a,"entryNames",E),T=l(e,a,"chunkNames",E),j=l(e,a,"assetNames",E),F=l(e,a,"inject",ee),D=l(e,a,"banner",te),W=l(e,a,"footer",te),x=l(e,a,"entryPoints",Sr),B=l(e,a,"absWorkingDir",E),L=l(e,a,"stdin",te),z=(s=l(e,a,"write",G))!=null?s:o,Z=l(e,a,"allowOverwrite",G),Y=l(e,a,"mangleCache",te);if(a.plugins=!0,H(e,a,`in ${t}() call`),d&&i.push(`--sourcemap${d===!0?"":`=${d}`}`),y&&i.push("--bundle"),Z&&i.push("--allow-overwrite"),k&&i.push("--splitting"),M&&i.push("--preserve-symlinks"),U&&i.push("--metafile"),_&&i.push(`--outfile=${_}`),I&&i.push(`--outdir=${I}`),b&&i.push(`--outbase=${b}`),w&&i.push(`--tsconfig=${w}`),C&&i.push(`--packages=${C}`),v&&i.push(`--resolve-extensions=${Se(v,"resolve extension")}`),$&&i.push(`--public-path=${$}`),O&&i.push(`--entry-names=${O}`),T&&i.push(`--chunk-names=${T}`),j&&i.push(`--asset-names=${j}`),p&&i.push(`--main-fields=${Se(p,"main field")}`),P&&i.push(`--conditions=${Se(P,"condition")}`),A)for(let S of A)i.push(`--external:${Q(S,"external")}`);if(R)for(let S in R){if(S.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${S}`);i.push(`--alias:${S}=${Q(R[S],"alias",S)}`)}if(D)for(let S in D){if(S.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${S}`);i.push(`--banner:${S}=${Q(D[S],"banner",S)}`)}if(W)for(let S in W){if(S.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${S}`);i.push(`--footer:${S}=${Q(W[S],"footer",S)}`)}if(F)for(let S of F)i.push(`--inject:${Q(S,"inject")}`);if(h)for(let S in h){if(S.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${S}`);i.push(`--loader:${S}=${Q(h[S],"loader",S)}`)}if(g)for(let S in g){if(S.indexOf("=")>=0)throw new Error(`Invalid out extension: ${S}`);i.push(`--out-extension:${S}=${Q(g[S],"out extension",S)}`)}if(x)if(Array.isArray(x))for(let S=0,ce=x.length;S<ce;S++){let re=x[S];if(typeof re=="object"&&re!==null){let ae=Object.create(null),ue=l(re,ae,"in",E),ne=l(re,ae,"out",E);if(H(re,ae,"in entry point at index "+S),ue===void 0)throw new Error('Missing property "in" for entry point at index '+S);if(ne===void 0)throw new Error('Missing property "out" for entry point at index '+S);c.push([ne,ue])}else c.push(["",Q(re,"entry point at index "+S)])}else for(let S in x)c.push([S,Q(x[S],"entry point",S)]);if(L){let S=Object.create(null),ce=l(L,S,"contents",Nt),re=l(L,S,"resolveDir",E),ae=l(L,S,"sourcefile",E),ue=l(L,S,"loader",E);H(L,S,'in "stdin" object'),ae&&i.push(`--sourcefile=${ae}`),ue&&i.push(`--loader=${ue}`),re&&(u=re),typeof ce=="string"?f=se(ce):ce instanceof Uint8Array&&(f=ce)}let le=[];if(m)for(let S of m)S+="",le.push(S);return{entries:c,flags:i,write:z,stdinContents:f,stdinResolveDir:u,absWorkingDir:B,nodePaths:le,mangleCache:Mt(Y)}}function _r(t,e,r,n){let o=[],s=Object.create(null);Xe(o,e,s,r,n),Bt(o,e,s);let i=l(e,s,"sourcemap",zt),c=l(e,s,"sourcefile",E),a=l(e,s,"loader",E),f=l(e,s,"banner",E),u=l(e,s,"footer",E),d=l(e,s,"mangleCache",te);return H(e,s,`in ${t}() call`),i&&o.push(`--sourcemap=${i===!0?"external":i}`),c&&o.push(`--sourcefile=${c}`),a&&o.push(`--loader=${a}`),f&&o.push(`--banner=${f}`),u&&o.push(`--footer=${u}`),{flags:o,mangleCache:Mt(d)}}function Ut(t){let e={},r={didClose:!1,reason:""},n={},o=0,s=0,i=new Uint8Array(16*1024),c=0,a=w=>{let v=c+w.length;if(v>i.length){let p=new Uint8Array(v*2);p.set(i),i=p}i.set(w,c),c+=w.length;let m=0;for(;m+4<=c;){let p=Tt(i,m);if(m+4+p>c)break;m+=4,M(i.subarray(m,m+p)),m+=p}m>0&&(i.copyWithin(0,m,c),c-=m)},f=w=>{r.didClose=!0,w&&(r.reason=": "+(w.message||w));let v="The service was stopped"+r.reason;for(let m in n)n[m](v,null);n={}},u=(w,v,m)=>{if(r.didClose)return m("The service is no longer running"+r.reason,null);let p=o++;n[p]=(P,A)=>{try{m(P,A)}finally{w&&w.unref()}},w&&w.ref(),t.writeToStdin(St({id:p,isRequest:!0,value:v}))},d=(w,v)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);t.writeToStdin(St({id:w,isRequest:!1,value:v}))},y=async(w,v)=>{try{if(v.command==="ping"){d(w,{});return}if(typeof v.key=="number"){let m=e[v.key];if(!m)return;let p=m[v.command];if(p){await p(w,v);return}}throw new Error("Invalid command: "+v.command)}catch(m){let p=[ye(m,t,null,void 0,"")];try{d(w,{errors:p})}catch{}}},k=!0,M=w=>{if(k){k=!1;let m=String.fromCharCode(...w);if(m!=="0.27.3")throw new Error(`Cannot start service: Host version "0.27.3" does not match binary version ${q(m)}`);return}let v=kr(w);if(v.isRequest)y(v.id,v.value);else{let m=n[v.id];delete n[v.id],v.value.error?m(v.value.error,{}):m(null,v.value)}};return{readFromStdout:a,afterClose:f,service:{buildOrContext:({callName:w,refs:v,options:m,isTTY:p,defaultWD:P,callback:A})=>{let C=0,R=s++,h={},g={ref(){++C===1&&v&&v.ref()},unref(){--C===0&&(delete e[R],v&&v.unref())}};e[R]=h,g.ref(),Or(w,R,u,d,g,t,h,m,p,P,($,O)=>{try{A($,O)}finally{g.unref()}})},transform:({callName:w,refs:v,input:m,options:p,isTTY:P,fs:A,callback:C})=>{let R=Wt(),h=g=>{try{if(typeof m!="string"&&!(m instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:$,mangleCache:O}=_r(w,p,P,$t),T={command:"transform",flags:$,inputFS:g!==null,input:g!==null?se(g):typeof m=="string"?se(m):m};O&&(T.mangleCache=O),u(v,T,(j,F)=>{if(j)return C(new Error(j),null);let D=Pe(F.errors,R),W=Pe(F.warnings,R),x=1,B=()=>{if(--x===0){let L={warnings:W,code:F.code,map:F.map,mangleCache:void 0,legalComments:void 0};"legalComments"in F&&(L.legalComments=F?.legalComments),F.mangleCache&&(L.mangleCache=F?.mangleCache),C(null,L)}};if(D.length>0)return C(_e("Transform failed",D,W),null);F.codeFS&&(x++,A.readFile(F.code,(L,z)=>{L!==null?C(L,null):(F.code=z,B())})),F.mapFS&&(x++,A.readFile(F.map,(L,z)=>{L!==null?C(L,null):(F.map=z,B())})),B()})}catch($){let O=[];try{Xe(O,p,{},P,$t)}catch{}let T=ye($,t,R,void 0,"");u(v,{command:"error",flags:O,error:T},()=>{T.detail=R.load(T.detail),C(_e("Transform failed",[T],[]),null)})}};if((typeof m=="string"||m instanceof Uint8Array)&&m.length>1024*1024){let g=h;h=()=>A.writeFile(m,g)}h(null)},formatMessages:({callName:w,refs:v,messages:m,options:p,callback:P})=>{if(!p)throw new Error(`Missing second argument in ${w}() call`);let A={},C=l(p,A,"kind",E),R=l(p,A,"color",G),h=l(p,A,"terminalWidth",ve);if(H(p,A,`in ${w}() call`),C===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let g={command:"format-msgs",messages:pe(m,"messages",null,"",h),isWarning:C==="warning"};R!==void 0&&(g.color=R),h!==void 0&&(g.terminalWidth=h),u(v,g,($,O)=>{if($)return P(new Error($),null);P(null,O.messages)})},analyzeMetafile:({callName:w,refs:v,metafile:m,options:p,callback:P})=>{p===void 0&&(p={});let A={},C=l(p,A,"color",G),R=l(p,A,"verbose",G);H(p,A,`in ${w}() call`);let h={command:"analyze-metafile",metafile:m};C!==void 0&&(h.color=C),R!==void 0&&(h.verbose=R),u(v,h,(g,$)=>{if(g)return P(new Error(g),null);P(null,$.result)})}}}}function Or(t,e,r,n,o,s,i,c,a,f,u){let d=Wt(),y=t==="context",k=(_,I)=>{let b=[];try{Xe(b,c,{},a,Pt)}catch{}let w=ye(_,s,d,void 0,I);r(o,{command:"error",flags:b,error:w},()=>{w.detail=d.load(w.detail),u(_e(y?"Context failed":"Build failed",[w],[]),null)})},M;if(typeof c=="object"){let _=c.plugins;if(_!==void 0){if(!Array.isArray(_))return k(new Error('"plugins" must be an array'),"");M=_}}if(M&&M.length>0){if(s.isSync)return k(new Error("Cannot use plugins in synchronous API calls"),"");jr(e,r,n,o,s,i,c,M,d).then(_=>{if(!_.ok)return k(_.error,_.pluginName);try{U(_.requestPlugins,_.runOnEndCallbacks,_.scheduleOnDisposeCallbacks)}catch(I){k(I,"")}},_=>k(_,""));return}try{U(null,(_,I)=>I([],[]),()=>{})}catch(_){k(_,"")}function U(_,I,b){let w=s.hasFS,{entries:v,flags:m,write:p,stdinContents:P,stdinResolveDir:A,absWorkingDir:C,nodePaths:R,mangleCache:h}=Rr(t,c,a,Pt,w);if(p&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let g={command:"build",key:e,entries:v,flags:m,write:p,stdinContents:P,stdinResolveDir:A,absWorkingDir:C||f,nodePaths:R,context:y};_&&(g.plugins=_),h&&(g.mangleCache=h);let $=(j,F)=>{let D={errors:Pe(j.errors,d),warnings:Pe(j.warnings,d),outputFiles:void 0,metafile:void 0,mangleCache:void 0},W=D.errors.slice(),x=D.warnings.slice();j.outputFiles&&(D.outputFiles=j.outputFiles.map(Cr)),j.metafile&&(D.metafile=JSON.parse(j.metafile)),j.mangleCache&&(D.mangleCache=j.mangleCache),j.writeToStdout,I(D,(B,L)=>{if(W.length>0||B.length>0){let z=_e("Build failed",W.concat(B),x.concat(L));return F(z,null,B,L)}F(null,D,B,L)})},O,T;y&&(i["on-end"]=(j,F)=>new Promise(D=>{$(F,(W,x,B,L)=>{let z={errors:B,warnings:L};T&&T(W,x),O=void 0,T=void 0,n(j,z),D()})})),r(o,g,(j,F)=>{if(j)return u(new Error(j),null);if(!y)return $(F,(x,B)=>(b(),u(x,B)));if(F.errors.length>0)return u(_e("Context failed",F.errors,F.warnings),null);let D=!1,W={rebuild:()=>(O||(O=new Promise((x,B)=>{let L;T=(Z,Y)=>{L||(L=()=>Z?B(Z):x(Y))};let z=()=>{r(o,{command:"rebuild",key:e},(Y,le)=>{Y?B(new Error(Y)):L?L():z()})};z()})),O),watch:(x={})=>new Promise((B,L)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');let z={},Z=l(x,z,"delay",ve);H(x,z,"in watch() call");let Y={command:"watch",key:e};Z&&(Y.delay=Z),r(o,Y,le=>{le?L(new Error(le)):B(void 0)})}),serve:(x={})=>new Promise((B,L)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let z={},Z=l(x,z,"port",Er),Y=l(x,z,"host",E),le=l(x,z,"servedir",E),S=l(x,z,"keyfile",E),ce=l(x,z,"certfile",E),re=l(x,z,"fallback",E),ae=l(x,z,"cors",te),ue=l(x,z,"onRequest",It);H(x,z,"in serve() call");let ne={command:"serve",key:e,onRequest:!!ue};if(Z!==void 0&&(ne.port=Z),Y!==void 0&&(ne.host=Y),le!==void 0&&(ne.servedir=le),S!==void 0&&(ne.keyfile=S),ce!==void 0&&(ne.certfile=ce),re!==void 0&&(ne.fallback=re),ae){let $e={},ke=l(ae,$e,"origin",Lt);H(ae,$e,'on "cors" object'),Array.isArray(ke)?ne.corsOrigin=ke:ke!==void 0&&(ne.corsOrigin=[ke])}r(o,ne,($e,ke)=>{if($e)return L(new Error($e));ue&&(i["serve-request"]=(Kt,Xt)=>{ue(Xt.args),n(Kt,{})}),B(ke)})}),cancel:()=>new Promise(x=>{if(D)return x();r(o,{command:"cancel",key:e},()=>{x()})}),dispose:()=>new Promise(x=>{if(D)return x();D=!0,r(o,{command:"dispose",key:e},()=>{x(),b(),o.unref()})})};o.ref(),u(null,W)})}}var jr=async(t,e,r,n,o,s,i,c,a)=>{let f=[],u=[],d={},y={},k=[],M=0,U=0,_=[],I=!1;c=[...c];for(let v of c){let m={};if(typeof v!="object")throw new Error(`Plugin at index ${U} must be an object`);let p=l(v,m,"name",E);if(typeof p!="string"||p==="")throw new Error(`Plugin at index ${U} is missing a name`);try{let P=l(v,m,"setup",It);if(typeof P!="function")throw new Error("Plugin is missing a setup function");H(v,m,`on plugin ${q(p)}`);let A={name:p,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};U++;let R=P({initialOptions:i,resolve:(h,g={})=>{if(!I)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof h!="string")throw new Error("The path to resolve must be a string");let $=Object.create(null),O=l(g,$,"pluginName",E),T=l(g,$,"importer",E),j=l(g,$,"namespace",E),F=l(g,$,"resolveDir",E),D=l(g,$,"kind",E),W=l(g,$,"pluginData",Ye),x=l(g,$,"with",te);return H(g,$,"in resolve() call"),new Promise((B,L)=>{let z={command:"resolve",path:h,key:t,pluginName:p};if(O!=null&&(z.pluginName=O),T!=null&&(z.importer=T),j!=null&&(z.namespace=j),F!=null&&(z.resolveDir=F),D!=null)z.kind=D;else throw new Error('Must specify "kind" when calling "resolve"');W!=null&&(z.pluginData=a.store(W)),x!=null&&(z.with=Dr(x,"with")),e(n,z,(Z,Y)=>{Z!==null?L(new Error(Z)):B({errors:Pe(Y.errors,a),warnings:Pe(Y.warnings,a),path:Y.path,external:Y.external,sideEffects:Y.sideEffects,namespace:Y.namespace,suffix:Y.suffix,pluginData:a.load(Y.pluginData)})})})},onStart(h){let g='This error came from the "onStart" callback registered here:',$=We(new Error(g),o,"onStart");f.push({name:p,callback:h,note:$}),A.onStart=!0},onEnd(h){let g='This error came from the "onEnd" callback registered here:',$=We(new Error(g),o,"onEnd");u.push({name:p,callback:h,note:$}),A.onEnd=!0},onResolve(h,g){let $='This error came from the "onResolve" callback registered here:',O=We(new Error($),o,"onResolve"),T={},j=l(h,T,"filter",He),F=l(h,T,"namespace",E);if(H(h,T,`in onResolve() call for plugin ${q(p)}`),j==null)throw new Error("onResolve() call is missing a filter");let D=M++;d[D]={name:p,callback:g,note:O},A.onResolve.push({id:D,filter:qe(j),namespace:F||""})},onLoad(h,g){let $='This error came from the "onLoad" callback registered here:',O=We(new Error($),o,"onLoad"),T={},j=l(h,T,"filter",He),F=l(h,T,"namespace",E);if(H(h,T,`in onLoad() call for plugin ${q(p)}`),j==null)throw new Error("onLoad() call is missing a filter");let D=M++;y[D]={name:p,callback:g,note:O},A.onLoad.push({id:D,filter:qe(j),namespace:F||""})},onDispose(h){k.push(h)},esbuild:o.esbuild});R&&await R,_.push(A)}catch(P){return{ok:!1,error:P,pluginName:p}}}s["on-start"]=async(v,m)=>{a.clear();let p={errors:[],warnings:[]};await Promise.all(f.map(async({name:P,callback:A,note:C})=>{try{let R=await A();if(R!=null){if(typeof R!="object")throw new Error(`Expected onStart() callback in plugin ${q(P)} to return an object`);let h={},g=l(R,h,"errors",de),$=l(R,h,"warnings",de);H(R,h,`from onStart() callback in plugin ${q(P)}`),g!=null&&p.errors.push(...pe(g,"errors",a,P,void 0)),$!=null&&p.warnings.push(...pe($,"warnings",a,P,void 0))}}catch(R){p.errors.push(ye(R,o,a,C&&C(),P))}})),r(v,p)},s["on-resolve"]=async(v,m)=>{let p={},P="",A,C;for(let R of m.ids)try{({name:P,callback:A,note:C}=d[R]);let h=await A({path:m.path,importer:m.importer,namespace:m.namespace,resolveDir:m.resolveDir,kind:m.kind,pluginData:a.load(m.pluginData),with:m.with});if(h!=null){if(typeof h!="object")throw new Error(`Expected onResolve() callback in plugin ${q(P)} to return an object`);let g={},$=l(h,g,"pluginName",E),O=l(h,g,"path",E),T=l(h,g,"namespace",E),j=l(h,g,"suffix",E),F=l(h,g,"external",G),D=l(h,g,"sideEffects",G),W=l(h,g,"pluginData",Ye),x=l(h,g,"errors",de),B=l(h,g,"warnings",de),L=l(h,g,"watchFiles",ee),z=l(h,g,"watchDirs",ee);H(h,g,`from onResolve() callback in plugin ${q(P)}`),p.id=R,$!=null&&(p.pluginName=$),O!=null&&(p.path=O),T!=null&&(p.namespace=T),j!=null&&(p.suffix=j),F!=null&&(p.external=F),D!=null&&(p.sideEffects=D),W!=null&&(p.pluginData=a.store(W)),x!=null&&(p.errors=pe(x,"errors",a,P,void 0)),B!=null&&(p.warnings=pe(B,"warnings",a,P,void 0)),L!=null&&(p.watchFiles=Ge(L,"watchFiles")),z!=null&&(p.watchDirs=Ge(z,"watchDirs"));break}}catch(h){p={id:R,errors:[ye(h,o,a,C&&C(),P)]};break}r(v,p)},s["on-load"]=async(v,m)=>{let p={},P="",A,C;for(let R of m.ids)try{({name:P,callback:A,note:C}=y[R]);let h=await A({path:m.path,namespace:m.namespace,suffix:m.suffix,pluginData:a.load(m.pluginData),with:m.with});if(h!=null){if(typeof h!="object")throw new Error(`Expected onLoad() callback in plugin ${q(P)} to return an object`);let g={},$=l(h,g,"pluginName",E),O=l(h,g,"contents",Nt),T=l(h,g,"resolveDir",E),j=l(h,g,"pluginData",Ye),F=l(h,g,"loader",E),D=l(h,g,"errors",de),W=l(h,g,"warnings",de),x=l(h,g,"watchFiles",ee),B=l(h,g,"watchDirs",ee);H(h,g,`from onLoad() callback in plugin ${q(P)}`),p.id=R,$!=null&&(p.pluginName=$),O instanceof Uint8Array?p.contents=O:O!=null&&(p.contents=se(O)),T!=null&&(p.resolveDir=T),j!=null&&(p.pluginData=a.store(j)),F!=null&&(p.loader=F),D!=null&&(p.errors=pe(D,"errors",a,P,void 0)),W!=null&&(p.warnings=pe(W,"warnings",a,P,void 0)),x!=null&&(p.watchFiles=Ge(x,"watchFiles")),B!=null&&(p.watchDirs=Ge(B,"watchDirs"));break}}catch(h){p={id:R,errors:[ye(h,o,a,C&&C(),P)]};break}r(v,p)};let b=(v,m)=>m([],[]);u.length>0&&(b=(v,m)=>{(async()=>{let p=[],P=[];for(let{name:A,callback:C,note:R}of u){let h,g;try{let $=await C(v);if($!=null){if(typeof $!="object")throw new Error(`Expected onEnd() callback in plugin ${q(A)} to return an object`);let O={},T=l($,O,"errors",de),j=l($,O,"warnings",de);H($,O,`from onEnd() callback in plugin ${q(A)}`),T!=null&&(h=pe(T,"errors",a,A,void 0)),j!=null&&(g=pe(j,"warnings",a,A,void 0))}}catch($){h=[ye($,o,a,R&&R(),A)]}if(h){p.push(...h);try{v.errors.push(...h)}catch{}}if(g){P.push(...g);try{v.warnings.push(...g)}catch{}}}m(p,P)})()});let w=()=>{for(let v of k)setTimeout(()=>v(),0)};return I=!0,{ok:!0,requestPlugins:_,runOnEndCallbacks:b,scheduleOnDisposeCallbacks:w}};function Wt(){let t=new Map,e=0;return{clear(){t.clear()},load(r){return t.get(r)},store(r){if(r===void 0)return-1;let n=e++;return t.set(n,r),n}}}function We(t,e,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let s=(t.stack+"").split(`
|
|
7
|
+
`);s.splice(1,1);let i=Gt(e,s,r);if(i)return n={text:t.message,location:i},n}catch{}}}function ye(t,e,r,n,o){let s="Internal error",i=null;try{s=(t&&t.message||t)+""}catch{}try{i=Gt(e,(t.stack+"").split(`
|
|
8
|
+
`),"")}catch{}return{id:"",pluginName:o,text:s,location:i,notes:n?[n]:[],detail:r?r.store(t):-1}}function Gt(t,e,r){let n=" at ";if(t.readFileSync&&!e[0].startsWith(n)&&e[1].startsWith(n))for(let o=1;o<e.length;o++){let s=e[o];if(s.startsWith(n))for(s=s.slice(n.length);;){let i=/^(?:new |async )?\S+ \((.*)\)$/.exec(s);if(i){s=i[1];continue}if(i=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(s),i){s=i[1];continue}if(i=/^(\S+):(\d+):(\d+)$/.exec(s),i){let c;try{c=t.readFileSync(i[1],"utf8")}catch{break}let a=c.split(/\r\n|\r|\n|\u2028|\u2029/)[+i[2]-1]||"",f=+i[3]-1,u=a.slice(f,f+r.length)===r?r.length:0;return{file:i[1],namespace:"file",line:+i[2],column:se(a.slice(0,f)).length,length:se(a.slice(f,f+u)).length,lineText:a+`
|
|
9
|
+
`+e.slice(1).join(`
|
|
10
|
+
`),suggestion:""}}break}}return null}function _e(t,e,r){let n=5;t+=e.length<1?"":` with ${e.length} error${e.length<2?"":"s"}:`+e.slice(0,n+1).map((s,i)=>{if(i===n)return`
|
|
11
|
+
...`;if(!s.location)return`
|
|
12
|
+
error: ${s.text}`;let{file:c,line:a,column:f}=s.location,u=s.pluginName?`[plugin: ${s.pluginName}] `:"";return`
|
|
13
|
+
${c}:${a}:${f}: ERROR: ${u}${s.text}`}).join("");let o=new Error(t);for(let[s,i]of[["errors",e],["warnings",r]])Object.defineProperty(o,s,{configurable:!0,enumerable:!0,get:()=>i,set:c=>Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:c})});return o}function Pe(t,e){for(let r of t)r.detail=e.load(r.detail);return t}function Ft(t,e,r){if(t==null)return null;let n={},o=l(t,n,"file",E),s=l(t,n,"namespace",E),i=l(t,n,"line",ve),c=l(t,n,"column",ve),a=l(t,n,"length",ve),f=l(t,n,"lineText",E),u=l(t,n,"suggestion",E);if(H(t,n,e),f){let d=f.slice(0,(c&&c>0?c:0)+(a&&a>0?a:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(d)&&!/\n/.test(f)&&(f=d)}return{file:o||"",namespace:s||"",line:i||0,column:c||0,length:a||0,lineText:f||"",suggestion:u||""}}function pe(t,e,r,n,o){let s=[],i=0;for(let c of t){let a={},f=l(c,a,"id",E),u=l(c,a,"pluginName",E),d=l(c,a,"text",E),y=l(c,a,"location",At),k=l(c,a,"notes",de),M=l(c,a,"detail",Ye),U=`in element ${i} of "${e}"`;H(c,a,U);let _=[];if(k)for(let I of k){let b={},w=l(I,b,"text",E),v=l(I,b,"location",At);H(I,b,U),_.push({text:w||"",location:Ft(v,U,o)})}s.push({id:f||"",pluginName:u||n,text:d||"",location:Ft(y,U,o),notes:_,detail:r?r.store(M):-1}),i++}return s}function Ge(t,e){let r=[];for(let n of t){if(typeof n!="string")throw new Error(`${q(e)} must be an array of strings`);r.push(n)}return r}function Dr(t,e){let r=Object.create(null);for(let n in t){let o=t[n];if(typeof o!="string")throw new Error(`key ${q(n)} in object ${q(e)} must be a string`);r[n]=o}return r}function Cr({path:t,contents:e,hash:r}){let n=null;return{path:t,contents:e,hash:r,get text(){let o=this.contents;return(n===null||o!==e)&&(e=o,n=De(o)),n}}}function qe(t){let e=t.source;return t.flags&&(e=`(?${t.flags})${e}`),e}var ge=J("fs"),Rt=J("os"),oe=J("path"),Oe=process.env.ESBUILD_BINARY_PATH||Oe,Tr=t=>!!t&&t!=="/usr/bin/esbuild",_t="@esbuild/darwin-arm64",Ot="@esbuild/darwin-x64",Ve={"win32 arm64 LE":"@esbuild/win32-arm64","win32 ia32 LE":"@esbuild/win32-ia32","win32 x64 LE":"@esbuild/win32-x64"},Je={"aix ppc64 BE":"@esbuild/aix-ppc64","android arm64 LE":"@esbuild/android-arm64","darwin arm64 LE":"@esbuild/darwin-arm64","darwin x64 LE":"@esbuild/darwin-x64","freebsd arm64 LE":"@esbuild/freebsd-arm64","freebsd x64 LE":"@esbuild/freebsd-x64","linux arm LE":"@esbuild/linux-arm","linux arm64 LE":"@esbuild/linux-arm64","linux ia32 LE":"@esbuild/linux-ia32","linux mips64el LE":"@esbuild/linux-mips64el","linux ppc64 LE":"@esbuild/linux-ppc64","linux riscv64 LE":"@esbuild/linux-riscv64","linux s390x BE":"@esbuild/linux-s390x","linux x64 LE":"@esbuild/linux-x64","linux loong64 LE":"@esbuild/linux-loong64","netbsd arm64 LE":"@esbuild/netbsd-arm64","netbsd x64 LE":"@esbuild/netbsd-x64","openbsd arm64 LE":"@esbuild/openbsd-arm64","openbsd x64 LE":"@esbuild/openbsd-x64","sunos x64 LE":"@esbuild/sunos-x64"},jt={"android arm LE":"@esbuild/android-arm","android x64 LE":"@esbuild/android-x64","openharmony arm64 LE":"@esbuild/openharmony-arm64"};function Ir(){let t,e,r=!1,n=`${process.platform} ${Rt.arch()} ${Rt.endianness()}`;if(n in Ve)t=Ve[n],e="esbuild.exe";else if(n in Je)t=Je[n],e="bin/esbuild";else if(n in jt)t=jt[n],e="bin/esbuild",r=!0;else throw new Error(`Unsupported platform: ${n}`);return{pkg:t,subpath:e,isWASM:r}}function zr(){let t=J.resolve("esbuild"),e=oe.dirname(oe.dirname(oe.dirname(t)));if(oe.basename(e)==="node_modules"){for(let r in Je)try{let n=Je[r];if(ge.existsSync(oe.join(e,n)))return n}catch{}for(let r in Ve)try{let n=Ve[r];if(ge.existsSync(oe.join(e,n)))return n}catch{}}return null}function Lr(t,e){let r=oe.dirname(J.resolve("esbuild"));return oe.join(r,`downloaded-${t.replace("/","-")}-${oe.basename(e)}`)}function Nr(){if(Tr(Oe)&&ge.existsSync(Oe))return{binPath:Oe,isWASM:!1};let{pkg:t,subpath:e,isWASM:r}=Ir(),n;try{n=J.resolve(`${t}/${e}`)}catch(o){if(n=Lr(t,e),!ge.existsSync(n)){try{J.resolve(t)}catch{let s=zr();if(s){let i=`
|
|
14
|
+
Specifically the "${s}" package is present but this platform
|
|
15
|
+
needs the "${t}" package instead. People often get into this
|
|
16
|
+
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
|
17
|
+
into a Docker image that runs Linux, or by copying "node_modules" between
|
|
18
|
+
Windows and WSL environments.
|
|
19
|
+
|
|
20
|
+
If you are installing with npm, you can try not copying the "node_modules"
|
|
21
|
+
directory when you copy the files over, and running "npm ci" or "npm install"
|
|
22
|
+
on the destination platform after the copy. Or you could consider using yarn
|
|
23
|
+
instead of npm which has built-in support for installing a package on multiple
|
|
24
|
+
platforms simultaneously.
|
|
25
|
+
|
|
26
|
+
If you are installing with yarn, you can try listing both this platform and the
|
|
27
|
+
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
|
28
|
+
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
29
|
+
Keep in mind that this means multiple copies of esbuild will be present.
|
|
30
|
+
`;throw(t===Ot&&s===_t||t===_t&&s===Ot)&&(i=`
|
|
31
|
+
Specifically the "${s}" package is present but this platform
|
|
32
|
+
needs the "${t}" package instead. People often get into this
|
|
33
|
+
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
|
34
|
+
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
|
35
|
+
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
|
36
|
+
|
|
37
|
+
If you are installing with npm, you can try ensuring that both npm and node are
|
|
38
|
+
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
|
39
|
+
changing how you installed npm and/or node. For example, installing node with
|
|
40
|
+
the universal installer here should work: https://nodejs.org/en/download/. Or
|
|
41
|
+
you could consider using yarn instead of npm which has built-in support for
|
|
42
|
+
installing a package on multiple platforms simultaneously.
|
|
43
|
+
|
|
44
|
+
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
|
45
|
+
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
|
46
|
+
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
47
|
+
Keep in mind that this means multiple copies of esbuild will be present.
|
|
48
|
+
`),new Error(`
|
|
49
|
+
You installed esbuild for another platform than the one you're currently using.
|
|
50
|
+
This won't work because esbuild is written with native code and needs to
|
|
51
|
+
install a platform-specific binary executable.
|
|
52
|
+
${i}
|
|
53
|
+
Another alternative is to use the "esbuild-wasm" package instead, which works
|
|
54
|
+
the same way on all platforms. But it comes with a heavy performance cost and
|
|
55
|
+
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
|
56
|
+
want to do that.
|
|
57
|
+
`)}throw new Error(`The package "${t}" could not be found, and is needed by esbuild.
|
|
58
|
+
|
|
59
|
+
If you are installing esbuild with npm, make sure that you don't specify the
|
|
60
|
+
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
|
61
|
+
of "package.json" is used by esbuild to install the correct binary executable
|
|
62
|
+
for your current platform.`)}throw o}}if(/\.zip\//.test(n)){let o;try{o=J("pnpapi")}catch{}if(o){let s=o.getPackageInformation(o.topLevel).packageLocation,i=oe.join(s,"node_modules",".cache","esbuild",`pnpapi-${t.replace("/","-")}-0.27.3-${oe.basename(e)}`);return ge.existsSync(i)||(ge.mkdirSync(oe.dirname(i),{recursive:!0}),ge.copyFileSync(n,i),ge.chmodSync(i,493)),{binPath:i,isWASM:r}}}return{binPath:n,isWASM:r}}var Yt=J("child_process"),Mr=J("crypto"),st=J("path"),we=J("fs"),Br=J("os"),Ur=J("tty"),K;if(process.env.ESBUILD_WORKER_THREADS!=="0"){try{K=J("worker_threads")}catch{}let[t,e]=process.versions.node.split(".");(+t<12||+t==12&&+e<17||+t==13&&+e<13)&&(K=void 0)}var Dt,Te=((Dt=K?.workerData)==null?void 0:Dt.esbuildVersion)==="0.27.3",Ht=()=>{if(!Oe&&(st.basename(__filename)!=="main.js"||st.basename(__dirname)!=="lib"))throw new Error(`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
|
|
63
|
+
|
|
64
|
+
More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`);{let{binPath:t,isWASM:e}=Nr();return e?["node",[t]]:[t,[]]}},je=()=>Ur.isatty(2),Wr={readFile(t,e){try{let r=we.readFileSync(t,"utf8");try{we.unlinkSync(t)}catch{}e(null,r)}catch(r){e(r,null)}},writeFile(t,e){try{let r=qt();we.writeFileSync(r,t),e(r)}catch{e(null)}}},Gr={readFile(t,e){try{we.readFile(t,"utf8",(r,n)=>{try{we.unlink(t,()=>e(r,n))}catch{e(r,n)}})}catch(r){e(r,null)}},writeFile(t,e){try{let r=qt();we.writeFile(r,t,n=>e(n!==null?null:r))}catch{e(null)}}},Yr="0.27.3",Hr=t=>xe().build(t),qr=t=>xe().context(t),Vr=(t,e)=>xe().transform(t,e),Jr=(t,e)=>xe().formatMessages(t,e),Kr=(t,e)=>xe().analyzeMetafile(t,e),Xr=t=>{if(K&&!Te)return X||(X=Qe(K)),X.buildSync(t);let e;return Ze(r=>r.buildOrContext({callName:"buildSync",refs:null,options:t,isTTY:je(),defaultWD:be,callback:(n,o)=>{if(n)throw n;e=o}})),e},Zr=(t,e)=>{if(K&&!Te)return X||(X=Qe(K)),X.transformSync(t,e);let r;return Ze(n=>n.transform({callName:"transformSync",refs:null,input:t,options:e||{},isTTY:je(),fs:Wr,callback:(o,s)=>{if(o)throw o;r=s}})),r},Qr=(t,e)=>{if(K&&!Te)return X||(X=Qe(K)),X.formatMessagesSync(t,e);let r;return Ze(n=>n.formatMessages({callName:"formatMessagesSync",refs:null,messages:t,options:e,callback:(o,s)=>{if(o)throw o;r=s}})),r},en=(t,e)=>{if(K&&!Te)return X||(X=Qe(K)),X.analyzeMetafileSync(t,e);let r;return Ze(n=>n.analyzeMetafile({callName:"analyzeMetafileSync",refs:null,metafile:typeof t=="string"?t:JSON.stringify(t),options:e,callback:(o,s)=>{if(o)throw o;r=s}})),r},tn=()=>(Ke&&Ke(),X&&X.stop(),Promise.resolve()),at=!1,rn=t=>{if(t=Fr(t||{}),t.wasmURL)throw new Error('The "wasmURL" option only works in the browser');if(t.wasmModule)throw new Error('The "wasmModule" option only works in the browser');if(t.worker)throw new Error('The "worker" option only works in the browser');if(at)throw new Error('Cannot call "initialize" more than once');return xe(),at=!0,Promise.resolve()},be=process.cwd(),Re,Ke,xe=()=>{if(Re)return Re;let[t,e]=Ht(),r=Yt.spawn(t,e.concat("--service=0.27.3","--ping"),{windowsHide:!0,stdio:["pipe","pipe","inherit"],cwd:be}),{readFromStdout:n,afterClose:o,service:s}=Ut({writeToStdin(u){r.stdin.write(u,d=>{d&&o(d)})},readFileSync:we.readFileSync,isSync:!1,hasFS:!0,esbuild:Ce});r.stdin.on("error",o),r.on("error",o);let i=r.stdin,c=r.stdout;c.on("data",n),c.on("end",o),Ke=()=>{i.destroy(),c.destroy(),r.kill(),at=!1,Re=void 0,Ke=void 0};let a=0;r.unref(),i.unref&&i.unref(),c.unref&&c.unref();let f={ref(){++a===1&&r.ref()},unref(){--a===0&&r.unref()}};return Re={build:u=>new Promise((d,y)=>{s.buildOrContext({callName:"build",refs:f,options:u,isTTY:je(),defaultWD:be,callback:(k,M)=>k?y(k):d(M)})}),context:u=>new Promise((d,y)=>s.buildOrContext({callName:"context",refs:f,options:u,isTTY:je(),defaultWD:be,callback:(k,M)=>k?y(k):d(M)})),transform:(u,d)=>new Promise((y,k)=>s.transform({callName:"transform",refs:f,input:u,options:d||{},isTTY:je(),fs:Gr,callback:(M,U)=>M?k(M):y(U)})),formatMessages:(u,d)=>new Promise((y,k)=>s.formatMessages({callName:"formatMessages",refs:f,messages:u,options:d,callback:(M,U)=>M?k(M):y(U)})),analyzeMetafile:(u,d)=>new Promise((y,k)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:f,metafile:typeof u=="string"?u:JSON.stringify(u),options:d,callback:(M,U)=>M?k(M):y(U)}))},Re},Ze=t=>{let[e,r]=Ht(),n=new Uint8Array,{readFromStdout:o,afterClose:s,service:i}=Ut({writeToStdin(a){if(n.length!==0)throw new Error("Must run at most one command");n=a},isSync:!0,hasFS:!0,esbuild:Ce});t(i);let c=Yt.execFileSync(e,r.concat("--service=0.27.3"),{cwd:be,windowsHide:!0,input:n,maxBuffer:+process.env.ESBUILD_MAX_BUFFER||16*1024*1024});o(c),s(null)},qt=()=>st.join(Br.tmpdir(),`esbuild-${Mr.randomBytes(32).toString("hex")}`),X=null,Qe=t=>{let{port1:e,port2:r}=new t.MessageChannel,n=new t.Worker(__filename,{workerData:{workerPort:r,defaultWD:be,esbuildVersion:"0.27.3"},transferList:[r],execArgv:[]}),o=0,s=f=>{let u=new Error(`Build failed with 1 error:
|
|
65
|
+
error: ${f}`),d=[{id:"",pluginName:"",text:f,location:null,notes:[],detail:void 0}];return u.errors=d,u.warnings=[],u},i=f=>{if(!f)return;let u=f.plugins;if(u&&u.length>0)throw s("Cannot use plugins in synchronous API calls")},c=(f,u)=>{for(let d in u)f[d]=u[d]},a=(f,u)=>{let d=o++,y=new SharedArrayBuffer(8),k=new Int32Array(y),M={sharedBuffer:y,id:d,command:f,args:u};n.postMessage(M);let U=Atomics.wait(k,0,0);if(U!=="ok"&&U!=="not-equal")throw new Error("Internal error: Atomics.wait() failed: "+U);let{message:{id:_,resolve:I,reject:b,properties:w}}=t.receiveMessageOnPort(e);if(d!==_)throw new Error(`Internal error: Expected id ${d} but got id ${_}`);if(b)throw c(b,w),b;return I};return n.unref(),{buildSync(f){return i(f),a("build",[f])},transformSync(f,u){return a("transform",[f,u])},formatMessagesSync(f,u){return a("formatMessages",[f,u])},analyzeMetafileSync(f,u){return a("analyzeMetafile",[f,u])},stop(){n.terminate(),X=null}}},nn=()=>{let t=K.workerData.workerPort,e=K.parentPort,r=n=>{let o={};if(n&&typeof n=="object")for(let s in n)o[s]=n[s];return o};try{let n=xe();be=K.workerData.defaultWD,e.on("message",o=>{(async()=>{let{sharedBuffer:s,id:i,command:c,args:a}=o,f=new Int32Array(s);try{switch(c){case"build":t.postMessage({id:i,resolve:await n.build(a[0])});break;case"transform":t.postMessage({id:i,resolve:await n.transform(a[0],a[1])});break;case"formatMessages":t.postMessage({id:i,resolve:await n.formatMessages(a[0],a[1])});break;case"analyzeMetafile":t.postMessage({id:i,resolve:await n.analyzeMetafile(a[0],a[1])});break;default:throw new Error(`Invalid command: ${c}`)}}catch(u){t.postMessage({id:i,reject:u,properties:r(u)})}Atomics.add(f,0,1),Atomics.notify(f,0,1/0)})()})}catch(n){e.on("message",o=>{let{sharedBuffer:s,id:i}=o,c=new Int32Array(s);t.postMessage({id:i,reject:n,properties:r(n)}),Atomics.add(c,0,1),Atomics.notify(c,0,1/0)})}};Te&&nn();var on=Ce});import Ae from"node:fs";import ie from"node:path";import{fileURLToPath as or}from"node:url";var sr=or(import.meta.url),pn=ie.dirname(sr);function Ie(){let t=process.cwd(),e=10;for(let r=0;r<e;r++){let n=ie.join(t,"package.json");if(Ae.existsSync(n))try{let s=JSON.parse(Ae.readFileSync(n,"utf8")),i=s.workspaces&&Array.isArray(s.workspaces);if(i&&s.workspaces.some(u=>u==="packages/**"||u.startsWith("packages/"))&&(Ae.existsSync(ie.join(t,"packages","core"))||Ae.existsSync(ie.join(t,"packages","functions"))))return{type:"dndev",root:t};if(i&&s.workspaces.some(u=>u.includes("dndev/packages"))){let d=s.workspaces.find(k=>k.includes("dndev/packages")).replace(/\/packages.*$/,""),y=ie.resolve(t,d);if(Ae.existsSync(ie.join(y,"packages","core")))return{type:"dndev",root:y}}}catch{}let o=ie.dirname(t);if(o===t)break;t=o}return{type:"npm",root:process.cwd()}}function ar(t){return t.type==="dndev"?t.root:null}function dt(t){let e={};if(t.type==="dndev"){let r=ar(t);r&&(e["@donotdev/types"]=ie.join(r,"packages","core","types","src"),e["@donotdev/functions"]=ie.join(r,"packages","functions","src"),e["@donotdev/utils"]=ie.join(r,"packages","core","utils","src"),e["@donotdev/schemas"]=ie.join(r,"packages","core","schemas","src"),e["@donotdev/core"]=ie.join(r,"packages","core"))}return e}import*as N from"node:fs";import"node:fs";import{createRequire as cr}from"node:module";import{resolve as Le,join as fe,dirname as me,relative as gt,normalize as ur,sep as yt,extname as fr}from"node:path";import{fileURLToPath as dr}from"node:url";import pr from"fast-glob";var ze={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},he={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${ze.SOURCE_EAGER}/*_*.json`],lazy:[`${ze.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]};var pt={base:{absolute:!0,onlyFiles:!0,ignore:he.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...he.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...he.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:he.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:he.globalIgnore}};function ht(t,e=null){let r=he[t];if(!r)throw new Error(`Unknown pattern type: ${t}`);return e&&r.framework?{...r,framework:r.framework.map(n=>`${e}/${n}`)}:r}function mt(t){return pt[t]||pt.base}var Ee={getGlobOptionsFor:mt||void 0,SCAN_PATTERNS:he||void 0,getPatternsFor:ht||void 0,I18N_PATHS:ze||void 0},V={error:(t,e)=>{},warn:(t,e)=>{},info:t=>{}};function vt(t,e){return t().catch(r=>{throw new Error(`${e}: ${r instanceof Error?r.message:String(r)}`)})}var wt={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},Ne=class t{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return t._instance||(t._instance=new t(e)),t._instance}static _reset(){t._instance=null}constructor(e={}){if(t._instance)return t._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let r=process.cwd();if(!r)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(r)}catch(r){throw new Error(`PathResolver constructor failed: ${r instanceof Error?r.message:String(r)}. cwd: ${process.cwd()}`)}this._appRoot=null,t._instance=this}normalizePath(e){if(!e)return"";try{return ur(e).split(yt).join("/")}catch{return String(e).split(yt).join("/")}}getRelativePath(e){let r=this.getAppRoot(),n=gt(r,e);return this.normalizePath(n)}getBasename(e){if(!e)return"";let n=this.normalizePath(e).split("/");return n[n.length-1]||""}getDirname(e){return e?this.normalizePath(me(e)):""}resolvePackage(e,r=null){try{let n=r||this.getAppRoot(),s=cr(fe(n,"package.json")).resolve(e);return this.normalizePath(s)}catch{return null}}resolveFrameworkPackage(e,r=null){let n=this.resolvePackage(`${e}/package.json`,r);if(n)return this.getDirname(n);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let i=e.replace("@donotdev/",""),c=this.resolveRepoPath(`packages/${i}`);if(this.pathExists(c))return c;if(["auth","billing","crud","oauth"].includes(i)){let a=this.resolveRepoPath(`packages/features/${i}`);if(this.pathExists(a))return a}if(i==="firebase"){let a=this.resolveRepoPath(`packages/providers/${i}`);if(this.pathExists(a))return a}}let o=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(o))return o;let s=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(s)?s:null}resolvePackageAsset(e,r=null){return this.resolvePackage(e,r)}resolveAppPath(e){let r=this.getAppRoot(),n=Le(r,e);return this.normalizePath(n)}resolveRepoPath(e){let r=this.getRepoRoot(),n=this.normalizePath(e),o=Le(r,n);return this.normalizePath(o)}resolvePath(e,r){let n=this.normalizePath(r),o=this.normalizePath(e),s=Le(n,o);return this.normalizePath(s)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let r=N.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:r.size,isFile:r.isFile(),isDirectory:r.isDirectory()}}catch{return null}}_detectFormat(e,r){return r&&r!=="auto"?r:fr(e).toLowerCase()===".json"?"json":"text"}async read(e,r={}){let{format:n="auto",encoding:o="utf8"}=r,s=this._detectFormat(e,n);try{if(s==="buffer")return await N.promises.readFile(e);let i=await N.promises.readFile(e,o),c=this.stripBom(i);return s==="json"?JSON.parse(c):c}catch(i){return this.options.debug&&V.warn(`Failed to read file: ${e}`,i),null}}readSync(e,r={}){let{format:n="auto",encoding:o="utf8"}=r,s=this._detectFormat(e,n);try{if(s==="buffer")return N.readFileSync(e);let i=N.readFileSync(e,o),c=this.stripBom(i);return s==="json"?JSON.parse(c):c}catch(i){return this.options.debug&&V.warn(`Failed to read file: ${e}`,i),null}}async write(e,r,n={}){let{format:o="auto",overwrite:s=!1,dryRun:i=!1,verbose:c=!1}=n,a=this.normalizePath(e),f=this.normalizePath(me(a)),u=this.pathExists(a);if(u&&!s)return c&&V.info(`Skipping existing file: ${a}`),!1;if(i)return V.info(`[DRY RUN] Would write file: ${a}`),!0;try{await N.promises.mkdir(f,{recursive:!0})}catch(k){if(k?.code!=="EEXIST")throw k}let d=this._detectFormat(e,o),y;Buffer.isBuffer(r)?y=r:d==="json"&&typeof r=="object"?y=JSON.stringify(r,null,2):y=String(r);try{return await vt(async()=>(Buffer.isBuffer(y)?await N.promises.writeFile(a,y):await N.promises.writeFile(a,y,"utf8"),c&&V.info(`${u?"Updated":"Created"} file: ${a}`),!0),`Failed to write file: ${a}`)}catch{return!1}}writeSync(e,r,n={}){let{format:o="auto",overwrite:s=!1,dryRun:i=!1,verbose:c=!1}=n,a=this.normalizePath(e),f=this.normalizePath(me(a)),u=this.pathExists(a);if(u&&!s)return c&&V.info(`Skipping existing file: ${a}`),!1;if(i)return V.info(`[DRY RUN] Would write file: ${a}`),!0;try{N.mkdirSync(f,{recursive:!0})}catch(k){if(k?.code!=="EEXIST")throw k}let d=this._detectFormat(e,o),y;Buffer.isBuffer(r)?y=r:d==="json"&&typeof r=="object"?y=JSON.stringify(r,null,2):y=String(r);try{return Buffer.isBuffer(y)?N.writeFileSync(a,y):N.writeFileSync(a,y,"utf8"),c&&V.info(`${u?"Updated":"Created"} file: ${a}`),!0}catch(k){throw new Error(`Failed to write file: ${a}: ${k instanceof Error?k.message:String(k)}`)}}async copy(e,r,n={}){let{overwrite:o=!1,dryRun:s=!1,verbose:i=!1}=n,c=this.normalizePath(r),a=this.pathExists(c);if(a&&!o)return i&&V.info(`Skipping existing file: ${c}`),!1;if(s)return V.info(`[DRY RUN] Would copy file: ${c}`),!0;let f=this.normalizePath(me(c));try{await N.promises.mkdir(f,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return await vt(async()=>(await N.promises.copyFile(e,c),i&&V.info(`${a?"Updated":"Created"} file: ${c}`),!0),`Failed to copy file from ${e} to ${c}`)}catch{return!1}}copySync(e,r,n={}){let{overwrite:o=!1,dryRun:s=!1,verbose:i=!1}=n,c=this.normalizePath(r),a=this.pathExists(c);if(a&&!o)return i&&V.info(`Skipping existing file: ${c}`),!1;if(s)return V.info(`[DRY RUN] Would copy file: ${c}`),!0;let f=this.normalizePath(me(c));try{N.mkdirSync(f,{recursive:!0})}catch(u){if(u?.code!=="EEXIST")throw u}try{return N.copyFileSync(e,c),i&&V.info(`${a?"Updated":"Created"} file: ${c}`),!0}catch{return!1}}pathExists(e,r=!1){try{return N.existsSync(e)}catch(n){return r||V.error(`Error checking path existence: ${e}`,n),!1}}mkdir(e){try{let r=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return N.existsSync(r)||N.mkdirSync(r,{recursive:!0}),!0}catch{return!1}}readdirSync(e,r){try{return N.readdirSync(e,r)}catch(n){return this.options.debug&&V.warn(`Failed to read directory: ${e}`,n),r&&typeof r=="object"&&"withFileTypes"in r&&r.withFileTypes?[]:[]}}statSync(e){try{return N.statSync(e)}catch(r){return this.options.debug&&V.warn(`Failed to stat file: ${e}`,r),null}}lstatSync(e){try{return N.lstatSync(e)}catch(r){return this.options.debug&&V.warn(`Failed to lstat file: ${e}`,r),null}}async ensureDir(e){try{await N.promises.mkdir(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}ensureDirSync(e){try{N.mkdirSync(e,{recursive:!0})}catch(r){if(r?.code!=="EEXIST")throw r}}async remove(e){await N.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){N.rmSync(e,{recursive:!0,force:!0})}async readdir(e,r){return N.promises.readdir(e,r)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=fe(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let r=this.normalizePath(Le(e)),n=this.getAppRoot(),o=gt(n,r),s=this.normalizePath(o);return!s.startsWith("../")&&!s.startsWith("/")}async findFiles(e,r,n={}){let o=this.normalizePath(fe(e,r)),s=this.getAppRoot(),i=this.normalizePath(s),c=o.startsWith(i)?o.slice(i.length+1):o,a={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:Ee.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([c],{...a,...n})}clearCache(){}async _resolveFrameworkI18nPattern(e){let r=Ee.I18N_PATHS;if(!r)return null;let n=e.replace(r.SOURCE_ROOT+"/",""),o=this.resolveFrameworkPackage("@donotdev/core");if(!o)return null;let s=this.normalizePath(fe(o,r.PUBLISHED_ROOT,n)),i=s.replace(/\/[^/]*\*.*$/,"");return this.pathExists(i),s}async _globWithNormalization(e,r){return(await pr(e,r)).map(o=>{let s=typeof o=="string"?o:o.path;return this.normalizePath(s)})}async resolveFiles(e,r="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(r==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let n=[...e.framework,...e.consumer];for(let u of n)if(typeof u!="string"||u.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let o=this.getAppRoot(),s=Ee.getGlobOptionsFor?Ee.getGlobOptionsFor(r):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},i=this.normalizePath(o),c=e.framework.map(u=>{let d=this.normalizePath(u);return d.startsWith(i)?d.slice(i.length+1):d}),a=e.consumer.map(u=>{let d=this.normalizePath(u);return d.startsWith(i)?d.slice(i.length+1):d}),f={...s,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o};try{let u=c.length>0?await this._globWithNormalization(c,f):[],d=await this._globWithNormalization(a,f);return{frameworkFiles:u,consumerFiles:d}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!Ee.getPatternsFor)return{framework:[],consumer:[],all:[]};let r=this.getAppRoot(),n=this.getRepoRoot();if(e==="i18n"&&(!r||r===n))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${r}, repoRoot: ${n}). Ensure configResolved hook has run before discovery.`);let o=Ee.getPatternsFor(e),s=this.isMonorepo();if(e==="i18n"){let a=o,f={eager:a.eager.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),lazy:a.lazy.map(u=>u.startsWith("!")?"!"+this.resolveAppPath(u.slice(1)):this.resolveAppPath(u)),framework:{eager:s?(a.framework?.eager||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((a.framework?.eager||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean)),lazy:s?(a.framework?.lazy||[]).map(u=>this.resolveRepoPath(u)).filter(Boolean):await Promise.all((a.framework?.lazy||[]).map(u=>this._resolveFrameworkI18nPattern(u))).then(u=>u.filter(Boolean))},all:[]};return f.all=[...f.eager,...f.lazy,...f.framework.eager,...f.framework.lazy],f}let i=o,c={framework:s?(i.framework||[]).map(a=>this.resolveRepoPath(a)).filter(Boolean):[],consumer:(i.consumer||[]).map(a=>this.resolveAppPath(a)),all:[]};return c.all=[...c.consumer,...c.framework],c}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let r=this.resolvePackage("@donotdev/core/empty");if(r)return r;let n=me(dr(import.meta.url));return this.normalizePath(fe(n,"../empty.js"))}_findRepoRoot(e){let r=this.normalizePath(e),n=0,o=this.options.maxLevels;for(;n<o;){let s=this.normalizePath(fe(r,wt.TOOLING)),i=this.normalizePath(fe(r,wt.CORE));if(this.pathExists(s)&&this.pathExists(i))return r;let c=fe(r,"apps");if(this.pathExists(c)&&this.statSync(c)?.isDirectory())return this.normalizePath(r);let a=this.normalizePath(fe(r,"package.json"));if(this.pathExists(a)&&this.normalizePath(me(r))===r)return r;let f=this.normalizePath(me(r));if(f===r)break;r=f,n++}return this.normalizePath(e)}};function Me(t={}){let{entry:e="src/index.ts",outDir:r="lib",minify:n=!1,sourcemap:o=!0,platform:s="firebase",workspace:i,bundleWorkspaceDeps:c=!1,importFramework:a=!1,external:f=!1,...u}=t,d=Ne.getInstance(),y=dt(i),k={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:r,outExtension:{".js":".js"},minify:n,sourcemap:o,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...u};c&&Object.keys(y).length>0&&(k.alias=Object.fromEntries(Object.entries(y).map(([I,b])=>[I,d.normalizePath(b)]))),k.mainFields=["module","main"],k.conditions=["import","module","node"];let M=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],U=[];if(c)try{let I=i?.root||process.cwd(),b=process.cwd(),w=10;for(let v=0;v<w;v++){let m=d.normalizePath(`${b}/package.json`);if(d.pathExists(m)){let P=d.readSync(m,{format:"json"});if(P&&Array.isArray(P.workspaces)){I=d.normalizePath(b);for(let A of P.workspaces)A==="apps/*"||A==="functions"||!A.includes("*")&&!A.includes("/")&&U.push(A);break}}let p=d.getDirname(b);if(p===b)break;b=p}}catch{}let _={name:"external-node-modules",setup(I){I.onResolve({filter:/^firebase($|\/)/},b=>{if(b.path==="firebase-admin"||b.path.startsWith("firebase-admin/")||b.path==="firebase-functions"||b.path.startsWith("firebase-functions/"))return null;let w;if(i?.type==="dndev"&&i.root)w=d.normalizePath(`${i.root}/packages/core/config/functions/firebase-stub.js`);else{let v=import.meta.url,p=new URL(v).pathname.replace(/^\/([A-Z]:)/i,"$1"),P=d.getDirname(p);w=d.normalizePath(`${P}/firebase-stub.js`)}return{path:w}}),I.onResolve({filter:/.*/},b=>{if(b.kind==="entry-point")return null;if(b.path.match(/@donotdev\/functions\/.+/)&&c&&i?.type==="dndev"){let w=b.path.replace("@donotdev/functions/","");return{path:d.normalizePath(`${i.root}/packages/functions/src/${w}/index.ts`)}}if(b.path==="@donotdev/utils")return i?.type==="dndev"?{path:d.normalizePath(`${i.root}/packages/core/utils/src/server/index.ts`)}:I.resolve("@donotdev/utils/server",{kind:b.kind,resolveDir:b.resolveDir});if(b.path.match(/@donotdev\/utils\/.+/)&&i?.type==="dndev"){let w=b.path.replace("@donotdev/utils/","");return{path:d.normalizePath(`${i.root}/packages/core/utils/src/${w}/index.ts`)}}if(b.path==="@donotdev/core")return i?.type==="dndev"?{path:d.normalizePath(`${i.root}/packages/core/server.ts`)}:I.resolve("@donotdev/core/server",{kind:b.kind,resolveDir:b.resolveDir});if(b.path.match(/@donotdev\/core\/.+/)&&c&&i?.type==="dndev"){let w=b.path.replace("@donotdev/core/","");return{path:d.normalizePath(`${i.root}/packages/core/${w}.ts`)}}if(b.path==="firebase-admin"||b.path.startsWith("firebase-admin/")||b.path==="firebase-functions"||b.path.startsWith("firebase-functions/"))return{path:b.path,external:!0};if(b.path.match(/@donotdev\/core\/.+/)&&c&&i?.type==="dndev"){let w=b.path.replace("@donotdev/core/","");return{path:d.normalizePath(`${i.root}/packages/core/${w}.ts`)}}if(b.path.startsWith("@donotdev/")||b.path==="valibot"||b.path.startsWith("valibot/"))return null;if(U.length>0){let w=b.path.split("/")[0];if(U.includes(w))return null}return b.path.startsWith(".")||b.path.startsWith("/")?null:{path:b.path,external:!0}})}};if(k.external=[...M,"firebase-admin","firebase-functions"],k.plugins=[_,...k.plugins||[]],k.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...k.define||{}},a&&i.type==="dndev"){let I=i.root,b=d.normalizePath(`${I}/functions/lib`);k.alias={...k.alias,"@donotdev/functions":b}}return s==="framework"&&(k.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),k}import{readFileSync as Be,writeFileSync as et,existsSync as Ue}from"fs";import"path";var tt=["create","get","list","listCard","update","delete"];function bt(t,e=0){let r=" ".repeat(e),n="";for(let[o,s]of Object.entries(t))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))Object.keys(s).length===0?n+=`${r}${o}: {}
|
|
66
|
+
`:n+=`${r}${o}:
|
|
67
|
+
${bt(s,e+1)}`;else if(Array.isArray(s))if(s.length===0)n+=`${r}${o}: []
|
|
68
|
+
`;else{n+=`${r}${o}:
|
|
69
|
+
`;for(let i of s)if(typeof i=="object"&&i!==null){let c=Object.entries(i),[a,f]=c[0];n+=`${r} - ${a}: ${f}
|
|
70
|
+
`;for(let u=1;u<c.length;u++){let[d,y]=c[u];n+=`${r} ${d}: ${y}
|
|
71
|
+
`}}else n+=`${r} - ${i}
|
|
72
|
+
`}else n+=`${r}${o}: ${s}
|
|
73
|
+
`;return n}var hr=["X_GOOGLE_","FIREBASE_","EXT_","GCLOUD_"],mr=["FIREBASE_REGION","FIREBASE_PROJECT_ID","FIREBASE_AUTH_DOMAIN","ENABLE_RATE_LIMITING","DISABLE_RATE_LIMITING","ENABLE_METRICS","DISABLE_METRICS","ENFORCE_APP_CHECK"];function xt(t){if(!Ue(t))return[];let e=Be(t,"utf-8"),r=[],n=e.matchAll(/export\s*\{([^}]+)\}/g);for(let s of n)if(s[1]){let i=s[1].split(",").map(c=>{let a=c.trim().split(/\s+as\s+/);return(a[1]||a[0]||"").trim()}).filter(Boolean);r.push(...i)}let o=e.matchAll(/export\s+const\s+(\w+)/g);for(let s of o)s[1]&&r.push(s[1]);return[...new Set(r)]}function Fe(t=".env"){if(!Ue(t))return[];let e=Be(t,"utf-8"),r=[];for(let n of e.split(/\r?\n/)){let o=n.trim();if(!o||o.startsWith("#"))continue;let s=o.indexOf("=");if(s<=0)continue;let i=o.substring(0,s).trim();mr.includes(i)||hr.some(c=>i.startsWith(c))||r.push(i)}return r}function kt(t){return tt.some(e=>t.startsWith(`${e}_`))}function Et(t,e={}){let r=t.defaults||{},n=r.labels||{},o={},s=e.envPath?Fe(e.envPath):Fe(),i=s.length>0?s.map(d=>({key:d})):void 0,c=e.entryFile?xt(e.entryFile):[],a=t.functions||{},f=new Set(Object.keys(a));for(let d of c)!kt(d)&&!f.has(d)&&f.add(d);for(let d of f){let y=a[d]||{},k={...n,...y.labels};y.category&&(k.category=y.category),o[d]={region:y.region||r.region||["europe-west1"],platform:y.platform||r.platform||"gcfv2",entryPoint:y.entryPoint||d,labels:k},y.trigger==="http"?o[d].httpsTrigger={}:o[d].callableTrigger={},y.secrets?.length?o[d].secretEnvironmentVariables=y.secrets.map(M=>({key:M})):i&&(o[d].secretEnvironmentVariables=i)}if(t.crud?.entities)for(let d of t.crud.entities)for(let y of tt){let k=`${y}_${d}`;o[k]={region:r.region||["europe-west1"],platform:r.platform||"gcfv2",callableTrigger:{},entryPoint:k,labels:{...n,category:"crud"}},i&&(o[k].secretEnvironmentVariables=i)}return`# Firebase Functions Configuration
|
|
10
74
|
# Generated by @donotdev/core/functions - DO NOT EDIT MANUALLY
|
|
11
75
|
# Generated at: ${new Date().toISOString()}
|
|
12
76
|
|
|
13
|
-
`+
|
|
14
|
-
`));let
|
|
15
|
-
`;if(
|
|
16
|
-
`+
|
|
77
|
+
`+bt({endpoints:o,specVersion:"v1alpha1",requiredAPIs:[]})}function rt(t,e={}){let r=Object.keys(t.functions||{}),n=[];if(t.crud?.entities)for(let a of t.crud.entities)for(let f of tt)n.push(`${f}_${a}`);let s=(e.entryFile?xt(e.entryFile):[]).filter(a=>!kt(a)&&!r.includes(a)),i=[...r,...s],c=e.envPath?Fe(e.envPath):Fe();return{yaml:Et(t,e),functions:[...i,...n],staticFunctions:i,crudFunctions:n,autoDetected:s,autoSecrets:c}}function nt(t){let e=new Set;for(let f of Object.values(t.functions||{}))if(f.secrets)for(let u of f.secrets)e.add(u);let r=Fe();for(let f of r)e.add(f);if(e.size===0||!Ue(".env"))return{stripped:[],kept:0};let o=Be(".env","utf-8").split(/\r?\n/),s=[],i=[];for(let f of o){let u=f.trim();if(!u||u.startsWith("#")){s.push(f);continue}let d=u.indexOf("="),y=d>0?u.substring(0,d).trim():"";e.has(y)?i.push(f):s.push(f)}if(i.length===0)return{stripped:[],kept:s.length};et(".env",s.join(`
|
|
78
|
+
`));let c=`# Secrets managed by sync-secrets (auto-filtered by build)
|
|
79
|
+
`;if(Ue(".env.local")){let f=Be(".env.local","utf-8"),u=new Set(f.split(/\r?\n/).filter(y=>y.trim()&&!y.trim().startsWith("#")).map(y=>y.split("=")[0].trim())),d=i.filter(y=>!u.has(y.split("=")[0].trim()));d.length>0&&et(".env.local",f.trimEnd()+`
|
|
80
|
+
`+c+d.join(`
|
|
17
81
|
`)+`
|
|
18
|
-
`)}else
|
|
82
|
+
`)}else et(".env.local",c+i.join(`
|
|
19
83
|
`)+`
|
|
20
|
-
`);return{stripped:
|
|
84
|
+
`);return{stripped:i.map(f=>f.split("=")[0].trim()),kept:s.length}}import{writeFileSync as sn}from"fs";function an(t={}){let e=Ie();return Me({...t,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0,workspace:e})}async function ln(t,e={}){let{entry:r="src/index.ts",outDir:n="lib",minify:o=process.env.NODE_ENV==="production",sourcemap:s=!0,analyze:i=!1,entryFile:c="src/index.ts",envPath:a=".env",...f}=e;try{let{build:u}=await Promise.resolve().then(()=>ft(ct(),1)),d=an({entry:r,outDir:n,minify:o,sourcemap:s,...f}),y=await u(d);y.errors.length>0&&process.exit(1),y.warnings.length>0;let{yaml:k,staticFunctions:M,crudFunctions:U,autoDetected:_,autoSecrets:I}=rt(t,{entryFile:c,envPath:a});sn("functions.yaml",k),_.length>0,I.length>0;let{stripped:b}=nt(t);if(b.length>0,i&&y.metafile){let{analyzeMetafile:w}=await Promise.resolve().then(()=>ft(ct(),1)),v=await w(y.metafile)}}catch{process.exit(1)}}function Jt(t={}){let{entry:e="src/index.ts",outDir:r="lib",minify:n=!1,sourcemap:o=!0,platform:s="firebase",...i}=t,c=Ie();return Me({entry:e,outDir:r,minify:n,sourcemap:o,platform:s,workspace:c,...i})}function Mn(t={}){return Jt({...t,platform:"framework",bundleWorkspaceDeps:!0})}function Bn(t={}){return Jt({...t,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{ln as buildFunctions,Bn as createAppFunctionsConfig,Jt as createFunctionsEsbuildConfig,Mn as createRootFunctionsConfig,nt as filterEnvSecrets,Et as generateFunctionsYaml,rt as generateFunctionsYamlWithInfo};
|