@@ -32,7 +32,7 @@ let container = {
3232 translation : { } ,
3333 /** @type {Result | null } */
3434 result : null ,
35- sharedKeys : new Set ( ) // Track keys shared via share() function
35+ sharedKeys : new Set ( ) , // Track keys shared via share() function
3636}
3737
3838/**
@@ -202,6 +202,15 @@ class Container {
202202 static append ( newContainer ) {
203203 container = deepMerge ( container , newContainer )
204204
205+ // If new helpers are added, set the helpers property on them
206+ if ( newContainer . helpers ) {
207+ for ( const name in newContainer . helpers ) {
208+ if ( container . helpers [ name ] && typeof container . helpers [ name ] === 'object' ) {
209+ container . helpers [ name ] . helpers = container . helpers
210+ }
211+ }
212+ }
213+
205214 // If new support objects are added, update the proxy support
206215 if ( newContainer . support ) {
207216 const newProxySupport = createSupportObjects ( newContainer . support )
@@ -250,10 +259,10 @@ class Container {
250259 // Instead of using append which replaces the entire container,
251260 // directly update the support object to maintain proxy references
252261 Object . assign ( container . support , data )
253-
262+
254263 // Track which keys were explicitly shared
255264 Object . keys ( data ) . forEach ( key => container . sharedKeys . add ( key ) )
256-
265+
257266 if ( ! options . local ) {
258267 WorkerStorage . share ( data )
259268 }
@@ -349,6 +358,16 @@ async function createHelpers(config) {
349358 }
350359 }
351360
361+ // Set helpers property on each helper to allow access to other helpers
362+ for ( const name in helpers ) {
363+ if ( helpers [ name ] && typeof helpers [ name ] === 'object' ) {
364+ helpers [ name ] . helpers = helpers
365+ }
366+ }
367+
368+ // Wait for async helpers and call _init
369+ await asyncHelperPromise
370+
352371 for ( const name in helpers ) {
353372 if ( helpers [ name ] . _init ) await helpers [ name ] . _init ( )
354373 }
@@ -677,24 +696,23 @@ async function loadSupportObject(modulePath, supportObjectName) {
677696 // Use dynamic import for both ESM and CJS modules
678697 let importPath = modulePath
679698 let tempJsFile = null
680-
699+
681700 if ( typeof importPath === 'string' ) {
682701 const ext = path . extname ( importPath )
683-
702+
684703 // Handle TypeScript files
685704 if ( ext === '.ts' ) {
686705 try {
687706 // Use the TypeScript transpilation utility
688707 const typescript = await import ( 'typescript' )
689708 const { tempFile, allTempFiles } = await transpileTypeScript ( importPath , typescript )
690-
709+
691710 debug ( `Transpiled TypeScript file: ${ importPath } -> ${ tempFile } ` )
692-
711+
693712 // Attach cleanup handler
694713 importPath = tempFile
695714 // Store temp files list in a way that cleanup can access them
696715 tempJsFile = allTempFiles
697-
698716 } catch ( tsError ) {
699717 throw new Error ( `Failed to load TypeScript file ${ importPath } : ${ tsError . message } . Make sure 'typescript' package is installed.` )
700718 }
@@ -703,7 +721,7 @@ async function loadSupportObject(modulePath, supportObjectName) {
703721 importPath = `${ importPath } .js`
704722 }
705723 }
706-
724+
707725 let obj
708726 try {
709727 obj = await import ( importPath )
0 commit comments