@stacksjs/server 0.75.35 → 0.75.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/imports.js +1 -1
  2. package/package.json +11 -11
package/dist/imports.js CHANGED
@@ -10,4 +10,4 @@ var {require}=import.meta;import{existsSync,readFileSync,renameSync,statSync,unl
10
10
  `)){const match=/^export \{ default as (\w+) \} from '([^']+)'/.exec(line.trim());if(!match)continue;const[,name,relativePath]=match;found.push({name,file:resolvePath(outputDir,`${relativePath}.ts`),isDefault:!0})}return found}export async function pruneBrowserAutoImportTypes(){const outputPath=path.storagePath("framework/types/browser-auto-imports.d.ts");if(!existsSync(outputPath))return[];const source=readFileSync(outputPath,"utf8"),removed=[],kept=[];for(const line of source.split(`
11
11
  `)){const match=/^ {2}const (\w+): typeof import\('([^']+)'\)\['(\w+)'\]/.exec(line);if(!match){kept.push(line);continue}const[,declaredAs]=match;removed.push(declaredAs)}const staleHeaders=new Set(["// Generated by unplugin-auto-import","// Pruned by Stacks: every name below is exported by the module beside it."]),pruned=kept.filter((line)=>line.trim()!=="// @ts-nocheck").map((line)=>staleHeaders.has(line.trim())?"// Emptied by Stacks: nothing injects a bare name into a template. See stacksjs/stacks#2585.":line).join(`
12
12
  `);if(pruned===source)return removed;await Bun.write(outputPath,pruned);const globals=[...pruned.matchAll(/^ {2}const (\w+):/gm)].map((match)=>match[1]).sort();await Bun.write(path.storagePath("framework/browser-auto-imports.json"),`${JSON.stringify({globals:Object.fromEntries(globals.map((name)=>[name,!0]))},null,2)}
13
- `);return removed}async function ormModelGlobals(){try{const{modelGlobalNames}=await import("@stacksjs/orm");return(modelGlobalNames??[]).map((name)=>({name,file:"@stacksjs/orm",isDefault:!1}))}catch{return[]}}export async function injectGlobalAutoImports(){if(globalThis.__stacksAutoImportsInjected)return;globalThis.__stacksAutoImportsInjected=!0;const errors=[],importWithTimeout=async(pkg)=>{let timer;try{return await Promise.race([import(pkg),new Promise((_,reject)=>{timer=setTimeout(()=>reject(Error(`auto-import timed out: ${pkg}`)),4000)})])}finally{if(timer!==void 0)clearTimeout(timer)}};await Promise.all(primitiveModules.map(async([pkg,names])=>{try{const mod=await importWithTimeout(pkg);for(const name of names)if(mod[name]!==void 0)globalThis[name]=mod[name]}catch(err){errors.push(err)}}));try{const{ensureLocalesLoaded}=await import("@stacksjs/i18n");await ensureLocalesLoaded()}catch(err){errors.push(err)}const barrels=COMBINED_BARRELS,injected=[];for(const barrel of barrels){const barrelPath=path.storagePath(`framework/auto-imports/${barrel}.ts`);if(!existsSync(barrelPath))continue;try{const mod=await import(barrelPath);Object.assign(globalThis,mod);injected.push(barrel)}catch(err){log.warn(`[auto-imports] ${barrel}.ts failed to load, so nothing it exports is available. Views and actions referencing them will throw "is not defined". Cause: ${err.message}`)}}if(!injected.includes("models")&&existsSync(path.storagePath("framework/auto-imports/models.ts")))log.warn("[auto-imports] No models were injected. Every model reference in stx views and actions will be undefined.");try{const{registerAppListeners}=await import("@stacksjs/events");await registerAppListeners()}catch(err){errors.push(err)}try{const{initializeAuthorization}=await import("@stacksjs/auth");await initializeAuthorization()}catch(err){errors.push(err)}if(errors.length)for(const err of errors)console.warn("[auto-imports]",err.message)}
13
+ `);return removed}async function ormModelGlobals(){try{const{modelGlobalNames}=await import("@stacksjs/orm");return(modelGlobalNames??[]).map((name)=>({name,file:"@stacksjs/orm",isDefault:!1}))}catch{return[]}}export async function injectGlobalAutoImports(){if(globalThis.__stacksAutoImportsInjected)return;globalThis.__stacksAutoImportsInjected=!0;const errors=[],importWithTimeout=async(pkg)=>{let timer;try{return await Promise.race([import(pkg),new Promise((_,reject)=>{timer=setTimeout(()=>reject(Error(`auto-import timed out: ${pkg}`)),4000)})])}finally{if(timer!==void 0)clearTimeout(timer)}};await Promise.all(primitiveModules.map(async([pkg,names])=>{try{const mod=await importWithTimeout(pkg);for(const name of names)if(mod[name]!==void 0)globalThis[name]=mod[name]}catch(err){errors.push(err)}}));try{const{ensureLocalesLoaded}=await import("@stacksjs/i18n");await ensureLocalesLoaded()}catch(err){errors.push(err)}const barrels=COMBINED_BARRELS,injected=[];for(const barrel of barrels){const barrelPath=path.storagePath(`framework/auto-imports/${barrel}.ts`);if(!existsSync(barrelPath))continue;try{const mod=await import(barrelPath);Object.assign(globalThis,mod);injected.push(barrel)}catch(err){log.warn(`[auto-imports] ${barrel}.ts failed to load, so nothing it exports is available. Views and actions referencing them will throw "is not defined". Cause: ${err.message}`)}}if(!injected.includes("models")&&existsSync(path.storagePath("framework/auto-imports/models.ts")))log.warn("[auto-imports] No models were injected. Every model reference in stx views and actions will be undefined.");try{const{bootAppListeners}=await import("@stacksjs/events");await bootAppListeners({base:path.projectPath()})}catch(err){errors.push(err)}try{const{initializeAuthorization}=await import("@stacksjs/auth");await initializeAuthorization()}catch(err){errors.push(err)}if(errors.length)for(const err of errors)console.warn("[auto-imports]",err.message)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/server",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.35",
5
+ "version": "0.75.37",
6
6
  "description": "Local development and production-ready.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -58,19 +58,19 @@
58
58
  "prepublishOnly": "bun run build"
59
59
  },
60
60
  "dependencies": {
61
- "@stacksjs/auth": "0.75.35",
62
- "@stacksjs/config": "0.75.35",
63
- "@stacksjs/events": "0.75.35",
64
- "@stacksjs/i18n": "0.75.35",
65
- "@stacksjs/logging": "0.75.35",
66
- "@stacksjs/orm": "0.75.35",
67
- "@stacksjs/path": "0.75.35",
68
- "@stacksjs/router": "0.75.35",
69
- "@stacksjs/storage": "0.75.35",
61
+ "@stacksjs/auth": "0.75.37",
62
+ "@stacksjs/config": "0.75.37",
63
+ "@stacksjs/events": "0.75.37",
64
+ "@stacksjs/i18n": "0.75.37",
65
+ "@stacksjs/logging": "0.75.37",
66
+ "@stacksjs/orm": "0.75.37",
67
+ "@stacksjs/path": "0.75.37",
68
+ "@stacksjs/router": "0.75.37",
69
+ "@stacksjs/storage": "0.75.37",
70
70
  "bun-plugin-auto-imports": "^0.4.3"
71
71
  },
72
72
  "devDependencies": {
73
- "@stacksjs/validation": "0.75.35",
73
+ "@stacksjs/validation": "0.75.37",
74
74
  "better-dx": "^0.2.24"
75
75
  }
76
76
  }