diff --git a/apps/wing/src/commands/pack.test.ts b/apps/wing/src/commands/pack.test.ts index 3bc815e0143..d424bb258ba 100644 --- a/apps/wing/src/commands/pack.test.ts +++ b/apps/wing/src/commands/pack.test.ts @@ -200,6 +200,7 @@ describe("wing pack", () => { expect(mod).toBeDefined(); expect(Object.keys(mod).sort()).toMatchInlineSnapshot(` [ + "$preflightTypesMap", "FavoriteNumbers", "Store", "default", diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index 1dfeaceedaf..e23242ddb45 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -1,18 +1,54 @@ -// https://github.com/winglang/wing/issues/2730 -// FAILING: +bring cloud; +bring "./subdir2" as subdir; -// bring cloud; +let b = new cloud.Bucket(); -// let b = new cloud.Bucket(); -// let myConst = "bang bang"; +inflight class Foo { + pub uploadToBucket(k: str, value: str) { + b.put(k, value); + assert(b.get(k) == value); + } -// inflight class Foo { -// uploadToBucket(k: str, value: str) { -// b.put(k, value); -// } -// } + static pub fooStatic() { + b.put("a", "b"); + assert(b.list() == ["a"]); + } +} -// test "inflight class captures preflight resource" { -// let f = new Foo(); -// f.uploadToBucket("hello.txt", "world"); -// } +test "inflight class captures preflight resource" { + let f = new Foo(); + f.uploadToBucket("hello.txt", "world"); +} + +test "inflight class type captures preflight resource" { + Foo.fooStatic(); +} + + +let getFoo = inflight () => { + return new Foo(); +}; + +test "inflight class qualified without explicit reference" { + // Get instance of Foo without mentioning the type + let foo = getFoo(); + // Now Foo needs to be qualified correcly + foo.uploadToBucket("greetings.txt", "universe"); +} + +test "inflight class defined inflight captures preflight object" { + class Foo2 { + pub uploadToBucket() { + b.put("x", "y"); + assert(b.get("x") == "y"); + } + } + + let f = new Foo2(); + f.uploadToBucket(); +} + +test "bring inflight class from subdir" { + let x = new subdir.InflightClass(); + assert(x.method() == "What did you expect?"); +} diff --git a/examples/tests/valid/subdir2/inflight_class.w b/examples/tests/valid/subdir2/inflight_class.w new file mode 100644 index 00000000000..bdf37243fe0 --- /dev/null +++ b/examples/tests/valid/subdir2/inflight_class.w @@ -0,0 +1,5 @@ +pub inflight class InflightClass { + pub method(): str { + return "What did you expect?"; + } +} \ No newline at end of file diff --git a/libs/wingc/src/dtsify/snapshots/declarations.snap b/libs/wingc/src/dtsify/snapshots/declarations.snap index 98f93db09e3..59471505957 100644 --- a/libs/wingc/src/dtsify/snapshots/declarations.snap +++ b/libs/wingc/src/dtsify/snapshots/declarations.snap @@ -105,9 +105,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.lib-1.cjs"), -}; +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` @@ -125,6 +125,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class InflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -155,6 +156,8 @@ class InflightClass extends $stdlib.std.Resource { }); } } +if ($preflightTypesMap[1]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[1] = InflightClass; class ParentClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -186,12 +189,14 @@ class ParentClass extends $stdlib.std.Resource { "bar": [ ], "$inflight_init": [ + [InflightClass, []], ], }); } static get _liftTypeMap() { return ({ "static_method": [ + [InflightClass, []], ], }); } @@ -225,7 +230,7 @@ class Child extends ParentClass { }); } } -module.exports = { InflightClass, ParentClass, Child }; +module.exports = { $preflightTypesMap, InflightClass, ParentClass, Child }; //# sourceMappingURL=preflight.lib-1.cjs.map ``` diff --git a/libs/wingc/src/dtsify/snapshots/optionals.snap b/libs/wingc/src/dtsify/snapshots/optionals.snap index deac88efa6f..f2ec550c899 100644 --- a/libs/wingc/src/dtsify/snapshots/optionals.snap +++ b/libs/wingc/src/dtsify/snapshots/optionals.snap @@ -46,9 +46,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.lib-1.cjs"), -}; +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` @@ -66,6 +66,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class ParentClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -96,7 +97,7 @@ class ParentClass extends $stdlib.std.Resource { }); } } -module.exports = { ParentClass }; +module.exports = { $preflightTypesMap, ParentClass }; //# sourceMappingURL=preflight.lib-1.cjs.map ``` diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index bba287f31a7..93d8d35c89a 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -41,8 +41,8 @@ const PREFLIGHT_FILE_NAME: &str = "preflight.cjs"; const STDLIB: &str = "$stdlib"; const STDLIB_CORE: &str = formatcp!("{STDLIB}.core"); -const STDLIB_CORE_RESOURCE: &str = formatcp!("{}.{}", STDLIB, WINGSDK_RESOURCE); -const STDLIB_CORE_AUTOID_RESOURCE: &str = formatcp!("{}.{}", STDLIB, WINGSDK_AUTOID_RESOURCE); +const STDLIB_CORE_RESOURCE: &str = formatcp!("{STDLIB}.{WINGSDK_RESOURCE}"); +const STDLIB_CORE_AUTOID_RESOURCE: &str = formatcp!("{STDLIB}.{WINGSDK_AUTOID_RESOURCE}"); const STDLIB_MODULE: &str = WINGSDK_ASSEMBLY_NAME; const ENV_WING_IS_TEST: &str = "$wing_is_test"; @@ -59,6 +59,9 @@ const __DIRNAME: &str = "__dirname"; const SUPER_CLASS_INFLIGHT_INIT_NAME: &str = formatcp!("super_{CLASS_INFLIGHT_INIT_NAME}"); +const PREFLIGHT_TYPES_MAP: &str = "$helpers.nodeof(this).root.$preflightTypesMap"; +const MODULE_PREFLIGHT_TYPES_MAP: &str = "$preflightTypesMap"; + const SCOPE_PARAM: &str = "$scope"; pub struct JSifyContext<'a> { @@ -100,7 +103,7 @@ impl VisitorWithContext for JSifyContext<'_> { /// Preflight classes have two types of host binding methods: /// `Type` for binding static fields and methods to the host and /// `instance` for binding instance fields and methods to the host. -#[derive(PartialEq, Eq)] +#[derive(PartialEq)] enum BindMethod { Type, Instance, @@ -154,11 +157,7 @@ impl<'a> JSifier<'a> { }) { let scope_env = self.types.get_scope_env(&scope); let s = self.jsify_statement(&scope_env, statement, &mut jsify_context); // top level statements are always preflight - if let StmtKind::Bring { - identifier: _, - source: _, - } = statement.kind - { + if matches!(statement.kind, StmtKind::Bring { .. }) { imports.add_code(s); } else { js.add_code(s); @@ -193,14 +192,23 @@ impl<'a> JSifier<'a> { output.line(format!( "const {EXTERN_VAR} = {HELPERS_VAR}.createExternRequire({__DIRNAME});" )); - output.add_code(imports); if is_entrypoint { let mut root_class = CodeMaker::default(); root_class.open(format!("class {} extends {} {{", ROOT_CLASS, STDLIB_CORE_RESOURCE)); root_class.open(format!("{JS_CONSTRUCTOR}({SCOPE_PARAM}, $id) {{")); root_class.line(format!("super({SCOPE_PARAM}, $id);")); + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {{ }};")); + + // The root preflight types map + root_class.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + + root_class.add_code(imports); root_class.add_code(self.jsify_struct_schemas(source_path)); + + // A global map pointing to the root preflight types map + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {MODULE_PREFLIGHT_TYPES_MAP};")); + root_class.add_code(js); root_class.close("}"); root_class.close("}"); @@ -220,35 +228,43 @@ impl<'a> JSifier<'a> { let directory_children = self.source_file_graph.dependencies_of(source_path); let preflight_file_map = self.preflight_file_map.borrow(); - // supposing a directory has two files and two subdirectories in it, + // supposing a directory has a file and a subdirectory in it, // we generate code like this: // ``` - // module.exports = { - // get inner_directory1() { return require("./preflight.inner-directory1.cjs") }, - // get inner_directory2() { return require("./preflight.inner-directory2.cjs") }, - // ...require("./preflight.inner-file1.cjs"), - // ...require("./preflight.inner-file2.cjs"), - // }; + // let $preflightTypesMap = {}; + // Object.assign(module.exports, $helpers.bringJs("./preflight.inner-file1.js", $preflightTypesMap)); + // Object.assign(module.exports, { get inner_directory1() { $helpers.bringJs("./preflight.inner-directory1.js", $preflightTypesMap); } }); + // module.exports = { ...module.exports, $preflightTypesMap }; // ``` - output.open("module.exports = {"); + + // This module's preflight type map + output.line(format!("const {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + for file in directory_children { let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); if file.is_dir() { let directory_name = file.file_stem().unwrap(); output.line(format!( - "get {directory_name}() {{ return require(\"./{preflight_file_name}\") }}," + "Object.assign(module.exports, {{ get {directory_name}() {{ return $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP}); }} }});" )); } else { - output.line(format!("...require(\"./{preflight_file_name}\"),")); + output.line(format!( + "Object.assign(module.exports, $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP}));" + )); } } - output.close("};"); + output.line(format!( + "module.exports = {{ ...module.exports, {MODULE_PREFLIGHT_TYPES_MAP} }};" + )); } else { + // This module's preflight type map + output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + output.add_code(imports); output.add_code(self.jsify_struct_schemas(source_path)); output.add_code(js); let exports = get_public_symbols(&scope); output.line(format!( - "module.exports = {{ {} }};", + "module.exports = {{ {MODULE_PREFLIGHT_TYPES_MAP}, {} }};", exports.iter().map(ToString::to_string).join(", ") )); } @@ -1166,10 +1182,7 @@ impl<'a> JSifier<'a> { code.line(format!("const {var_name} = {STDLIB}.{name};")) } BringSource::TrustedModule(name, module_dir) => { - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(module_dir).unwrap(); - let var_name = identifier.as_ref().unwrap_or(&name); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + code.append(self.jsify_bring_stmt(module_dir, &Some(identifier.as_ref().unwrap_or(name).clone()))); } BringSource::JsiiModule(name) => { // checked during type checking @@ -1177,25 +1190,10 @@ impl<'a> JSifier<'a> { code.line(format!("const {var_name} = require(\"{name}\");")) } BringSource::WingLibrary(_, module_dir) => { - // checked during type checking - let var_name = identifier.as_ref().expect("bring wing library requires an alias"); - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(module_dir).unwrap(); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) - } - BringSource::WingFile(path) => { - // checked during type checking - let var_name = identifier.as_ref().expect("bring wing file requires an alias"); - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(path).unwrap(); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + code.append(self.jsify_bring_stmt(module_dir, identifier)); } - BringSource::Directory(path) => { - // checked during type checking - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(path).unwrap(); - let var_name = identifier.as_ref().expect("bring wing directory requires an alias"); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + BringSource::Directory(path) | BringSource::WingFile(path) => { + code.append(self.jsify_bring_stmt(path, identifier)); } }, StmtKind::SuperConstructor { arg_list } => { @@ -1498,6 +1496,18 @@ impl<'a> JSifier<'a> { code } + fn jsify_bring_stmt(&self, path: &Utf8Path, identifier: &Option) -> CodeMaker { + let mut code = CodeMaker::default(); + // checked during type checking + let var_name = identifier.as_ref().expect("bring wing module requires an alias"); + let preflight_file_map = self.preflight_file_map.borrow(); + let preflight_file_name = preflight_file_map.get(path).unwrap(); + code.line(format!( + "const {var_name} = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP});" + )); + code + } + fn jsify_enum(&self, name: &Symbol, values: &IndexMap>) -> CodeMaker { let mut code = CodeMaker::with_source(&name.span); let mut value_index = 0; @@ -1849,10 +1859,32 @@ impl<'a> JSifier<'a> { code.add_code(self.jsify_register_bind_method(class, class_type, BindMethod::Type, ctx)); code.close("}"); + + // Inflight classes might need to be lift-qualified (onLift), but their type name might not be necessarily available + // at the scope when they are qualified (it might even be shadowed by another type name). We store a reference to these + // class types in a global preflight types map indexed by the class's unique id. + if class.phase == Phase::Inflight { + code.line(format!( + "if ({MODULE_PREFLIGHT_TYPES_MAP}[{}]) {{ throw new Error(\"{} is already in type map\"); }}", + class_type.as_class().unwrap().uid, + class.name + )); + code.line(format!( + "{MODULE_PREFLIGHT_TYPES_MAP}[{}] = {};", + class_type.as_class().unwrap().uid, + class.name + )); + } + code }) } + pub fn class_singleton(&self, type_: TypeRef) -> String { + let c = type_.as_class().unwrap(); + format!("$helpers.preflightClassSingleton(this, {})", c.uid) + } + fn jsify_preflight_constructor(&self, class: &AstClass, ctx: &mut JSifyContext) -> CodeMaker { let mut code = new_code!( &class.name.span, @@ -2170,9 +2202,9 @@ impl<'a> JSifier<'a> { } } - for m in class.inflight_fields() { - let name = &m.name; - let is_static = m.is_static; + for f in class.inflight_fields() { + let name = &f.name; + let is_static = f.is_static; let filter = match bind_method_kind { BindMethod::Instance => !is_static, BindMethod::Type => is_static, @@ -2197,7 +2229,9 @@ impl<'a> JSifier<'a> { if bind_method_kind == BindMethod::Instance && class.parent.is_some() { // mergeLiftDeps is a helper method that combines the lift deps of the parent class with the // lift deps of this class - bind_method.open(format!("return {STDLIB_CORE}.mergeLiftDeps(super._liftMap, {{")); + bind_method.open(format!( + "return {STDLIB_CORE}.mergeLiftDeps(super.{bind_method_name}, {{" + )); } else { bind_method.open("return ({".to_string()); } diff --git a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap index ebc433dcb62..c396742c435 100644 --- a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap +++ b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap index b5771fcc0b9..d093b8b3e3f 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap index fdce5f92022..3a47440282e 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap index bd00d29aa47..afc28743af5 100644 --- a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap +++ b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, x) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap index c996859fb2d..ca2c6cc48fd 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap @@ -72,6 +72,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap index 989c402998a..53de74f2c34 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap index a1098a4325a..945f43e89f4 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap @@ -77,10 +77,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap index 1bcabfc5528..188a438eafd 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap @@ -81,6 +81,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap index c5faa235839..e055ea9023c 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap index e2a2891ef78..70cc6660dad 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap index 7793850313b..eef16a40a7e 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/builtins.snap b/libs/wingc/src/jsify/snapshots/builtins.snap index 53008dfdff0..c27f7a970b4 100644 --- a/libs/wingc/src/jsify/snapshots/builtins.snap +++ b/libs/wingc/src/jsify/snapshots/builtins.snap @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index d131a1db629..74ed9c87f61 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -65,6 +65,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -136,6 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap index e34ef9d6acd..4bf1644e044 100644 --- a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap index 09e9197b655..f3d25d6bb08 100644 --- a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap index 855df068e77..f699bc23896 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap @@ -67,6 +67,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap index 7fc9b80532b..79c6953004d 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap index 13cc38e59bb..b2f07c217a5 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap index b5fbf73536b..0ec257d3e11 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap index a758b92f8cc..9a5ef810928 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap index 312283f1f43..0d9c3a3923e 100644 --- a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap +++ b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap @@ -49,10 +49,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -81,9 +84,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [x, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [x, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap index e08d93d3d5f..af034f5f15a 100644 --- a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap +++ b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap @@ -45,10 +45,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_token.snap b/libs/wingc/src/jsify/snapshots/capture_token.snap index 7d280541b37..b4e6974caca 100644 --- a/libs/wingc/src/jsify/snapshots/capture_token.snap +++ b/libs/wingc/src/jsify/snapshots/capture_token.snap @@ -44,10 +44,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap index e33734b441e..0a05c2e625e 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap index 47fb417fa00..979744061a1 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap @@ -57,6 +57,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap index b0d4cbe8f02..af7adb56121 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index 8489eec5041..291806a0b6a 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -61,6 +61,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -89,6 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -116,8 +121,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap index b6277673600..3cfdfa00daa 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index cd7cc8981dd..3a90eddef62 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -100,6 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -127,8 +132,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, ["bar"]], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap index 9254bf82239..12e633ae877 100644 --- a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index ebda1fe8f15..163c019e172 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -64,6 +64,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -92,6 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Base is already in type map"); } + $preflightTypesMap[1] = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -119,8 +124,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Base, []], ], "$inflight_init": [ + [Base, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/closure_field.snap b/libs/wingc/src/jsify/snapshots/closure_field.snap index 22d34a6d686..cb2ea648ef7 100644 --- a/libs/wingc/src/jsify/snapshots/closure_field.snap +++ b/libs/wingc/src/jsify/snapshots/closure_field.snap @@ -106,10 +106,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap index b61f8369c14..5e03a620b84 100644 --- a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap +++ b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap @@ -23,6 +23,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; this; } } diff --git a/libs/wingc/src/jsify/snapshots/enum_value.snap b/libs/wingc/src/jsify/snapshots/enum_value.snap index e48c24d9f1e..759fb0f233f 100644 --- a/libs/wingc/src/jsify/snapshots/enum_value.snap +++ b/libs/wingc/src/jsify/snapshots/enum_value.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["B"] = "B"; @@ -86,9 +89,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [MyEnum, [].concat(["B"], ["C"])], [x, []], ], "$inflight_init": [ + [MyEnum, []], [x, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap index 5257f8a3c70..9b476ad3879 100644 --- a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap @@ -59,6 +59,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap index 15ebf279878..24507645cfb 100644 --- a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap @@ -42,6 +42,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/func_returns_func.snap b/libs/wingc/src/jsify/snapshots/func_returns_func.snap index 2b8e67d67c0..8bb3df26820 100644 --- a/libs/wingc/src/jsify/snapshots/func_returns_func.snap +++ b/libs/wingc/src/jsify/snapshots/func_returns_func.snap @@ -56,6 +56,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/identify_field.snap b/libs/wingc/src/jsify/snapshots/identify_field.snap index 8cdc9ae7a00..bb5fcb10c79 100644 --- a/libs/wingc/src/jsify/snapshots/identify_field.snap +++ b/libs/wingc/src/jsify/snapshots/identify_field.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap index ede8b4806e1..2df0dbd74bc 100644 --- a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap +++ b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap @@ -66,10 +66,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/indirect_capture.snap b/libs/wingc/src/jsify/snapshots/indirect_capture.snap index 15a89bd9a55..8d67de04315 100644 --- a/libs/wingc/src/jsify/snapshots/indirect_capture.snap +++ b/libs/wingc/src/jsify/snapshots/indirect_capture.snap @@ -81,10 +81,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Capture extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap index c496a96fb04..da1e9d8141b 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap @@ -50,6 +50,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 681b87585d6..8a86b9e9704 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -50,6 +50,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -78,6 +81,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("A is already in type map"); } + $preflightTypesMap[1] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -107,6 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap index 80faa3b1138..1e355d4b666 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field.snap b/libs/wingc/src/jsify/snapshots/inflight_field.snap index 0cfde3b80c0..44c9860c391 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field.snap @@ -53,6 +53,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap index f300ef416e6..168eb48e6e2 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 04d361bfed3..fd0b68dc5e0 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -85,6 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[1] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap index 2a44a3b8b81..40650349c5e 100644 --- a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap @@ -69,10 +69,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/json_object.snap b/libs/wingc/src/jsify/snapshots/json_object.snap index 62036dd7fef..e95b6a0cd8f 100644 --- a/libs/wingc/src/jsify/snapshots/json_object.snap +++ b/libs/wingc/src/jsify/snapshots/json_object.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -76,9 +79,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [jsonObj1, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [jsonObj1, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap index b61054c3b05..093f1c00f6a 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap index 229498fdb1d..d845e175d9f 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap index c047a224ca7..a4f169e0d4f 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap @@ -49,10 +49,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap index 3cbfadf715d..7be2754fb37 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap @@ -46,10 +46,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap index 28b88a5ba27..9d50a7be1d5 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap index 4e5080a5db6..e8d95f5729a 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap index a7b5c6332a4..a6390026b34 100644 --- a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap +++ b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_string.snap b/libs/wingc/src/jsify/snapshots/lift_string.snap index 72b030f22ac..6822e8fce9e 100644 --- a/libs/wingc/src/jsify/snapshots/lift_string.snap +++ b/libs/wingc/src/jsify/snapshots/lift_string.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_this.snap b/libs/wingc/src/jsify/snapshots/lift_this.snap index 6ab8730b88c..cf64779fc21 100644 --- a/libs/wingc/src/jsify/snapshots/lift_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_this.snap @@ -85,6 +85,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap index 1274cd10e3a..e9e961e1cf7 100644 --- a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap index c2031ed3b27..e022d28e821 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap index 460441dd0a4..8fbf308b920 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap @@ -87,10 +87,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap index d7c67b36828..0d641dd4434 100644 --- a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap @@ -44,10 +44,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -75,8 +78,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap index 2c771b0b1f7..88c3a32572e 100644 --- a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class YourType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap index 91257bfd431..016fb850a22 100644 --- a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap @@ -89,10 +89,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class YourType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 4c0fcdbb3da..9b3694cc392 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -61,6 +61,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -89,6 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -116,8 +121,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap index c053dcae157..e61472625e7 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap index d3992988748..37f163fc6d2 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap index 8c96fb27ae5..37d68e92fbf 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap index 54db26e1554..e5a833fbf3d 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap @@ -60,6 +60,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap index 5b6c9f12da8..8cf87f1c99b 100644 --- a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap @@ -58,6 +58,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap index f8df6a1e343..6f8b36e738e 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap @@ -55,6 +55,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection.snap b/libs/wingc/src/jsify/snapshots/preflight_collection.snap index a2e0f01dcee..3323d0b5213 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap index ccbf4ba8352..3c7d184510c 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap @@ -50,10 +50,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap index d1f4f50769d..24b2d65c6cc 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object.snap b/libs/wingc/src/jsify/snapshots/preflight_object.snap index c7d6b9c02a2..a9bbc073db2 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object.snap @@ -72,6 +72,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap index 73ae66c5d8a..9408fa25143 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap @@ -69,10 +69,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap index 3118c933228..ccfc374b9c7 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap @@ -47,10 +47,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap index 30684d0011d..1151652abb0 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap @@ -52,10 +52,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap index 9a150a8c71d..506fe835563 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap new file mode 100644 index 00000000000..f35589d1325 --- /dev/null +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -0,0 +1,209 @@ +--- +source: libs/wingc/src/jsify/tests.rs +--- +## Code + +```w + + class PreflightC { + pub inflight bar() {} + } + let pc = new PreflightC(); + + inflight class InflightC { + pub foo() { + pc.bar(); + } + } + + test "test" { + let ic = new InflightC(); + ic.foo(); + } + +``` + +## inflight.$Closure1-1.cjs + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $InflightC }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const ic = (await (async () => {const o = new $InflightC(); await o.$inflight_init?.(); return o; })()); + (await ic.foo()); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-1.cjs.map +``` + +## inflight.InflightC-1.cjs + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $pc }) { + class InflightC { + async foo() { + (await $pc.bar()); + } + } + return InflightC; +} +//# sourceMappingURL=inflight.InflightC-1.cjs.map +``` + +## inflight.PreflightC-1.cjs + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class PreflightC { + constructor({ }) { + } + async bar() { + } + } + return PreflightC; +} +//# sourceMappingURL=inflight.PreflightC-1.cjs.map +``` + +## preflight.cjs + +```js +"use strict"; +const $stdlib = require('@winglang/sdk'); +const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +class $Root extends $stdlib.std.Resource { + constructor($scope, $id) { + super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; + class PreflightC extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.PreflightC-1.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const PreflightCClient = ${PreflightC._toInflightType()}; + const client = new PreflightCClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "bar": [ + ], + "$inflight_init": [ + ], + }); + } + } + class InflightC extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightC-1.cjs")({ + $pc: ${$stdlib.core.liftObject(pc)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightCClient = ${InflightC._toInflightType()}; + const client = new InflightCClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "foo": [ + [pc, ["bar"]], + ], + "$inflight_init": [ + [pc, []], + ], + }); + } + } + if ($preflightTypesMap[2]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[2] = InflightC; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ + $InflightC: ${$stdlib.core.liftObject(InflightC)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$helpers.preflightClassSingleton(this, 2), ["foo"]], + [InflightC, []], + ], + "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 2), []], + [InflightC, []], + ], + }); + } + } + const pc = new PreflightC(this, "PreflightC"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:test", new $Closure1(this, "$Closure1")); + } +} +const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); +const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "main", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); +$APP.synth(); +//# sourceMappingURL=preflight.cjs.map +``` + diff --git a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap index 774da98ff7f..db2b0b6ac0f 100644 --- a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap +++ b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap index cdab8211e67..2cd0be9082c 100644 --- a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap +++ b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap @@ -57,6 +57,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap index bbde03ffe57..0d37b640455 100644 --- a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap @@ -26,6 +26,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; let i = 10; (() => { i = 12; diff --git a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap index d421e6a3c7d..3156b19bcd9 100644 --- a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap +++ b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap index b4e479c49bf..4d446e7d47b 100644 --- a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index 7037afed5fc..c4c96cd62bd 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -100,6 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -127,8 +132,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, ["a"]], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap index 28ee4f47cc6..6444a8083db 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 6ddf585201a..0597623b6b5 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -78,6 +78,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -111,6 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -138,8 +143,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap index 4baa0e5b574..b478fce8fab 100644 --- a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap +++ b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap index 6d418fe4b67..328f3d3829f 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap index 17388473e70..69384186b30 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap index cabd4783e02..27863adcafe 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap @@ -65,10 +65,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap index f7b74ca97e8..7630bff1ae1 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap @@ -52,10 +52,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap index bee06339319..efc8fc0eed4 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap @@ -46,10 +46,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap index 39e5714deae..8b105fd7f38 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap index 5fe4ab94cc7..c79a04b67f9 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap @@ -73,10 +73,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 1478a64ae25..322b97d5ff9 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -111,6 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("A is already in type map"); } + $preflightTypesMap[1] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -138,8 +143,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [A, ["foo"]], ], "$inflight_init": [ + [A, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap index 6bdecac309e..1fbad7370de 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap @@ -76,6 +76,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap index a3afeeb210c..562280f0c7d 100644 --- a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap index ddd7d0bbc12..e93803cd00f 100644 --- a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap index cddb49b66f0..a8ddfb7e07e 100644 --- a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap +++ b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -76,8 +79,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["values"]], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), ["fromJson"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference.snap b/libs/wingc/src/jsify/snapshots/transitive_reference.snap index 847626e2f23..ae54a46416d 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference.snap @@ -88,10 +88,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index 4d646d3361c..c3e61474e94 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyInflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -108,6 +111,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("MyInflightClass is already in type map"); } + $preflightTypesMap[1] = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -135,8 +140,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), ["putInBucket"]], + [MyInflightClass, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], + [MyInflightClass, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap index 6360ecad233..1b0e1405a7e 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap @@ -96,10 +96,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap index bc7e393332e..ae17e2d8048 100644 --- a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap +++ b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap @@ -53,10 +53,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/use_util_functions.snap b/libs/wingc/src/jsify/snapshots/use_util_functions.snap index 85f8f9563f2..6df9d47b4ac 100644 --- a/libs/wingc/src/jsify/snapshots/use_util_functions.snap +++ b/libs/wingc/src/jsify/snapshots/use_util_functions.snap @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -74,8 +77,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap index d0e74b4002d..4b1282f2b4b 100644 --- a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/wait_util.snap b/libs/wingc/src/jsify/snapshots/wait_util.snap index e2f23baff21..baae474a327 100644 --- a/libs/wingc/src/jsify/snapshots/wait_util.snap +++ b/libs/wingc/src/jsify/snapshots/wait_util.snap @@ -50,10 +50,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -81,8 +84,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/libs/wingc/src/jsify/tests.rs b/libs/wingc/src/jsify/tests.rs index a07511e90c7..775bfe69365 100644 --- a/libs/wingc/src/jsify/tests.rs +++ b/libs/wingc/src/jsify/tests.rs @@ -43,6 +43,29 @@ fn free_inflight_obj_from_inflight() { ); } +#[test] +fn qualify_inflight_type_refrencing_preflight_instance() { + assert_compile_ok!( + r#" + class PreflightC { + pub inflight bar() {} + } + let pc = new PreflightC(); + + inflight class InflightC { + pub foo() { + pc.bar(); + } + } + + test "test" { + let ic = new InflightC(); + ic.foo(); + } + "# + ); +} + #[test] fn call_static_inflight_from_static_inflight() { assert_compile_ok!( diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 3be3514185f..ab5f4ec4baf 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -9,6 +9,7 @@ use crate::{ diagnostic::{report_diagnostic, Diagnostic}, jsify::{JSifier, JSifyContext}, type_check::{ + get_udt_definition_phase, lifts::{Liftable, Lifts}, resolve_user_defined_type, symbol_env::LookupResult, @@ -201,7 +202,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { fn visit_expr(&mut self, node: &'a Expr) { CompilationContext::set(CompilationPhase::Lifting, &node.span); - self.with_expr(node.id, |v| { + self.with_expr(&node, |v| { let expr_phase = v.jsify.types.get_expr_phase(&node).unwrap(); let expr_type = v.jsify.types.get_expr_type(&node); @@ -244,9 +245,9 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { Some((PropertyObject::Instance(prop_expr_id), property)) if node.id == prop_expr_id => Some(property), _ => { if expr_type.is_closure() { - // this is the case where we are lifting a "closure class" (e.g. a class that has a "handle" - // method). The "property" here is implicitly `handle`, these are generally syntheticaly generated by the compiler - // from closures. + // this is the case where we are lifting a "closure class" (a preflight class that has an inflight `handle` + // method is being called) the reason we might not have "property" set is because closure classes might be + // syntheticaly generated by the compiler from closures. Some(Symbol::global(CLOSURE_CLASS_HANDLE_METHOD)) } else { None @@ -274,7 +275,26 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { return; } + // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it visit::visit_expr(v, node); + + // Check if this is an inflight class defined preflight and if we need to qualify the lift with the current property + if expr_phase == Phase::Inflight { + if let Some(class) = expr_type.as_class() { + if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { + if let Some((_, property)) = v.ctx.current_property() { + let m = v.ctx.current_method().map(|(m, _)| m).expect("a method"); + let mut lifts = v.lifts_stack.pop().unwrap(); + // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique + // type alias here since we might not have the actual type name available in scope here. + let code = &v.jsify.class_singleton(expr_type); + lifts.lift(m, Some(v.jsify_symbol_to_op_array(&property)), code); + v.lifts_stack.push(lifts); + return; + } + } + } + } }); } @@ -293,14 +313,11 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { } // Get the type of the udt - let udt_type = resolve_user_defined_type( - node, - self.ctx.current_env().expect("an env"), - self.ctx.current_stmt_idx(), - ) - .unwrap_or(self.jsify.types.error()); - - // Since our target languages is isn't statically typed, we don't need to capture interfaces + let env = self.ctx.current_env().expect("an env"); + let udt_type = + resolve_user_defined_type(node, env, self.ctx.current_stmt_idx()).unwrap_or(self.jsify.types.error()); + + // Since our target language is isn't statically typed, we don't need to capture interfaces if udt_type.as_interface().is_some() { visit::visit_user_defined_type(self, node); return; @@ -308,25 +325,11 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { //--------------- // LIFT - if udt_type.is_preflight_class() { + if get_udt_definition_phase(node, env).expect("a phase") == Phase::Preflight { // jsify the expression so we can get the preflight code let code = self.jsify_udt(&node); let property = self.ctx.current_property(); - - // check that we can qualify the lift (e.g. determine which property is being accessed) - if property.is_none() { - report_diagnostic(Diagnostic { - message: format!( - "Cannot qualify access to a lifted type \"{udt_type}\" (see https://github.com/winglang/wing/issues/76 for more details)"), - span: Some(node.span.clone()), - annotations: vec![], - hints: vec![], - }); - - return; - } - let mut lifts = self.lifts_stack.pop().unwrap(); lifts.lift( self.ctx.current_method().map(|(m, _)| m).expect("a method"), diff --git a/libs/wingc/src/lsp/symbol_locator.rs b/libs/wingc/src/lsp/symbol_locator.rs index 9bdbd0b0b20..7c6fa79acae 100644 --- a/libs/wingc/src/lsp/symbol_locator.rs +++ b/libs/wingc/src/lsp/symbol_locator.rs @@ -302,7 +302,7 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { return; } - self.ctx.push_expr(node.id); + self.ctx.push_expr(&node); match &node.kind { ExprKind::New(new_expr) => 'new_expr: { diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index ce3fe0891a3..6825cb1c77a 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -329,11 +329,20 @@ pub struct Class { pub docs: Docs, pub lifts: Option, + // The phase in which this class was defined (this should be the same as the env.phase where the class name is defined) + pub defined_in_phase: Phase, + // Preflight classes are CDK Constructs which means they have a scope and id as their first arguments // this is natively supported by wing using the `as` `in` keywords. However theoretically it is possible // to have a construct which does not have these arguments, in which case we can't use the `as` `in` keywords // and instead the user will need to pass the relevant args to the class's init method. pub std_construct_args: bool, + + // Unique identifier for this class type, used to get access to the type's generated preflight code even when + // the type name isn't available in scope or is shadowed. + // Ideally we should use the FQN and unify the implementation of JSII imported classes and Wing classes, currently + // uid is used for Wing classes and is always 0 for JSII classes to avoid snapshot noise. + pub uid: usize, } impl Class { pub(crate) fn set_lifts(&mut self, lifts: Lifts) { @@ -345,8 +354,8 @@ impl Class { pub fn get_closure_method(&self) -> Option { self .methods(true) - .find(|(name, type_)| name == CLOSURE_CLASS_HANDLE_METHOD && type_.is_inflight_function()) - .map(|(_, t)| t) + .find(|(name, v)| name == CLOSURE_CLASS_HANDLE_METHOD && v.type_.is_inflight_function()) + .map(|(_, v)| v.type_) } } @@ -378,15 +387,15 @@ impl Display for Interface { } type ClassLikeIterator<'a> = - FilterMap, fn(::Item) -> Option<(String, TypeRef)>>; + FilterMap, fn(::Item) -> Option<(String, VariableInfo)>>; pub trait ClassLike: Display { fn get_env(&self) -> &SymbolEnv; fn methods(&self, with_ancestry: bool) -> ClassLikeIterator<'_> { - self.get_env().iter(with_ancestry).filter_map(|(s, t, ..)| { - if t.as_variable()?.type_.as_function_sig().is_some() { - Some((s, t.as_variable()?.type_)) + self.get_env().iter(with_ancestry).filter_map(|(s, sym_kind, ..)| { + if sym_kind.as_variable()?.type_.as_function_sig().is_some() { + Some((s, sym_kind.as_variable()?.clone())) } else { None } @@ -394,9 +403,9 @@ pub trait ClassLike: Display { } fn fields(&self, with_ancestry: bool) -> ClassLikeIterator<'_> { - self.get_env().iter(with_ancestry).filter_map(|(s, t, ..)| { - if t.as_variable()?.type_.as_function_sig().is_none() { - Some((s, t.as_variable()?.type_)) + self.get_env().iter(with_ancestry).filter_map(|(s, sym_kind, ..)| { + if sym_kind.as_variable()?.type_.as_function_sig().is_none() { + Some((s, sym_kind.as_variable()?.clone())) } else { None } @@ -638,16 +647,14 @@ impl Subtype for Type { // method type (aka "closure classes"). // First, check if there is exactly one inflight method in the interface - let mut inflight_methods = iface - .methods(true) - .filter(|(_name, type_)| type_.is_inflight_function()); + let mut inflight_methods = iface.methods(true).filter(|(_name, v)| v.type_.is_inflight_function()); let handler_method = inflight_methods.next(); if handler_method.is_none() || inflight_methods.next().is_some() { return false; } // Next, check that the method's name is "handle" - let (handler_method_name, handler_method_type) = handler_method.unwrap(); + let (handler_method_name, handler_method_var) = handler_method.unwrap(); if handler_method_name != CLOSURE_CLASS_HANDLE_METHOD { return false; } @@ -660,7 +667,7 @@ impl Subtype for Type { }; // Finally check if they're subtypes - res_handle_type.is_subtype_of(&handler_method_type) + res_handle_type.is_subtype_of(&handler_method_var.type_) } (Self::Class(res), Self::Function(_)) => { // To support flexible inflight closures, we say that any @@ -1085,12 +1092,13 @@ impl TypeRef { /// Returns whether type represents a closure (either a function or a closure class). pub fn is_closure(&self) -> bool { - if self.as_function_sig().is_some() { - return true; - } + self.as_function_sig().is_some() || self.is_closure_class() + } - if let Some(ref class) = self.as_preflight_class() { - return class.get_closure_method().is_some(); + /// Returns whether type represents a class representing an inflight closure. + pub fn is_closure_class(&self) -> bool { + if let Some(ref class) = self.as_class() { + return class.get_closure_method().is_some() && class.defined_in_phase == Phase::Preflight; } false } @@ -1220,7 +1228,7 @@ impl TypeRef { Type::MutArray(t) => t.is_serializable(), Type::Map(t) => t.is_serializable(), Type::MutMap(t) => t.is_serializable(), - Type::Struct(s) => s.fields(true).map(|(_, t)| t).all(|t| t.is_serializable()), + Type::Struct(s) => s.fields(true).map(|(_, v)| v.type_).all(|t| t.is_serializable()), Type::Enum(_) => true, // not serializable Type::Duration => false, @@ -1258,7 +1266,7 @@ impl TypeRef { Type::Map(v) => v.is_json_legal_value(), Type::Optional(v) => v.is_json_legal_value(), Type::Struct(ref s) => { - for (_, t) in s.fields(true) { + for t in s.fields(true).map(|(_, v)| v.type_) { if !t.is_json_legal_value() { return false; } @@ -1295,8 +1303,8 @@ impl TypeRef { match &**self { Type::Struct(s) => { // check all its fields are json compatible - for (_, field) in s.fields(true) { - if !field.has_json_representation() { + for t in s.fields(true).map(|(_, v)| v.type_) { + if !t.has_json_representation() { return false; } } @@ -1391,6 +1399,8 @@ pub struct Types { type_expressions: IndexMap, /// Append empty struct to end of arg list pub append_empty_struct_to_arglist: HashSet, + /// Class counter, used to generate unique ids for class types + pub class_counter: usize, } impl Types { @@ -1443,6 +1453,9 @@ impl Types { append_empty_struct_to_arglist: HashSet::new(), libraries: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Preflight, 0), intrinsics: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Independent, 0), + // 1 based to avoid conflict with imported JSII classes. This isn't strictly needed since brought JSII classes are never accessed + // through their unique ID, but still good to avoid confusion. + class_counter: 1, } } @@ -2301,14 +2314,14 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); self.spanned_error( exp, format!( - "Binary operator '+' cannot be applied to operands of type '{}' and '{}'; only ({}, {}) and ({}, {}) are supported", - ltype, - rtype, - self.types.number(), - self.types.number(), - self.types.string(), - self.types.string(), - ), + "Binary operator '+' cannot be applied to operands of type '{}' and '{}'; only ({}, {}) and ({}, {}) are supported", + ltype, + rtype, + self.types.number(), + self.types.number(), + self.types.string(), + self.types.string(), + ), ); } self.resolved_error() @@ -2499,7 +2512,8 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); .expect(&format!("Expected \"{}\" to be a struct type", struct_type)); // Verify that all expected fields are present and are the right type - for (name, field_type) in st.fields(true) { + for (name, v) in st.fields(true) { + let field_type = v.type_; match fields.get(name.as_str()) { Some(field_exp) => { let t = field_types.get(name.as_str()).unwrap(); @@ -2755,21 +2769,9 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); // Make sure this is a function signature type let func_sig = if let Some(func_sig) = func_type.as_deep_function_sig() { func_sig.clone() - } else if let Some(class) = func_type.as_preflight_class() { - // return the signature of the "handle" method - let lookup_res = class.get_method(&CLOSURE_CLASS_HANDLE_METHOD.into()); - let handle_type = if let Some(method) = lookup_res { - method.type_ - } else { - self.spanned_error(callee, "Expected a function or method"); - return self.resolved_error(); - }; - if let Some(sig_type) = handle_type.as_function_sig() { - sig_type.clone() - } else { - self.spanned_error(callee, "Expected a function or method"); - return self.resolved_error(); - } + } else if func_type.is_closure_class() { + let handle_type = func_type.as_class().unwrap().get_closure_method().unwrap(); + handle_type.as_function_sig().unwrap().clone() } else { self.spanned_error( callee, @@ -3062,7 +3064,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); pub fn all_optional_struct(t: TypeRef) -> bool { match &*t { - Type::Struct(s) => s.fields(true).all(|(_, t)| t.is_option()), + Type::Struct(s) => s.fields(true).all(|(_, v)| v.type_.is_option()), _ => false, } } @@ -4520,10 +4522,13 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); implements: impl_interfaces.clone(), is_abstract: false, phase: ast_class.phase, + defined_in_phase: env.phase, docs: stmt.doc.as_ref().map_or(Docs::default(), |s| Docs::with_summary(s)), std_construct_args: ast_class.phase == Phase::Preflight, lifts: None, + uid: self.types.class_counter, }; + self.types.class_counter += 1; let mut class_type = self.types.add_type(Type::Class(class_spec)); match env.define( &ast_class.name, @@ -4738,7 +4743,8 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); }; // Check all methods are implemented - for (method_name, method_type) in interface_type.methods(true) { + for (method_name, v) in interface_type.methods(true) { + let method_type = v.type_; if let Some(symbol) = &mut class_type .as_class_mut() .unwrap() @@ -5297,7 +5303,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); return; }; - // If the parent class is phase independent than its constructor name is just "new" regardless of + // If the parent class is phase independent then its constructor name is just "new" regardless of // whether we're inflight or not. let parent_init_name = if parent_class.as_class().unwrap().phase == Phase::Independent { CLASS_INIT_NAME @@ -5309,13 +5315,13 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); .as_class() .unwrap() .methods(false) - .filter(|(name, _type)| name == parent_init_name) - .collect_vec()[0] + .find(|(name, ..)| name == parent_init_name) + .unwrap() .1; self.type_check_arg_list_against_function_sig( &arg_list, - parent_initializer.as_function_sig().unwrap(), + parent_initializer.type_.as_function_sig().unwrap(), super_constructor_call, arg_list_types, ); @@ -5755,6 +5761,8 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); docs: c.docs.clone(), std_construct_args: c.std_construct_args, lifts: None, + defined_in_phase: env.phase, + uid: c.uid, }), Type::Interface(iface) => Type::Interface(Interface { name: iface.name.clone(), @@ -6281,7 +6289,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); if property.name == FROM_JSON || property.name == TRY_FROM_JSON { // we need to validate that only structs with all valid json fields can have a fromJson method for (name, field) in s.fields(true) { - if !field.has_json_representation() { + if !field.type_.has_json_representation() { self.spanned_error_with_var( property, format!( @@ -6982,6 +6990,19 @@ pub fn resolve_user_defined_type_ref<'a>( } } +pub fn get_udt_definition_phase(user_defined_type: &UserDefinedType, env: &SymbolEnv) -> Option { + let mut nested_name = vec![&user_defined_type.root]; + nested_name.extend(user_defined_type.fields.iter().collect_vec()); + + let lookup_result = env.lookup_nested(&nested_name, None); + + if let LookupResult::Found(_, lookup_info) = lookup_result { + Some(lookup_info.env.phase) + } else { + None + } +} + pub fn is_udt_struct_type(udt: &UserDefinedType, env: &SymbolEnv) -> bool { if let Ok(type_) = resolve_user_defined_type(udt, env, 0) { type_.as_struct().is_some() diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index 65c99014da2..de39f947dff 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -732,9 +732,14 @@ impl<'a> JsiiImporter<'a> { implements: vec![], is_abstract: jsii_class.abstract_.unwrap_or(false), phase: class_phase, + defined_in_phase: Phase::Preflight, docs: Docs::from(&jsii_class.docs), std_construct_args: false, // Temporary value, will be updated once we parse the initializer args lifts: None, + + // uid is used to create unique names class types so we can access the correct type regardless of type name shadowing, + // this isn't relevant for imported types (that aren't code generated), so we can default to 0 + uid: 0, }; let mut new_type = self.wing_types.add_type(Type::Class(class_spec)); self.register_jsii_type(&jsii_class_fqn, &new_type_symbol, new_type); diff --git a/libs/wingc/src/type_check/lifts.rs b/libs/wingc/src/type_check/lifts.rs index 8606c5e2bdc..61c7413bc08 100644 --- a/libs/wingc/src/type_check/lifts.rs +++ b/libs/wingc/src/type_check/lifts.rs @@ -10,7 +10,7 @@ use super::{ExprId, CLASS_INFLIGHT_INIT_NAME}; #[derive(Debug)] pub struct Lifts { // TODO: make all these private and add accessors+helper logic - /// All the lifts. Map from method to a map from inflight code to lift qualifications. + /// All the lifts. Map from method to a map from preflight code to lift qualifications. pub lifts_qualifications: BTreeMap>, /// All the captures. The key is token the value is the preflight code. diff --git a/libs/wingc/src/visit_context.rs b/libs/wingc/src/visit_context.rs index 5004ba58074..f2850b9424e 100644 --- a/libs/wingc/src/visit_context.rs +++ b/libs/wingc/src/visit_context.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use crate::{ - ast::{Class, ExprId, FunctionSignature, Phase, Stmt, StmtKind, Symbol, UserDefinedType}, + ast::{Class, Expr, ExprId, FunctionSignature, Phase, Stmt, StmtKind, Symbol, UserDefinedType}, type_check::symbol_env::SymbolEnvRef, }; @@ -91,8 +91,8 @@ impl VisitContext { // -- - pub fn push_expr(&mut self, expr: ExprId) { - self.expression.push(expr); + pub fn push_expr(&mut self, expr: &Expr) { + self.expression.push(expr.id); } pub fn pop_expr(&mut self) { @@ -237,7 +237,7 @@ impl VisitContext { pub trait VisitorWithContext { fn ctx(&mut self) -> &mut VisitContext; - fn with_expr(&mut self, expr: ExprId, f: impl FnOnce(&mut Self)) { + fn with_expr(&mut self, expr: &Expr, f: impl FnOnce(&mut Self)) { self.ctx().push_expr(expr); f(self); self.ctx().pop_expr(); diff --git a/libs/wingsdk/src/core/lifting.ts b/libs/wingsdk/src/core/lifting.ts index 737f4cfd434..41d2bb7fad0 100644 --- a/libs/wingsdk/src/core/lifting.ts +++ b/libs/wingsdk/src/core/lifting.ts @@ -265,10 +265,7 @@ export function collectLifts( } else if (typeof obj === "object" && obj._liftMap !== undefined) { matrix = parseMatrix(obj._liftMap ?? {}); matrixCache.set(obj, matrix); - } else if ( - typeof obj === "function" && - typeof obj._liftTypeMap !== undefined - ) { + } else if (typeof obj === "function" && obj._liftTypeMap !== undefined) { matrix = parseMatrix(obj._liftTypeMap ?? {}); matrixCache.set(obj, matrix); } else { diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index a54598218d8..26f4697b1a8 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -3,6 +3,7 @@ import { notDeepStrictEqual } from "node:assert"; import * as path from "node:path"; import type { Construct } from "constructs"; +import type { Resource } from "./std"; import type { Node } from "./std/node"; // since we moved from node:18 to node:20 the deepStrictEqual doesn't work as expected. // https://github.com/winglang/wing/issues/4444 @@ -166,3 +167,62 @@ export function resolveDirname( ): string { return normalPath(path.resolve(outdir, relativeSourceDir)); } + +/** + * Helper function to `require` a compiled preflight wing file (js) into another compiled (js) wing file. + * We need this instead of simply calling `require` because in addition to returning the imported module's exports, + * we also need to update the current module's preflight types map with the brought module's preflight types map. + * @param moduleFile - the file to `require` + * @param outPreflightTypesObject - the current module's $preflightTypesMap + * @returns all symbols exported by the `moduleFile` except `$preflightTypesMap` + */ +export function bringJs( + moduleFile: string, + outPreflightTypesObject: Object +): Object { + /* eslint-disable @typescript-eslint/no-require-imports */ + return Object.fromEntries( + Object.entries(require(moduleFile)).filter(([k, v]) => { + // If this is the preflight types array then update the input object and skip it + if (k === "$preflightTypesMap") { + // Verify no key collision (should never happen) + Object.keys(v as object).forEach((key) => { + if (key in outPreflightTypesObject) { + throw new Error(`Key collision (${key}) in preflight types map`); + } + }); + Object.assign(outPreflightTypesObject, v); + return false; + } + return true; + }) + ); +} + +/** + * Helper function to get a singleton instance of a class defined in preflight. + * In practice this is used to get the preflight instance of **inflight** classes defined **preflight**. + * This instance is used for accessing the lift map of such classes. + * @param scope - a scope in the construct tree that'll hold the instance (a singleton within that tree). + * @param typeId - the unique id of the preflight class type we want. + * @returns the instance of the class. + */ +export function preflightClassSingleton( + scope: Construct, + typeId: number +): Resource { + const root: any = nodeof(scope).root; + const type: any = root.$preflightTypesMap[typeId]; + if (root.resourceSingletons === undefined) { + root.resourceSingletons = {}; + } + const instance = root.resourceSingletons[type]; + if (instance) { + return instance; + } + root.resourceSingletons[type] = new type( + scope, + `${type.name}_singleton_${typeId}` + ); + return root.resourceSingletons[type]; +} diff --git a/tools/hangar/__snapshots__/invalid.ts.snap b/tools/hangar/__snapshots__/invalid.ts.snap index 6021af442d6..e944ae5e824 100644 --- a/tools/hangar/__snapshots__/invalid.ts.snap +++ b/tools/hangar/__snapshots__/invalid.ts.snap @@ -2613,13 +2613,6 @@ error: Cannot create preflight class "PreflightClass" in inflight phase | ^^^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type "PreflightClass" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/inflight_class_created_in_preflight.test.w:19:7 - | -19 | new PreflightClass(); - | ^^^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped @@ -4091,13 +4084,6 @@ exports[`resource_inflight.test.w 1`] = ` | ^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type "Bucket" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/resource_inflight.test.w:4:7 - | -4 | new cloud.Bucket(); // Should fail because we can't create resources inflight - | ^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped diff --git a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md index 48f9f26410c..a0171da37a6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md index a225949abbd..8693e2fefec 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md @@ -476,10 +476,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -508,9 +511,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [counter, ["inc"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [counter, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index 34cc0b087ff..bc5e0bfed85 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -332,13 +332,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -400,9 +403,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -438,9 +445,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -476,9 +489,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index 7a432fa81b5..3c077f31ee8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -307,13 +307,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -375,9 +378,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [apiDefaultCors.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [apiDefaultCors.url, []], ], }); @@ -413,9 +420,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [apiDefaultCors.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [apiDefaultCors.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md index 636daf6a931..1ff40e38af2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md @@ -550,11 +550,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md index affbcd93807..9c24a66a33b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md @@ -65,6 +65,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md index a1abff069c0..64402b8eac2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md @@ -269,10 +269,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md index 806f0755f05..0bef77200bc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md @@ -21,6 +21,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -52,7 +53,7 @@ class Baz extends $stdlib.std.Resource { }); } } -module.exports = { Baz }; +module.exports = { $preflightTypesMap, Baz }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md index 91d1d890678..2355f752634 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md @@ -28,11 +28,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const stdFs = $stdlib.fs; -const stdFs2 = $stdlib.fs; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const stdFs = $stdlib.fs; + const stdFs2 = $stdlib.fs; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((stdFs.Util.dirname("/")), "/"), "stdFs.dirname(\"/\") == \"/\""); $helpers.assert($helpers.eq((stdFs2.Util.dirname("/")), "/"), "stdFs2.dirname(\"/\") == \"/\""); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md index 0619d7e6677..76c18f32c64 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md @@ -42,10 +42,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cdk = require("aws-cdk-lib"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cdk = require("aws-cdk-lib"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class CdkDockerImageFunction extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md index 759bd050819..43ef75b0daa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md @@ -28,11 +28,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cdk8s = require("cdk8s"); -const kplus = require("cdk8s-plus-27"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cdk8s = require("cdk8s"); + const kplus = require("cdk8s-plus-27"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = this.node.root.new("cdk8s.App", cdk8s.App, ); const chart = this.node.root.new("cdk8s.Chart", cdk8s.Chart, this, "Chart"); const deploy = ($scope => $scope.node.root.new("cdk8s-plus-27.Deployment", kplus.Deployment, $scope, "Deployment"))(chart); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md index 60cc9c5b347..47db08390c9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md @@ -59,11 +59,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const aws = require("@cdktf/provider-aws"); -const cdktf = require("cdktf"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const aws = require("@cdktf/provider-aws"); + const cdktf = require("cdktf"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md index 7d08220759d..169b251befa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const lib = require("./preflight.extendnonentrypoint-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const lib = $helpers.bringJs(`${__dirname}/preflight.extendnonentrypoint-1.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const f = new lib.Foo(this, "Foo"); } } @@ -63,6 +66,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cdk8s = require("cdk8s"); class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { constructor($scope, $id, ) { @@ -93,7 +97,7 @@ class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.extendnonentrypoint-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md index 8ce43dccc57..e670a56f704 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md @@ -64,12 +64,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const stuff = require("jsii-code-samples"); -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const stuff = require("jsii-code-samples"); + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -98,9 +101,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(stuff.HelloWorld, "jsii-code-samples", "HelloWorld"), []], [greeting, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(stuff.HelloWorld, "jsii-code-samples", "HelloWorld"), []], [greeting, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md index eaea16be38c..731e6cfad7f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md @@ -297,14 +297,17 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const file1 = require("./preflight.store-2.cjs"); -const file2 = require("./preflight.subfile-3.cjs"); -const file3 = require("./preflight.empty-1.cjs"); -const math = $stdlib.math; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const file1 = $helpers.bringJs(`${__dirname}/preflight.store-2.cjs`, $preflightTypesMap); + const file2 = $helpers.bringJs(`${__dirname}/preflight.subfile-3.cjs`, $preflightTypesMap); + const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); + const math = $stdlib.math; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -368,9 +371,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [$stdlib.core.toLiftableModuleType(file2.Q, "", "Q"), ["greet"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [$stdlib.core.toLiftableModuleType(file2.Q, "", "Q"), []], ], }); @@ -459,7 +464,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.empty-1.cjs.map ``` @@ -470,7 +476,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const file3 = require("./preflight.empty-1.cjs"); +let $preflightTypesMap = {}; +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = @@ -580,7 +587,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Util, Store, Color }; +module.exports = { $preflightTypesMap, Util, Store, Color }; //# sourceMappingURL=preflight.store-2.cjs.map ``` @@ -591,6 +598,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const math = $stdlib.math; class Q extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -629,7 +637,7 @@ class Q extends $stdlib.std.Resource { }); } } -module.exports = { Q }; +module.exports = { $preflightTypesMap, Q }; //# sourceMappingURL=preflight.subfile-3.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index 0161018121b..2dd33865c8f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -42,6 +42,21 @@ module.exports = function({ }) { //# sourceMappingURL=inflight.Foo-3.cjs.map ``` +## inflight.InflightClass-4.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class InflightClass { + async method() { + return "What did you expect?"; + } + } + return InflightClass; +} +//# sourceMappingURL=inflight.InflightClass-4.cjs.map +``` + ## inflight.Widget-1.cjs ```cjs "use strict"; @@ -84,11 +99,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const w = require("./preflight.widget-1.cjs"); -const subdir = require("./preflight.subdir2-5.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const w = $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap); + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const widget1 = new w.Widget(this, "widget1"); $helpers.assert($helpers.eq((widget1.compute()), 42), "widget1.compute() == 42"); const foo = new subdir.Foo(this, "Foo"); @@ -113,7 +131,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const blah = require("./preflight.inner-2.cjs"); +let $preflightTypesMap = {}; +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { @@ -150,7 +169,7 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.file1-3.cjs.map ``` @@ -161,6 +180,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const util = $stdlib.util; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -222,10 +242,54 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.file2-4.cjs.map ``` +## preflight.inflightclass-5.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class InflightClass extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightClass-4.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightClassClient = ${InflightClass._toInflightType()}; + const client = new InflightClassClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "method": [ + ], + "$inflight_init": [ + ], + }); + } +} +if ($preflightTypesMap[5]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[5] = InflightClass; +module.exports = { $preflightTypesMap, InflightClass }; +//# sourceMappingURL=preflight.inflightclass-5.cjs.map +``` + ## preflight.inner-2.cjs ```cjs "use strict"; @@ -233,25 +297,26 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.widget-1.cjs"), -}; +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.inner-2.cjs.map ``` -## preflight.subdir2-5.cjs +## preflight.subdir2-6.cjs ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - get inner() { return require("./preflight.inner-2.cjs") }, - ...require("./preflight.file2-4.cjs"), - ...require("./preflight.file1-3.cjs"), -}; -//# sourceMappingURL=preflight.subdir2-5.cjs.map +const $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; +//# sourceMappingURL=preflight.subdir2-6.cjs.map ``` ## preflight.widget-1.cjs @@ -261,6 +326,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Widget extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -295,7 +361,7 @@ class Widget extends $stdlib.std.Resource { }); } } -module.exports = { Widget }; +module.exports = { $preflightTypesMap, Widget }; //# sourceMappingURL=preflight.widget-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md index 4fc2a4d1afb..7398aa21dd1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md @@ -67,6 +67,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -101,7 +102,7 @@ class Bar extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.bar-1.cjs.map ``` @@ -112,6 +113,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -143,7 +145,7 @@ class Baz extends $stdlib.std.Resource { }); } } -module.exports = { Baz }; +module.exports = { $preflightTypesMap, Baz }; //# sourceMappingURL=preflight.baz-2.cjs.map ``` @@ -157,12 +159,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const foo = require("./preflight.foo-3.cjs"); -const bar = require("./preflight.bar-1.cjs"); -const baz = require("./preflight.baz-2.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const foo = $helpers.bringJs(`${__dirname}/preflight.foo-3.cjs`, $preflightTypesMap); + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); + const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((foo.Foo.foo(this)), "foo"), "foo.Foo.foo() == \"foo\""); $helpers.assert($helpers.eq((foo.Foo.bar(this)), "bar"), "foo.Foo.bar() == \"bar\""); $helpers.assert($helpers.eq((foo.Foo.baz(this)), "baz"), "foo.Foo.baz() == \"baz\""); @@ -183,8 +188,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const bar = require("./preflight.bar-1.cjs"); -const baz = require("./preflight.baz-2.cjs"); +let $preflightTypesMap = {}; +const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); +const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`, $preflightTypesMap); class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -222,7 +228,7 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.foo-3.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md index 85d3f6033f6..7ccc2ee5a0c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md @@ -28,10 +28,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const projen = require("projen"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const projen = require("projen"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.neq(projen.LogLevel.OFF, projen.LogLevel.VERBOSE), "projen.LogLevel.OFF != projen.LogLevel.VERBOSE"); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md index 39d1b1cbf04..5e58a8ff2aa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md @@ -107,12 +107,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const fixture = require("./preflight.testfixture-5.cjs"); -const testfixture = require("./preflight.testfixture-5.cjs"); -const testfixture2 = require("./preflight.testfixture-5.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const fixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); + const testfixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); + const testfixture2 = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -169,6 +172,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const FavoriteNumbers = (function (tmp) { tmp["SEVEN"] = "SEVEN"; @@ -176,7 +180,7 @@ const FavoriteNumbers = return tmp; })({}) ; -module.exports = { FavoriteNumbers }; +module.exports = { $preflightTypesMap, FavoriteNumbers }; //# sourceMappingURL=preflight.enums-1.cjs.map ``` @@ -187,8 +191,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cloud = $stdlib.cloud; -const myutil = require("./preflight.util-2.cjs"); +const myutil = $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, $preflightTypesMap); class Store extends $stdlib.std.Resource { constructor($scope, $id, options) { super($scope, $id); @@ -242,7 +247,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Store }; +module.exports = { $preflightTypesMap, Store }; //# sourceMappingURL=preflight.store-3.cjs.map ``` @@ -253,9 +258,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.util-2.cjs"), -}; +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir-4.cjs.map ``` @@ -266,11 +271,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - get subdir() { return require("./preflight.subdir-4.cjs") }, - ...require("./preflight.store-3.cjs"), - ...require("./preflight.enums-1.cjs"), -}; +const $preflightTypesMap = {}; +Object.assign(module.exports, { get subdir() { return $helpers.bringJs(`${__dirname}/preflight.subdir-4.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.store-3.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.enums-1.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.testfixture-5.cjs.map ``` @@ -281,6 +286,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Util extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -317,7 +323,7 @@ class Util extends $stdlib.std.Resource { }); } } -module.exports = { Util }; +module.exports = { $preflightTypesMap, Util }; //# sourceMappingURL=preflight.util-2.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md index 4b8c605b7a2..e762d20f3e9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md index ea4602f5b01..03d5a647c20 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const simpleThrow = (() => { throw new Error("not implemented"); }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index 4611883ee58..84dbcc76d5b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -102,6 +102,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -167,8 +170,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "callThis": [ + [Bar, ["bar"]], ], "$inflight_init": [ + [Bar, []], ], }); } @@ -179,6 +184,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("Bar is already in type map"); } + $preflightTypesMap[2] = Bar; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -208,10 +215,14 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 2), ["callThis"]], + [Bar, ["bar"]], [Foo, ["foo"]], [foo, ["callThis"]], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 2), []], + [Bar, []], [Foo, []], [foo, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md index fd928e94383..00adcc28e4c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md @@ -113,6 +113,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md index 16cf7d4204f..dad39b8b93b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md @@ -56,10 +56,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md index 73647713356..ecf8ade3a00 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md @@ -64,10 +64,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md index 538560e462b..1ec46a6ba0e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md @@ -74,6 +74,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md index 1b5082f1c70..0725bb48d7e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md @@ -168,10 +168,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md index 0e3e34f9f93..081361e3401 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md @@ -153,11 +153,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class KeyValueStore extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -298,10 +301,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [counter, ["peek"]], [kv, [].concat(["set"], ["get"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [counter, []], [kv, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md index 17f9085dddc..8ce585923d3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md index 3e4023e45ec..92ddc8fb9b6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md @@ -78,10 +78,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md index 54af4c008fb..69f6253c74e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md @@ -90,10 +90,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md index 55d284b2ce0..c2e624d2b4e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md @@ -227,10 +227,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md index 5e70bb4a547..e01268f629c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md @@ -648,10 +648,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md index d6739f9b1c8..fefdc50a3b4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md @@ -47,12 +47,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const aws = require("@cdktf/provider-aws"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const aws = require("@cdktf/provider-aws"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); if ($helpers.eq((util.Util.env("WING_TARGET")), "tf-aws")) { const s3Bucket = ($helpers.nodeof(b).findChild("Default")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index 222177a3393..16865355b48 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -586,10 +586,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C1 extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -1211,6 +1214,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[20]) { throw new Error("A is already in type map"); } + $preflightTypesMap[20] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -1240,6 +1245,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[21]) { throw new Error("B is already in type map"); } + $preflightTypesMap[21] = B; class $Closure5 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -1267,8 +1274,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 21), ["sound"]], + [B, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 21), []], + [B, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md index 8527d14afd4..62b11c93ac9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md @@ -75,6 +75,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md index b303e7c3cea..a2ad6b661c8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md @@ -54,12 +54,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const cx = require("constructs"); -const aws = require("@cdktf/provider-aws"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const cx = require("constructs"); + const aws = require("@cdktf/provider-aws"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class WingResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md index bfc1c7752f2..a583447f5bf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md @@ -62,10 +62,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const bucket1 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket1"); const bucket2 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket2"); const bucket3 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket3"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md index 09fd1622e94..fa553b1f8f1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md @@ -45,6 +45,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md index 3cc240d6983..9f75a4cfd6e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md @@ -42,10 +42,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md index 3d139298a72..fcb628d4bbd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md @@ -306,6 +306,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -500,8 +503,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["values"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md index f93187e3c3d..1796d7a91f5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md @@ -108,10 +108,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md index 0fabf02ee95..1f81a187a68 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md @@ -252,10 +252,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Doubler extends $stdlib.std.Resource { constructor($scope, $id, func) { super($scope, $id); @@ -356,9 +359,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), ["fromStr"]], [handler, ["handle"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), []], [handler, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md index 9dfb3b6b408..9d7aa868863 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md @@ -74,6 +74,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const SomeEnum = (function (tmp) { tmp["ONE"] = "ONE"; @@ -117,10 +120,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [SomeEnum, [].concat(["ONE"], ["TWO"])], [one, []], [two, []], ], "$inflight_init": [ + [SomeEnum, []], [one, []], [two, []], ], @@ -154,8 +159,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [SomeEnum, [].concat(["ONE"], ["TWO"], ["THREE"])], ], "$inflight_init": [ + [SomeEnum, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md index 25ed7a932e0..82bfb8995d5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md @@ -213,10 +213,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md index 5c8ac0336ed..1e163ed75c5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const x = (-1); const y = (2 * x); const z = ((x + y) - 1); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md index b320cc977b3..6fb16c92c8a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md @@ -53,10 +53,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -85,9 +88,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [number, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [number, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md index 794ec04a576..8bf44dfdc83 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md @@ -22,6 +22,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cdk8s = require("cdk8s"); class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { constructor($scope, $id, ) { @@ -52,7 +53,7 @@ class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md index 8763ce21760..a8effb04aa1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md @@ -236,10 +236,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md index a244a8ce90e..aceec6e2d13 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md @@ -216,10 +216,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md index 49fed41ce7f..be92a25fbfe 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md @@ -177,10 +177,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md index 287a91f1761..d176dedbad8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md @@ -45,6 +45,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md index 2feba53142a..4cde6e758c9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md @@ -45,6 +45,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md index 0a2609770f3..02edb318a6f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md @@ -56,10 +56,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md index 1047d0fd693..d65d23f80fa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md @@ -106,6 +106,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md index d0346334c75..c8978d701ca 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md @@ -91,10 +91,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, msg) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md index a61df751352..88bcc5a917b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md @@ -194,10 +194,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md index 8f2cbcbb2ea..34ffe393f1a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md @@ -69,6 +69,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md index ee3ceb316ad..1ba04695a5b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md @@ -265,11 +265,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -625,6 +628,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[11]) { throw new Error("ImplInflightIfaceInInflightClass is already in type map"); } + $preflightTypesMap[11] = ImplInflightIfaceInInflightClass; class ImplInflightIfaceInPreflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md index c2c93e1f0e7..22ee565a070 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const d = (std.Duration.fromMinutes(5)); const n = ((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return Number(args) })("12"); $helpers.assert($helpers.eq(d.seconds, (5 * 60)), "d.seconds == 5 * 60"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md index c0fa4e1a016..04c31a4940f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md @@ -42,10 +42,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const c = require("constructs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const c = require("constructs"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md index 63ac7687524..36a734bcd31 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md @@ -42,11 +42,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md index d9c9ec036f8..5cbb1cd8f3d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md @@ -253,10 +253,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md index c00ce72a039..ff2bdeff84e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md @@ -322,10 +322,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index 099441fc26c..6acea4f262b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -154,10 +154,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Preflight extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -226,6 +229,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("OuterInflight is already in type map"); } + $preflightTypesMap[2] = OuterInflight; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -288,8 +293,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [OuterInflight, ["staticMethod"]], ], "$inflight_init": [ + [OuterInflight, []], ], }); } @@ -353,8 +360,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index 63eac774a41..22418a19e92 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -87,6 +87,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -117,6 +120,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -144,8 +149,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -177,9 +184,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), ["get"]], [getBar, ["handle"]], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], [getBar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index fd1516e9e87..3a91adb2ae5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -64,10 +64,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -101,6 +104,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -129,9 +134,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), ["getValue"]], + [Foo, []], [myConst, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], + [Foo, []], [myConst, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index b11b224548b..07738803002 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -1,5 +1,226 @@ # [inflight_class_capture_preflight_object.test.w](../../../../../examples/tests/valid/inflight_class_capture_preflight_object.test.w) | compile | tf-aws +## inflight.$Closure1-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const f = (await (async () => {const o = new $Foo(); await o.$inflight_init?.(); return o; })()); + (await f.uploadToBucket("hello.txt", "world")); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-5.cjs.map +``` + +## inflight.$Closure2-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + (await $Foo.fooStatic()); + } + } + return $Closure2; +} +//# sourceMappingURL=inflight.$Closure2-5.cjs.map +``` + +## inflight.$Closure3-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure3 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + return (await (async () => {const o = new $Foo(); await o.$inflight_init?.(); return o; })()); + } + } + return $Closure3; +} +//# sourceMappingURL=inflight.$Closure3-5.cjs.map +``` + +## inflight.$Closure4-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $getFoo }) { + class $Closure4 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const foo = (await $getFoo()); + (await foo.uploadToBucket("greetings.txt", "universe")); + } + } + return $Closure4; +} +//# sourceMappingURL=inflight.$Closure4-5.cjs.map +``` + +## inflight.$Closure5-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $b }) { + class $Closure5 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + class Foo2 { + async uploadToBucket() { + (await $b.put("x", "y")); + $helpers.assert($helpers.eq((await $b.get("x")), "y"), "b.get(\"x\") == \"y\""); + } + } + const f = (await (async () => {const o = new Foo2(); await o.$inflight_init?.(); return o; })()); + (await f.uploadToBucket()); + } + } + return $Closure5; +} +//# sourceMappingURL=inflight.$Closure5-5.cjs.map +``` + +## inflight.$Closure6-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $subdir_InflightClass }) { + class $Closure6 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const x = (await (async () => {const o = new $subdir_InflightClass(); await o.$inflight_init?.(); return o; })()); + $helpers.assert($helpers.eq((await x.method()), "What did you expect?"), "x.method() == \"What did you expect?\""); + } + } + return $Closure6; +} +//# sourceMappingURL=inflight.$Closure6-5.cjs.map +``` + +## inflight.Bar-3.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Bar { + constructor({ }) { + } + } + return Bar; +} +//# sourceMappingURL=inflight.Bar-3.cjs.map +``` + +## inflight.Foo-2.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Foo { + constructor({ }) { + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-2.cjs.map +``` + +## inflight.Foo-3.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Foo { + constructor({ }) { + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-3.cjs.map +``` + +## inflight.Foo-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $b }) { + class Foo { + async uploadToBucket(k, value) { + (await $b.put(k, value)); + $helpers.assert($helpers.eq((await $b.get(k)), value), "b.get(k) == value"); + } + static async fooStatic() { + (await $b.put("a", "b")); + $helpers.assert($helpers.eq((await $b.list()), ["a"]), "b.list() == [\"a\"]"); + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-5.cjs.map +``` + +## inflight.InflightClass-4.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class InflightClass { + async method() { + return "What did you expect?"; + } + } + return InflightClass; +} +//# sourceMappingURL=inflight.InflightClass-4.cjs.map +``` + +## inflight.Widget-1.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Widget { + constructor({ }) { + } + } + return Widget; +} +//# sourceMappingURL=inflight.Widget-1.cjs.map +``` + ## main.tf.json ```json { @@ -14,6 +235,20 @@ "aws": [ {} ] + }, + "resource": { + "aws_s3_bucket": { + "Bucket": { + "//": { + "metadata": { + "path": "root/Default/Default/Bucket/Default", + "uniqueId": "Bucket" + } + }, + "bucket_prefix": "bucket-c88fdc5f-", + "force_destroy": false + } + } } } ``` @@ -31,6 +266,276 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; + class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-5.cjs")({ + $b: ${$stdlib.core.liftObject(b)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "uploadToBucket": [ + [b, [].concat(["put"], ["get"])], + ], + "$inflight_init": [ + [b, []], + ], + }); + } + static get _liftTypeMap() { + return ({ + "fooStatic": [ + [b, [].concat(["put"], ["list"])], + ], + }); + } + } + if ($preflightTypesMap[6]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[6] = Foo; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-5.cjs")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$helpers.preflightClassSingleton(this, 6), ["uploadToBucket"]], + [Foo, []], + ], + "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 6), []], + [Foo, []], + ], + }); + } + } + class $Closure2 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-5.cjs")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure2Client = ${$Closure2._toInflightType()}; + const client = new $Closure2Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [Foo, ["fooStatic"]], + ], + "$inflight_init": [ + [Foo, []], + ], + }); + } + } + class $Closure3 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-5.cjs")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure3Client = ${$Closure3._toInflightType()}; + const client = new $Closure3Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [Foo, []], + ], + "$inflight_init": [ + [Foo, []], + ], + }); + } + } + class $Closure4 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-5.cjs")({ + $getFoo: ${$stdlib.core.liftObject(getFoo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure4Client = ${$Closure4._toInflightType()}; + const client = new $Closure4Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$helpers.preflightClassSingleton(this, 6), ["uploadToBucket"]], + [getFoo, ["handle"]], + ], + "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 6), []], + [getFoo, []], + ], + }); + } + } + class $Closure5 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-5.cjs")({ + $b: ${$stdlib.core.liftObject(b)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure5Client = ${$Closure5._toInflightType()}; + const client = new $Closure5Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [b, [].concat(["put"], ["get"])], + ], + "$inflight_init": [ + [b, []], + ], + }); + } + } + class $Closure6 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure6-5.cjs")({ + $subdir_InflightClass: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"))}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure6Client = ${$Closure6._toInflightType()}; + const client = new $Closure6Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$helpers.preflightClassSingleton(this, 5), ["method"]], + [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], + ], + "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 5), []], + [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], + ], + }); + } + } + const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class captures preflight resource", new $Closure1(this, "$Closure1")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class type captures preflight resource", new $Closure2(this, "$Closure2")); + const getFoo = new $Closure3(this, "$Closure3"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class qualified without explicit reference", new $Closure4(this, "$Closure4")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class defined inflight captures preflight object", new $Closure5(this, "$Closure5")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:bring inflight class from subdir", new $Closure6(this, "$Closure6")); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); @@ -39,3 +544,244 @@ $APP.synth(); //# sourceMappingURL=preflight.cjs.map ``` +## preflight.file1-3.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); +const cloud = $stdlib.cloud; +const util = $stdlib.util; +class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + foo() { + return "foo"; + } + checkWidget(widget) { + return ((widget.compute()) + (blah.Widget.staticCompute(this))); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-2.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Foo }; +//# sourceMappingURL=preflight.file1-3.cjs.map +``` + +## preflight.file2-4.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +const util = $stdlib.util; +class Bar extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + bar() { + (util.Util.nanoid()); + return "bar"; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Bar-3.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const BarClient = ${Bar._toInflightType()}; + const client = new BarClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-3.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Bar }; +//# sourceMappingURL=preflight.file2-4.cjs.map +``` + +## preflight.inflightclass-5.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class InflightClass extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightClass-4.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightClassClient = ${InflightClass._toInflightType()}; + const client = new InflightClassClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "method": [ + ], + "$inflight_init": [ + ], + }); + } +} +if ($preflightTypesMap[5]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[5] = InflightClass; +module.exports = { $preflightTypesMap, InflightClass }; +//# sourceMappingURL=preflight.inflightclass-5.cjs.map +``` + +## preflight.inner-2.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; +//# sourceMappingURL=preflight.inner-2.cjs.map +``` + +## preflight.subdir2-6.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +const $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; +//# sourceMappingURL=preflight.subdir2-6.cjs.map +``` + +## preflight.widget-1.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class Widget extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + compute() { + return 42; + } + static staticCompute($scope) { + return 1337; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Widget-1.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const WidgetClient = ${Widget._toInflightType()}; + const client = new WidgetClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Widget }; +//# sourceMappingURL=preflight.widget-1.cjs.map +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md index e9aae34f065..e7220befa0b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md @@ -2,9 +2,13 @@ ## stdout.log ```log -pass ─ inflight_class_capture_preflight_object.test.wsim (no tests) +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env0/test:inflight class captures preflight resource +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env1/test:inflight class type captures preflight resource +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env2/test:inflight class qualified without explicit reference +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env3/test:inflight class defined inflight captures preflight object +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env4/test:bring inflight class from subdir -Tests 1 passed (1) +Tests 5 passed (5) Snapshots 1 skipped Test Files 1 passed (1) Duration diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index e537abc4187..7b51ee2ebbf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -181,6 +181,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -244,6 +247,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -342,6 +347,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[8]) { throw new Error("F is already in type map"); } + $preflightTypesMap[8] = F; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -369,8 +376,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 8), ["foo"]], + [F, ["foo"]], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 8), []], + [F, []], ], }); } @@ -440,12 +451,16 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 2), ["foo"]], + [B, []], [a, ["goo"]], [d, ["callInner"]], [fn, ["handle"]], [innerD, ["handle"]], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 2), []], + [B, []], [a, []], [d, []], [fn, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md index dabe240a3a0..7486f263ddb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md @@ -59,10 +59,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md index 856df8223f3..1901d050321 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md @@ -239,10 +239,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class PreflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index 8e93c5ec0c9..9a3dfce7fbf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -50,6 +50,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -83,6 +86,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("C is already in type map"); } + $preflightTypesMap[1] = C; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index 0c04970c411..9384086dc1a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class BinaryOperation extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -110,6 +113,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("BinaryOperation is already in type map"); } + $preflightTypesMap[1] = BinaryOperation; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -137,8 +142,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), ["add"]], + [BinaryOperation, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], + [BinaryOperation, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index 983628a34c9..8a655af51ed 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -74,11 +74,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class NotGoo extends $stdlib.std.Resource { + _id = $stdlib.core.closureId(); constructor($scope, $id, ) { super($scope, $id); } @@ -108,6 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("NotGoo is already in type map"); } + $preflightTypesMap[1] = NotGoo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -135,8 +141,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [NotGoo, []], ], "$inflight_init": [ + [NotGoo, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index 2b1a60b79bb..f7b737fd9b7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -60,10 +60,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -92,6 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -119,8 +124,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md index 90f1cc224eb..f9e7a4dc4a0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md @@ -114,6 +114,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md index 3053064bc53..f960ed7ec92 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md @@ -73,6 +73,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md index f12ec6a9126..1504fc3015e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md @@ -64,6 +64,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md index fcd905fd09c..054dbbd2863 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md @@ -46,10 +46,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md index ef4d5090935..b49cf2c35f0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md @@ -434,12 +434,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -574,11 +577,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [fn, ["invoke"]], [fn2, ["invoke"]], [sim, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [fn, []], [fn2, []], [sim, []], @@ -615,9 +620,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), ["fromSeconds"]], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["sleep"]], [foo, [].concat(["inc"], ["get"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), []], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [foo, []], ], }); @@ -652,9 +661,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), ["fromSeconds"]], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["sleep"]], [fn3, [].concat(["invokeAsync"], ["invoke"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), []], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [fn3, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index 107f59abfa7..fae9583fd66 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -192,10 +192,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -231,6 +234,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class FooChild extends Foo { constructor($scope, $id, ) { super($scope, $id); @@ -263,6 +268,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[2]) { throw new Error("FooChild is already in type map"); } + $preflightTypesMap[2] = FooChild; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -290,8 +297,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), [].concat(["field1"], ["field2"])], + [Foo, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], + [Foo, []], ], }); } @@ -323,8 +334,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 2), [].concat(["field1"], ["field2"], ["field3"])], + [FooChild, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 2), []], + [FooChild, []], ], }); } @@ -388,8 +403,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(jsii_fixture.JsiiClass, "jsii-fixture", "JsiiClass"), []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(jsii_fixture.JsiiClass, "jsii-fixture", "JsiiClass"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md index 5ed1e8afb45..4141cadd9c9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md @@ -272,10 +272,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md index 605a0562d1d..f23be52247e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md @@ -289,11 +289,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class AnApi extends (this?.node?.root?.typeForFqn("@winglang/sdk.cloud.Api") ?? cloud.Api) { constructor($scope, $id, ) { super($scope, $id); @@ -383,9 +386,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md index 28e66cf857a..0a09272fbde 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md @@ -91,10 +91,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class FooBase extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -188,9 +191,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [foo, [].concat(["bang"], ["bug"], ["over_inflight"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [foo, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md index 0675acb048d..e8d29f44d7c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md @@ -57,10 +57,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class FooBase extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md index 1cfce89b825..8250a5117e6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md @@ -42,10 +42,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md index 25d7dcdd312..5ae5aa0d286 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md @@ -59,6 +59,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md index 826fa5f8c0b..013392f80ab 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md @@ -226,6 +226,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -260,7 +261,7 @@ class Bar extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.bar-1.cjs.map ``` @@ -274,14 +275,17 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const fs = $stdlib.fs; -const expect = $stdlib.expect; -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const bar = require("./preflight.bar-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const fs = $stdlib.fs; + const expect = $stdlib.expect; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Example extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md index 28a3a575564..f59607ffdf5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md @@ -277,11 +277,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -309,8 +312,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), [].concat(["parse"], ["stringify"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } @@ -344,9 +349,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md index 2bafdc5c8a2..b3e36dff030 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md @@ -66,10 +66,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md index 0774d81ea04..22f947fe294 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md @@ -187,10 +187,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md index c707fb3a1fa..4c64066df78 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -103,9 +106,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [jj, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [jj, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md index e2fc9034d6b..b0b433492ed 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const obj = ({"strValue": "test", "numValue": 1}); const notStringifyStrValue = String.raw({ raw: ["string: ", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))); $helpers.assert($helpers.eq(notStringifyStrValue, "string: \"test\""), "notStringifyStrValue == \"string: \\\"test\\\"\""); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md index 0b2bd167ff6..2d175572d59 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md index a2e5f968652..53eeb3794f7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md @@ -637,10 +637,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md index 78f61f0bbcd..5a63bd27a85 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md @@ -140,10 +140,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -174,6 +177,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -201,8 +206,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -234,9 +241,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 1), ["do"]], [foo, ["handle"]], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 1), []], [foo, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md index b9b5b77c4ab..7357851ee5d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md @@ -111,6 +111,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md index 7b0d6b976a7..8ae9c48474d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md @@ -53,6 +53,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md index 7ed560804f7..3ebdba3c8b7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md @@ -305,11 +305,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyBucket extends $stdlib.std.Resource { constructor($scope, $id, bucket) { super($scope, $id); @@ -410,9 +413,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md index a71a833cc41..5d669059063 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -144,9 +147,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], [f, ["foo"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [f, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md index b1bfee214a8..d730cf7808b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md @@ -145,10 +145,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md index 09892856fa3..c20d2d303cd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md @@ -84,10 +84,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md index 267393b209b..dcedef2d843 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md @@ -86,6 +86,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class B extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md index eda26b8fc99..d4c7ea807d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md @@ -55,10 +55,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const math = $stdlib.math; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const math = $stdlib.math; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -87,9 +90,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), [].concat(["floor"], ["random"])], [ar, [].concat(["at"], ["length"], ["copyMut"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), []], [ar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md index c50b025eeeb..24e28ee1f7f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md @@ -118,6 +118,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md index 4664729ab76..a39a45436db 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md @@ -62,10 +62,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const bucket1 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket1"); const bucket2 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket2"); const bucket3 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket3"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md index cc3f653a9d3..36326b84129 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md @@ -339,11 +339,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Queue extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -515,10 +518,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [c, ["peek"]], [q, ["push"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [c, []], [q, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md index 94699c966bf..2ee9924e3f6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md @@ -174,13 +174,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const c = require("constructs"); -const jsii_fixture = require("jsii-fixture"); -const new_in_static_lib = require("./preflight.newinstaticlib-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const c = require("constructs"); + const jsii_fixture = require("jsii-fixture"); + const new_in_static_lib = $helpers.bringJs(`${__dirname}/preflight.newinstaticlib-1.cjs`, $preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -358,6 +361,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -417,7 +421,7 @@ class LibClass extends $stdlib.std.Resource { }); } } -module.exports = { Foo, LibClass }; +module.exports = { $preflightTypesMap, Foo, LibClass }; //# sourceMappingURL=preflight.newinstaticlib-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md index 2600606fde2..9905f1aa986 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md @@ -35,6 +35,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -94,7 +95,7 @@ class LibClass extends $stdlib.std.Resource { }); } } -module.exports = { Foo, LibClass }; +module.exports = { $preflightTypesMap, Foo, LibClass }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md index 6ddb1f36591..4adf970a686 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md @@ -56,10 +56,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class CustomScope extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md index f532f728ef4..69b29e866b7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md @@ -104,10 +104,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md index 7e78d7ad70d..325aa8db4a3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -110,14 +113,17 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "m1": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } static get _liftTypeMap() { return ({ "m2": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md index 0ea88a8d77f..d8d0f7ef0f3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md @@ -123,11 +123,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; const Person = $stdlib.std.Struct._createJsonSchema({$id:"/Person",type:"object",properties:{age:{type:"number"},name:{type:"string"},},required:["age","name",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Super extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md index 3503181bdfd..d98bb1e2e87 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md @@ -31,7 +31,10 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{houses:{type:"array",items:{type:"object",properties:{address:{type:"string"},residents:{type:"array",items:{type:"object",properties:{age:{type:"number"},name:{type:"string"},},required:["age","name",]}},},required:["address","residents",]}},},required:["houses",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); $helpers.assert($helpers.eq(myParams.houses.length, 2), "myParams.houses.length == 2"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md index e304cb025bd..caa21223aea 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md @@ -31,7 +31,10 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{foo:{type:"string"},meaningOfLife:{type:"number"},},required:["meaningOfLife",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md index 9bf16ceb677..16a89f4f03c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md @@ -136,11 +136,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -171,11 +174,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["notEqual"])], [api.url, [].concat(["startsWith"], ["length"])], [tokenLength, []], [urlRegex, ["test"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [api.url, []], [tokenLength, []], [urlRegex, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md index b1371d2ece1..7d06eb6d50c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const dur = (std.Duration.fromSeconds(60)); const dur2 = (std.Duration.fromSeconds(600)); const f = ((d) => { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md index a01629c4119..58710b5f17d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md index 9a2f46ad429..d45eb465d4e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md @@ -45,6 +45,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md index df675212cda..d398c6056c9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md @@ -681,12 +681,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const ex = $stdlib.ex; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const ex = $stdlib.ex; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -752,11 +755,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [queue, ["push"]], [r, ["get"]], [r2, [].concat(["set"], ["get"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [queue, []], [r, []], [r2, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md index c53272518fe..3117975832c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md @@ -708,11 +708,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; @@ -806,11 +809,13 @@ class $Root extends $stdlib.std.Resource { "testTypeAccess": [ [Bar, ["barStatic"]], [Foo, ["fooStatic"]], + [MyEnum, ["B"]], [this.e, []], ], "$inflight_init": [ [Bar, []], [Foo, []], + [MyEnum, []], [this.b, []], [this.e, []], [this.foo, []], @@ -1052,9 +1057,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [bigOlPublisher, [].concat(["publish"], ["getObjectCount"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [bigOlPublisher, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md index 4ae8a6f7e61..36da9581699 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md @@ -174,10 +174,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md index 0509113ee0e..c0ef8f3ca0f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md @@ -86,10 +86,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Another extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md index e3a9b7f7cbe..41bd603ecf9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md @@ -240,10 +240,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class First extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md index 83635822e9d..c3d106d17c4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md @@ -362,11 +362,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class First extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -517,6 +520,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "myPut": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [Another, ["myStaticMethod"]], [globalAnother, ["myMethod"]], [globalAnother.first.myResource, ["put"]], @@ -532,6 +536,7 @@ class $Root extends $stdlib.std.Resource { [this.localTopic, ["publish"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [Another, []], [globalAnother, []], [globalAnother.first.myResource, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md index 72c0fe616c3..217349b8a7d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md index f0b9fecca15..a5c64b95b56 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md @@ -80,10 +80,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md index fd0ae7a5677..7711b440596 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md @@ -75,10 +75,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const sim = $stdlib.sim; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const sim = $stdlib.sim; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; @@ -126,6 +129,7 @@ class $Root extends $stdlib.std.Resource { "methodWithJsons": [ ], "methodWithEnums": [ + [MyEnum, ["A"]], ], "methodWithArrays": [ ], @@ -138,10 +142,13 @@ class $Root extends $stdlib.std.Resource { "methodWithComplexTypes": [ ], "$inflight_init": [ + [MyEnum, []], ], }); } } + if ($preflightTypesMap[1]) { throw new Error("ResourceBackend is already in type map"); } + $preflightTypesMap[1] = ResourceBackend; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md index 7fdd23242c0..87c6fd80fb3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md @@ -36,6 +36,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class A extends $stdlib.std.Resource { constructor($scope, $id, a) { super($scope, $id); @@ -95,7 +96,7 @@ class B extends A { }); } } -module.exports = { }; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md index 30eb8fa4754..62dfa63453e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md @@ -67,10 +67,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md index 8d74f4b9971..e4d65b4ad3f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const x = 2; const y = x; const id = 1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md index 780b990a746..889b4c06696 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md @@ -75,10 +75,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md index d6009c0537f..2c88436783f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md @@ -75,6 +75,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Animal extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md index 9838e17fea0..7e6b876f3f0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md @@ -53,6 +53,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md index 5afb35fc2ee..2fc82a4643e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md @@ -59,7 +59,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const file3 = require("./preflight.empty-1.cjs"); +let $preflightTypesMap = {}; +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = @@ -169,7 +170,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Util, Store, Color }; +module.exports = { $preflightTypesMap, Util, Store, Color }; //# sourceMappingURL=preflight.cjs.map ``` @@ -180,7 +181,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.empty-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md index abf6a1f0424..c7c2345a711 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index dbd874c1694..65c76f35127 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -176,12 +176,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const externalStructs = require("./preflight.structs-1.cjs"); -const otherExternalStructs = require("./preflight.structs2-2.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const externalStructs = $helpers.bringJs(`${__dirname}/preflight.structs-1.cjs`, $preflightTypesMap); + const otherExternalStructs = $helpers.bringJs(`${__dirname}/preflight.structs2-2.cjs`, $preflightTypesMap); const Bar = $stdlib.std.Struct._createJsonSchema({$id:"/Bar",type:"object",properties:{b:{type:"number"},f:{type:"string"},},required:["b","f",]}); const Foo = $stdlib.std.Struct._createJsonSchema({$id:"/Foo",type:"object",properties:{f:{type:"string"},},required:["f",]}); const Foosible = $stdlib.std.Struct._createJsonSchema({$id:"/Foosible",type:"object",properties:{f:{type:"string"},},required:[]}); @@ -189,6 +191,7 @@ class $Root extends $stdlib.std.Resource { const Student = $stdlib.std.Struct._createJsonSchema({$id:"/Student",type:"object",properties:{additionalData:{type:["object","string","boolean","number","array"]},advisor:{type:"object",properties:{dob:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},employeeID:{type:"string"},firstName:{type:"string"},lastName:{type:"string"},},required:["dob","employeeID","firstName","lastName",]},coursesTaken:{type:"array",items:{type:"object",properties:{course:{type:"object",properties:{credits:{type:"number"},name:{type:"string"},},required:["credits","name",]},dateTaken:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},grade:{type:"string"},},required:["course","dateTaken","grade",]}},dob:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},enrolled:{type:"boolean"},enrolledCourses:{type:"array",uniqueItems:true,items:{type:"object",properties:{credits:{type:"number"},name:{type:"string"},},required:["credits","name",]}},firstName:{type:"string"},lastName:{type:"string"},schoolId:{type:"string"},},required:["dob","enrolled","firstName","lastName","schoolId",]}); const cloud_BucketProps = $stdlib.std.Struct._createJsonSchema({$id:"/BucketProps",type:"object",properties:{public:{type:"boolean"},},required:[]}); const externalStructs_MyOtherStruct = $stdlib.std.Struct._createJsonSchema({$id:"/MyOtherStruct",type:"object",properties:{data:{type:"object",properties:{val:{type:"number"},},required:["val",]},},required:["data",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -217,9 +220,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(cloud_BucketProps, "@winglang/sdk/cloud", "BucketProps"), ["fromJson"]], [j, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(cloud_BucketProps, "@winglang/sdk/cloud", "BucketProps"), []], [j, []], ], }); @@ -252,8 +257,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Student, ["fromJson"]], ], "$inflight_init": [ + [Student, []], ], }); } @@ -286,9 +293,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Student, ["fromJson"]], [jStudent1, []], ], "$inflight_init": [ + [Student, []], [jStudent1, []], ], }); @@ -325,11 +334,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], + [MyStruct, ["schema"]], [expectedSchema, []], [jMyStruct, []], [schema, ["asStr"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], + [MyStruct, []], [expectedSchema, []], [jMyStruct, []], [schema, []], @@ -367,8 +380,16 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Boolean, "@winglang/sdk/std", "Boolean"), ["fromJson"]], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), ["fromJson"]], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), ["fromJson"]], + [Student, ["fromJson"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Boolean, "@winglang/sdk/std", "Boolean"), []], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), []], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), []], + [Student, []], ], }); } @@ -511,7 +532,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.structs-1.cjs.map ``` @@ -522,6 +544,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const SomeStruct = $stdlib.std.Struct._createJsonSchema({$id:"/SomeStruct",type:"object",properties:{foo:{type:"string"},},required:["foo",]}); class UsesStructInImportedFile extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -552,7 +575,7 @@ class UsesStructInImportedFile extends $stdlib.std.Resource { }); } } -module.exports = { UsesStructInImportedFile }; +module.exports = { $preflightTypesMap, UsesStructInImportedFile }; //# sourceMappingURL=preflight.structs2-2.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md index c7f1e74c5a8..234bfdbe3d8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md @@ -67,10 +67,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, b) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index def61b603a0..083a31cb4d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -223,11 +223,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -412,6 +415,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[6]) { throw new Error("InflightA is already in type map"); } + $preflightTypesMap[6] = InflightA; class InflightB extends InflightA { constructor($scope, $id, ) { super($scope, $id); @@ -443,6 +448,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[7]) { throw new Error("InflightB is already in type map"); } + $preflightTypesMap[7] = InflightB; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -471,8 +478,14 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.preflightClassSingleton(this, 7), ["description"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [InflightB, []], ], "$inflight_init": [ + [$helpers.preflightClassSingleton(this, 7), []], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [InflightB, []], ], }); } @@ -572,9 +585,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [extended, ["do"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [extended, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md index 421ba0afddc..42b94770984 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md @@ -123,10 +123,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md index 0e2da91975a..c927d4a3054 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md @@ -52,10 +52,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const ex = $stdlib.ex; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const ex = $stdlib.ex; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const t = this.node.root.new("@winglang/sdk.ex.Table", ex.Table, this, "Table", { name: "simple-table", primaryKey: "id", columns: ({["id"]: ex.ColumnType.STRING, ["name"]: ex.ColumnType.STRING, ["age"]: ex.ColumnType.NUMBER}) }); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md index 3c3ac279786..5ea2ff2f6cb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md @@ -85,10 +85,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md index 7b18f6b34ae..599ddd7e22c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md index 2356d69988e..a62860645e0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md @@ -28,10 +28,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const path = $helpers.nodeof(this).path; for (const c of $helpers.nodeof(this).children) { console.log($helpers.nodeof(c).path); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md index c6e72bfd406..250004648b3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md @@ -62,10 +62,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md index 4010f1331de..ea344d1aede 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; let x = ""; try { throw new Error("hello"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md index 096a246a18b..ba775e69f5d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md @@ -120,10 +120,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md index b66cafb179b..136422bbe26 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md @@ -170,10 +170,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 692db90b036..fabea5493dc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -628,13 +628,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -663,9 +666,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [usersTable, ["list"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [usersTable, []], ], }); @@ -699,9 +704,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), [].concat(["parse"], ["stringify"])], [usersTable, ["insert"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [usersTable, []], ], }); @@ -737,9 +744,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["GET"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -775,9 +788,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md index d380f7b9611..710be6ffecd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md @@ -31,6 +31,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; while (false) { const x = 1; } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md index 536b86d5155..b86de064c41 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md @@ -189,10 +189,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) {