@stacksjs/server 0.75.264 → 0.75.266
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/dist/imports.d.ts +8 -6
- package/dist/imports.js +1 -1
- package/package.json +12 -12
package/dist/imports.d.ts
CHANGED
|
@@ -139,13 +139,15 @@ export declare function generateServerAutoImportTypes(): Promise<void>;
|
|
|
139
139
|
*/
|
|
140
140
|
export declare function pruneBrowserAutoImportTypes(): Promise<string[]>;
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
142
|
+
* Puts an auto-import barrel's exports on `target` (globalThis), except a name
|
|
143
|
+
* the platform already defines. An app's model called `Event` (a race on a
|
|
144
|
+
* calendar) replaced the DOM `Event` class for the whole server, and every
|
|
145
|
+
* library built on it stopped loading: `stripe` extends `Event`, threw "The
|
|
146
|
+
* superclass is not a constructor", and @stacksjs/payments reported it as "the
|
|
147
|
+
* `stripe` package is not installed". The model stays importable; only the
|
|
148
|
+
* global goes to the platform. Returns the names it left out.
|
|
148
149
|
*/
|
|
150
|
+
export declare function assignBarrelGlobals(target: Record<string, unknown>, mod: Record<string, unknown>, platformNames: ReadonlySet<string>): string[];
|
|
149
151
|
export declare function injectGlobalAutoImports(): Promise<void>;
|
|
150
152
|
/**
|
|
151
153
|
* Generate runtime auto-import files for Bun runtime execution.
|
package/dist/imports.js
CHANGED
|
@@ -12,4 +12,4 @@ var {require}=import.meta;import{existsSync,readFileSync,renameSync,statSync,unl
|
|
|
12
12
|
`)){const match=/^export \{ default as (\w+) \} from '([^']+)'/.exec(line.trim());if(!match)continue;const[,name,relativePath]=match,specifier=relativePath,file=specifier.startsWith(".")||isAbsolute(specifier)?resolvePath(outputDir,specifier.endsWith(".ts")?specifier:`${specifier}.ts`):specifier;found.push({name,file,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(`
|
|
13
13
|
`)){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(`
|
|
14
14
|
`);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)}
|
|
15
|
-
`);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)
|
|
15
|
+
`);return removed}async function ormModelGlobals(){try{const{modelGlobalNames}=await import("@stacksjs/orm");return(modelGlobalNames??[]).map((name)=>({name,file:"@stacksjs/orm",isDefault:!1}))}catch{return[]}}let platformGlobalNames=null;export function assignBarrelGlobals(target,mod,platformNames){const skipped=[];for(const[name,value]of Object.entries(mod)){if(platformNames.has(name)){skipped.push(name);continue}target[name]=value}return skipped}export async function injectGlobalAutoImports(){if(globalThis.__stacksAutoImportsInjected)return;globalThis.__stacksAutoImportsInjected=!0;platformGlobalNames??=new Set(Object.getOwnPropertyNames(globalThis));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),kept=assignBarrelGlobals(globalThis,mod,platformGlobalNames);if(kept.length)log.warn(`[auto-imports] ${kept.join(", ")} from ${barrel}.ts ${kept.length===1?"is":"are"} not global: ${kept.length===1?"it":"they"} would replace the platform's own, which libraries rely on. Import ${kept.length===1?"it":"them"} where used.`);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.
|
|
5
|
+
"version": "0.75.266",
|
|
6
6
|
"description": "Local development and production-ready.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@stacksjs/auth": "0.75.
|
|
61
|
+
"@stacksjs/auth": "0.75.266",
|
|
62
62
|
"@stacksjs/bun-router": "^0.1.24",
|
|
63
|
-
"@stacksjs/config": "0.75.
|
|
64
|
-
"@stacksjs/events": "0.75.
|
|
65
|
-
"@stacksjs/i18n": "0.75.
|
|
66
|
-
"@stacksjs/logging": "0.75.
|
|
67
|
-
"@stacksjs/orm": "0.75.
|
|
68
|
-
"@stacksjs/path": "0.75.
|
|
69
|
-
"@stacksjs/payments": "0.75.
|
|
70
|
-
"@stacksjs/router": "0.75.
|
|
71
|
-
"@stacksjs/storage": "0.75.
|
|
63
|
+
"@stacksjs/config": "0.75.266",
|
|
64
|
+
"@stacksjs/events": "0.75.266",
|
|
65
|
+
"@stacksjs/i18n": "0.75.266",
|
|
66
|
+
"@stacksjs/logging": "0.75.266",
|
|
67
|
+
"@stacksjs/orm": "0.75.266",
|
|
68
|
+
"@stacksjs/path": "0.75.266",
|
|
69
|
+
"@stacksjs/payments": "0.75.266",
|
|
70
|
+
"@stacksjs/router": "0.75.266",
|
|
71
|
+
"@stacksjs/storage": "0.75.266",
|
|
72
72
|
"bun-plugin-auto-imports": "^0.4.4"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@stacksjs/validation": "0.75.
|
|
75
|
+
"@stacksjs/validation": "0.75.266",
|
|
76
76
|
"better-dx": "^0.2.24"
|
|
77
77
|
}
|
|
78
78
|
}
|