( compartmentPrivateFields, staticModuleRecord, compartment, moduleAliases, moduleSpecifier, resolvedImports)
| 8461 | const { quote: q}= assert; |
| 8462 | |
| 8463 | const makeThirdPartyModuleInstance= ( |
| 8464 | compartmentPrivateFields, |
| 8465 | staticModuleRecord, |
| 8466 | compartment, |
| 8467 | moduleAliases, |
| 8468 | moduleSpecifier, |
| 8469 | resolvedImports)=> |
| 8470 | { |
| 8471 | const { exportsProxy, exportsTarget, activate}= getDeferredExports( |
| 8472 | compartment, |
| 8473 | weakmapGet(compartmentPrivateFields, compartment), |
| 8474 | moduleAliases, |
| 8475 | moduleSpecifier); |
| 8476 | |
| 8477 | |
| 8478 | const notifiers= create(null); |
| 8479 | |
| 8480 | if( staticModuleRecord.exports) { |
| 8481 | if( |
| 8482 | !isArray(staticModuleRecord.exports)|| |
| 8483 | arraySome(staticModuleRecord.exports, (name)=>typeof name!== 'string')) |
| 8484 | { |
| 8485 | throw TypeError( |
| 8486 | `SES third-party static module record "exports" property must be an array of strings for module ${moduleSpecifier}`); |
| 8487 | |
| 8488 | } |
| 8489 | arrayForEach(staticModuleRecord.exports, (name)=>{ |
| 8490 | let value= exportsTarget[name]; |
| 8491 | const updaters= []; |
| 8492 | |
| 8493 | const get= ()=> value; |
| 8494 | |
| 8495 | const set= (newValue)=>{ |
| 8496 | value= newValue; |
| 8497 | for( const updater of updaters) { |
| 8498 | updater(newValue); |
| 8499 | } |
| 8500 | }; |
| 8501 | |
| 8502 | defineProperty(exportsTarget, name, { |
| 8503 | get, |
| 8504 | set, |
| 8505 | enumerable: true, |
| 8506 | configurable: false}); |
| 8507 | |
| 8508 | |
| 8509 | notifiers[name]= (update)=>{ |
| 8510 | arrayPush(updaters, update); |
| 8511 | update(value); |
| 8512 | }; |
| 8513 | }); |
| 8514 | // This is enough to support import * from cjs - the '*' field doesn't need to be in exports nor exportsTarget because import will only ever access it via notifiers |
| 8515 | notifiers['*']= (update)=>{ |
| 8516 | update(exportsTarget); |
| 8517 | }; |
| 8518 | } |
| 8519 | |
| 8520 | const localState= { |
no test coverage detected