@@ -208,8 +208,8 @@ var mustBeInteger = (value) => typeof value === "number" && value === (value | 0
208
208
var mustBeFunction = ( value ) => typeof value === "function" ? null : "a function" ;
209
209
var mustBeArray = ( value ) => Array . isArray ( value ) ? null : "an array" ;
210
210
var mustBeObject = ( value ) => typeof value === "object" && value !== null && ! Array . isArray ( value ) ? null : "an object" ;
211
+ var mustBeEntryPoints = ( value ) => typeof value === "object" && value !== null ? null : "an array or an object" ;
211
212
var mustBeWebAssemblyModule = ( value ) => value instanceof WebAssembly . Module ? null : "a WebAssembly.Module" ;
212
- var mustBeArrayOrRecord = ( value ) => typeof value === "object" && value !== null ? null : "an array or an object" ;
213
213
var mustBeObjectOrNull = ( value ) => typeof value === "object" && ! Array . isArray ( value ) ? null : "an object or null" ;
214
214
var mustBeStringOrBoolean = ( value ) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean" ;
215
215
var mustBeStringOrObject = ( value ) => typeof value === "string" || typeof value === "object" && value !== null && ! Array . isArray ( value ) ? null : "a string or an object" ;
@@ -423,7 +423,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
423
423
let inject = getFlag ( options , keys , "inject" , mustBeArray ) ;
424
424
let banner = getFlag ( options , keys , "banner" , mustBeObject ) ;
425
425
let footer = getFlag ( options , keys , "footer" , mustBeObject ) ;
426
- let entryPoints = getFlag ( options , keys , "entryPoints" , mustBeArrayOrRecord ) ;
426
+ let entryPoints = getFlag ( options , keys , "entryPoints" , mustBeEntryPoints ) ;
427
427
let absWorkingDir = getFlag ( options , keys , "absWorkingDir" , mustBeString ) ;
428
428
let stdin = getFlag ( options , keys , "stdin" , mustBeObject ) ;
429
429
let write = getFlag ( options , keys , "write" , mustBeBoolean ) ?? writeDefault ;
@@ -534,8 +534,21 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
534
534
}
535
535
if ( entryPoints ) {
536
536
if ( Array . isArray ( entryPoints ) ) {
537
- for ( let entryPoint of entryPoints ) {
538
- entries . push ( [ "" , validateStringValue ( entryPoint , "entry point" ) ] ) ;
537
+ for ( let i = 0 , n = entryPoints . length ; i < n ; i ++ ) {
538
+ let entryPoint = entryPoints [ i ] ;
539
+ if ( typeof entryPoint === "object" && entryPoint !== null ) {
540
+ let entryPointKeys = /* @__PURE__ */ Object . create ( null ) ;
541
+ let input = getFlag ( entryPoint , entryPointKeys , "in" , mustBeString ) ;
542
+ let output = getFlag ( entryPoint , entryPointKeys , "out" , mustBeString ) ;
543
+ checkForInvalidFlags ( entryPoint , entryPointKeys , "in entry point at index " + i ) ;
544
+ if ( input === void 0 )
545
+ throw new Error ( 'Missing property "in" for entry point at index ' + i ) ;
546
+ if ( output === void 0 )
547
+ throw new Error ( 'Missing property "out" for entry point at index ' + i ) ;
548
+ entries . push ( [ output , input ] ) ;
549
+ } else {
550
+ entries . push ( [ "" , validateStringValue ( entryPoint , "entry point at index " + i ) ] ) ;
551
+ }
539
552
}
540
553
} else {
541
554
for ( let key in entryPoints ) {
@@ -698,8 +711,8 @@ function createChannel(streamIn) {
698
711
if ( isFirstPacket ) {
699
712
isFirstPacket = false ;
700
713
let binaryVersion = String . fromCharCode ( ...bytes ) ;
701
- if ( binaryVersion !== "0.17.0 " ) {
702
- throw new Error ( `Cannot start service: Host version "${ "0.17.0 " } " does not match binary version ${ quote ( binaryVersion ) } ` ) ;
714
+ if ( binaryVersion !== "0.17.11 " ) {
715
+ throw new Error ( `Cannot start service: Host version "${ "0.17.11 " } " does not match binary version ${ quote ( binaryVersion ) } ` ) ;
703
716
}
704
717
return ;
705
718
}
@@ -943,7 +956,7 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
943
956
if ( ! result . ok )
944
957
return handleError ( result . error , result . pluginName ) ;
945
958
try {
946
- buildOrContextContinue ( result . requestPlugins , result . runOnEndCallbacks ) ;
959
+ buildOrContextContinue ( result . requestPlugins , result . runOnEndCallbacks , result . scheduleOnDisposeCallbacks ) ;
947
960
} catch ( e ) {
948
961
handleError ( e , "" ) ;
949
962
}
@@ -953,11 +966,12 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
953
966
return ;
954
967
}
955
968
try {
956
- buildOrContextContinue ( null , ( result , done ) => done ( [ ] , [ ] ) ) ;
969
+ buildOrContextContinue ( null , ( result , done ) => done ( [ ] , [ ] ) , ( ) => {
970
+ } ) ;
957
971
} catch ( e ) {
958
972
handleError ( e , "" ) ;
959
973
}
960
- function buildOrContextContinue ( requestPlugins , runOnEndCallbacks ) {
974
+ function buildOrContextContinue ( requestPlugins , runOnEndCallbacks , scheduleOnDisposeCallbacks ) {
961
975
const writeDefault = streamIn . hasFS ;
962
976
const {
963
977
entries,
@@ -1034,7 +1048,10 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1034
1048
if ( error )
1035
1049
return callback ( new Error ( error ) , null ) ;
1036
1050
if ( ! isContext ) {
1037
- return buildResponseToResult ( response , callback ) ;
1051
+ return buildResponseToResult ( response , ( err , res ) => {
1052
+ scheduleOnDisposeCallbacks ( ) ;
1053
+ return callback ( err , res ) ;
1054
+ } ) ;
1038
1055
}
1039
1056
if ( response . errors . length > 0 ) {
1040
1057
return callback ( failureErrorWithLog ( "Context failed" , response . errors , response . warnings ) , null ) ;
@@ -1122,15 +1139,28 @@ function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs,
1122
1139
resolve ( response2 ) ;
1123
1140
} ) ;
1124
1141
} ) ,
1142
+ cancel : ( ) => new Promise ( ( resolve ) => {
1143
+ if ( didDispose )
1144
+ return resolve ( ) ;
1145
+ const request2 = {
1146
+ command : "cancel" ,
1147
+ key : buildKey
1148
+ } ;
1149
+ sendRequest ( refs , request2 , ( ) => {
1150
+ resolve ( ) ;
1151
+ } ) ;
1152
+ } ) ,
1125
1153
dispose : ( ) => new Promise ( ( resolve ) => {
1126
1154
if ( didDispose )
1127
1155
return resolve ( ) ;
1156
+ didDispose = true ;
1128
1157
const request2 = {
1129
1158
command : "dispose" ,
1130
1159
key : buildKey
1131
1160
} ;
1132
1161
sendRequest ( refs , request2 , ( ) => {
1133
1162
resolve ( ) ;
1163
+ scheduleOnDisposeCallbacks ( ) ;
1134
1164
refs . unref ( ) ;
1135
1165
} ) ;
1136
1166
} )
@@ -1145,6 +1175,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1145
1175
let onEndCallbacks = [ ] ;
1146
1176
let onResolveCallbacks = { } ;
1147
1177
let onLoadCallbacks = { } ;
1178
+ let onDisposeCallbacks = [ ] ;
1148
1179
let nextCallbackID = 0 ;
1149
1180
let i = 0 ;
1150
1181
let requestPlugins = [ ] ;
@@ -1262,6 +1293,9 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1262
1293
onLoadCallbacks [ id ] = { name, callback, note : registeredNote } ;
1263
1294
plugin . onLoad . push ( { id, filter : filter . source , namespace : namespace || "" } ) ;
1264
1295
} ,
1296
+ onDispose ( callback ) {
1297
+ onDisposeCallbacks . push ( callback ) ;
1298
+ } ,
1265
1299
esbuild : streamIn . esbuild
1266
1300
} ) ;
1267
1301
if ( promise )
@@ -1455,11 +1489,17 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
1455
1489
} ) ( ) ;
1456
1490
} ;
1457
1491
}
1492
+ let scheduleOnDisposeCallbacks = ( ) => {
1493
+ for ( const cb of onDisposeCallbacks ) {
1494
+ setTimeout ( ( ) => cb ( ) , 0 ) ;
1495
+ }
1496
+ } ;
1458
1497
isSetupDone = true ;
1459
1498
return {
1460
1499
ok : true ,
1461
1500
requestPlugins,
1462
- runOnEndCallbacks
1501
+ runOnEndCallbacks,
1502
+ scheduleOnDisposeCallbacks
1463
1503
} ;
1464
1504
} ;
1465
1505
function createObjectStash ( ) {
@@ -1667,7 +1707,7 @@ function convertOutputFiles({ path, contents }) {
1667
1707
1668
1708
// lib/deno/mod.ts
1669
1709
import * as denoflate from "https://deno.land/x/denoflate@1.2.1/mod.ts" ;
1670
- var version = "0.17.0 " ;
1710
+ var version = "0.17.11 " ;
1671
1711
var build = ( options ) => ensureServiceIsRunning ( ) . then ( ( service ) => service . build ( options ) ) ;
1672
1712
var context = ( options ) => ensureServiceIsRunning ( ) . then ( ( service ) => service . context ( options ) ) ;
1673
1713
var transform = ( input , options ) => ensureServiceIsRunning ( ) . then ( ( service ) => service . transform ( input , options ) ) ;
0 commit comments