From 1852f1291ead40c5f76fb028750db01e4d3f1868 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Dec 2023 12:08:41 +0100 Subject: [PATCH 1/5] esm --- ...XDataProvider.js => ICU4XDataProvider.mjs} | 2 +- ...XFixedDecimal.js => ICU4XFixedDecimal.mjs} | 2 +- ...tter.js => ICU4XFixedDecimalFormatter.mjs} | 4 +- ... => ICU4XFixedDecimalFormatterOptions.mjs} | 4 +- ... => ICU4XFixedDecimalGroupingStrategy.mjs} | 2 +- .../api/{ICU4XLocale.js => ICU4XLocale.mjs} | 2 +- ...plomat-runtime.js => diplomat-runtime.mjs} | 0 example/js/lib/api/diplomat-wasm.mjs | 4 +- example/js/lib/api/index.d.ts | 14 ++--- example/js/lib/api/index.js | 7 --- example/js/lib/api/index.mjs | 7 +++ .../js/api/{AttrEnum.js => AttrEnum.mjs} | 2 +- .../api/{AttrOpaque1.js => AttrOpaque1.mjs} | 2 +- .../api/{AttrOpaque2.js => AttrOpaque2.mjs} | 2 +- feature_tests/js/api/{Bar.js => Bar.mjs} | 2 +- .../{BorrowedFields.js => BorrowedFields.mjs} | 2 +- ...turning.js => BorrowedFieldsReturning.mjs} | 2 +- .../{ContiguousEnum.js => ContiguousEnum.mjs} | 2 +- .../js/api/{ErrorEnum.js => ErrorEnum.mjs} | 2 +- .../api/{ErrorStruct.js => ErrorStruct.mjs} | 2 +- .../js/api/{Float64Vec.js => Float64Vec.mjs} | 2 +- feature_tests/js/api/{Foo.js => Foo.mjs} | 6 +-- .../{ImportedStruct.js => ImportedStruct.mjs} | 4 +- .../js/api/{MyEnum.js => MyEnum.mjs} | 2 +- .../js/api/{MyString.js => MyString.mjs} | 2 +- .../js/api/{MyStruct.js => MyStruct.mjs} | 4 +- feature_tests/js/api/{One.js => One.mjs} | 2 +- .../js/api/{Opaque.js => Opaque.mjs} | 8 +-- .../api/{OptionOpaque.js => OptionOpaque.mjs} | 4 +- ...tionOpaqueChar.js => OptionOpaqueChar.mjs} | 2 +- .../api/{OptionStruct.js => OptionStruct.mjs} | 6 +-- .../js/api/{RefList.js => RefList.mjs} | 2 +- ...fListParameter.js => RefListParameter.mjs} | 2 +- .../api/{ResultOpaque.js => ResultOpaque.mjs} | 6 +-- feature_tests/js/api/{Two.js => Two.mjs} | 2 +- .../{UnimportedEnum.js => UnimportedEnum.mjs} | 2 +- ...plomat-runtime.js => diplomat-runtime.mjs} | 0 feature_tests/js/api/diplomat-wasm.mjs | 4 +- feature_tests/js/api/index.d.ts | 52 +++++++++---------- feature_tests/js/api/index.js | 26 ---------- feature_tests/js/api/index.mjs | 26 ++++++++++ tool/src/js/mod.rs | 20 +++---- tool/src/js/test_util.rs | 2 +- tool/src/js/wasm.mjs | 4 +- 44 files changed, 128 insertions(+), 128 deletions(-) rename example/js/lib/api/{ICU4XDataProvider.js => ICU4XDataProvider.mjs} (93%) rename example/js/lib/api/{ICU4XFixedDecimal.js => ICU4XFixedDecimal.mjs} (94%) rename example/js/lib/api/{ICU4XFixedDecimalFormatter.js => ICU4XFixedDecimalFormatter.mjs} (95%) rename example/js/lib/api/{ICU4XFixedDecimalFormatterOptions.js => ICU4XFixedDecimalFormatterOptions.mjs} (91%) rename example/js/lib/api/{ICU4XFixedDecimalGroupingStrategy.js => ICU4XFixedDecimalGroupingStrategy.mjs} (87%) rename example/js/lib/api/{ICU4XLocale.js => ICU4XLocale.mjs} (92%) rename example/js/lib/api/{diplomat-runtime.js => diplomat-runtime.mjs} (100%) delete mode 100644 example/js/lib/api/index.js create mode 100644 example/js/lib/api/index.mjs rename feature_tests/js/api/{AttrEnum.js => AttrEnum.mjs} (81%) rename feature_tests/js/api/{AttrOpaque1.js => AttrOpaque1.mjs} (90%) rename feature_tests/js/api/{AttrOpaque2.js => AttrOpaque2.mjs} (88%) rename feature_tests/js/api/{Bar.js => Bar.mjs} (87%) rename feature_tests/js/api/{BorrowedFields.js => BorrowedFields.mjs} (91%) rename feature_tests/js/api/{BorrowedFieldsReturning.js => BorrowedFieldsReturning.mjs} (83%) rename feature_tests/js/api/{ContiguousEnum.js => ContiguousEnum.mjs} (84%) rename feature_tests/js/api/{ErrorEnum.js => ErrorEnum.mjs} (80%) rename feature_tests/js/api/{ErrorStruct.js => ErrorStruct.mjs} (80%) rename feature_tests/js/api/{Float64Vec.js => Float64Vec.mjs} (95%) rename feature_tests/js/api/{Foo.js => Foo.mjs} (95%) rename feature_tests/js/api/{ImportedStruct.js => ImportedStruct.mjs} (79%) rename feature_tests/js/api/{MyEnum.js => MyEnum.mjs} (85%) rename feature_tests/js/api/{MyString.js => MyString.mjs} (95%) rename feature_tests/js/api/{MyStruct.js => MyStruct.mjs} (91%) rename feature_tests/js/api/{One.js => One.mjs} (98%) rename feature_tests/js/api/{Opaque.js => Opaque.mjs} (87%) rename feature_tests/js/api/{OptionOpaque.js => OptionOpaque.mjs} (93%) rename feature_tests/js/api/{OptionOpaqueChar.js => OptionOpaqueChar.mjs} (90%) rename feature_tests/js/api/{OptionStruct.js => OptionStruct.mjs} (81%) rename feature_tests/js/api/{RefList.js => RefList.mjs} (90%) rename feature_tests/js/api/{RefListParameter.js => RefListParameter.mjs} (88%) rename feature_tests/js/api/{ResultOpaque.js => ResultOpaque.mjs} (98%) rename feature_tests/js/api/{Two.js => Two.mjs} (87%) rename feature_tests/js/api/{UnimportedEnum.js => UnimportedEnum.mjs} (82%) rename feature_tests/js/api/{diplomat-runtime.js => diplomat-runtime.mjs} (100%) delete mode 100644 feature_tests/js/api/index.js create mode 100644 feature_tests/js/api/index.mjs diff --git a/example/js/lib/api/ICU4XDataProvider.js b/example/js/lib/api/ICU4XDataProvider.mjs similarity index 93% rename from example/js/lib/api/ICU4XDataProvider.js rename to example/js/lib/api/ICU4XDataProvider.mjs index c1ff03e57..37ee1f666 100644 --- a/example/js/lib/api/ICU4XDataProvider.js +++ b/example/js/lib/api/ICU4XDataProvider.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const ICU4XDataProvider_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.ICU4XDataProvider_destroy(underlying); diff --git a/example/js/lib/api/ICU4XFixedDecimal.js b/example/js/lib/api/ICU4XFixedDecimal.mjs similarity index 94% rename from example/js/lib/api/ICU4XFixedDecimal.js rename to example/js/lib/api/ICU4XFixedDecimal.mjs index 44cbf6bcb..0c30aecce 100644 --- a/example/js/lib/api/ICU4XFixedDecimal.js +++ b/example/js/lib/api/ICU4XFixedDecimal.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const ICU4XFixedDecimal_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.ICU4XFixedDecimal_destroy(underlying); diff --git a/example/js/lib/api/ICU4XFixedDecimalFormatter.js b/example/js/lib/api/ICU4XFixedDecimalFormatter.mjs similarity index 95% rename from example/js/lib/api/ICU4XFixedDecimalFormatter.js rename to example/js/lib/api/ICU4XFixedDecimalFormatter.mjs index f93673770..0b3d69dd9 100644 --- a/example/js/lib/api/ICU4XFixedDecimalFormatter.js +++ b/example/js/lib/api/ICU4XFixedDecimalFormatter.mjs @@ -1,6 +1,6 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { ICU4XFixedDecimalGroupingStrategy_js_to_rust, ICU4XFixedDecimalGroupingStrategy_rust_to_js } from "./ICU4XFixedDecimalGroupingStrategy.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { ICU4XFixedDecimalGroupingStrategy_js_to_rust, ICU4XFixedDecimalGroupingStrategy_rust_to_js } from "./ICU4XFixedDecimalGroupingStrategy.mjs" const ICU4XFixedDecimalFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.ICU4XFixedDecimalFormatter_destroy(underlying); diff --git a/example/js/lib/api/ICU4XFixedDecimalFormatterOptions.js b/example/js/lib/api/ICU4XFixedDecimalFormatterOptions.mjs similarity index 91% rename from example/js/lib/api/ICU4XFixedDecimalFormatterOptions.js rename to example/js/lib/api/ICU4XFixedDecimalFormatterOptions.mjs index b34a2bc43..4c0c6f380 100644 --- a/example/js/lib/api/ICU4XFixedDecimalFormatterOptions.js +++ b/example/js/lib/api/ICU4XFixedDecimalFormatterOptions.mjs @@ -1,6 +1,6 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { ICU4XFixedDecimalGroupingStrategy_js_to_rust, ICU4XFixedDecimalGroupingStrategy_rust_to_js } from "./ICU4XFixedDecimalGroupingStrategy.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { ICU4XFixedDecimalGroupingStrategy_js_to_rust, ICU4XFixedDecimalGroupingStrategy_rust_to_js } from "./ICU4XFixedDecimalGroupingStrategy.mjs" export class ICU4XFixedDecimalFormatterOptions { constructor(underlying) { diff --git a/example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.js b/example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.mjs similarity index 87% rename from example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.js rename to example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.mjs index 8272ee599..e1de0f358 100644 --- a/example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.js +++ b/example/js/lib/api/ICU4XFixedDecimalGroupingStrategy.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const ICU4XFixedDecimalGroupingStrategy_js_to_rust = { "Auto": 0, diff --git a/example/js/lib/api/ICU4XLocale.js b/example/js/lib/api/ICU4XLocale.mjs similarity index 92% rename from example/js/lib/api/ICU4XLocale.js rename to example/js/lib/api/ICU4XLocale.mjs index af17436dd..791cf6dfa 100644 --- a/example/js/lib/api/ICU4XLocale.js +++ b/example/js/lib/api/ICU4XLocale.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const ICU4XLocale_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.ICU4XLocale_destroy(underlying); diff --git a/example/js/lib/api/diplomat-runtime.js b/example/js/lib/api/diplomat-runtime.mjs similarity index 100% rename from example/js/lib/api/diplomat-runtime.js rename to example/js/lib/api/diplomat-runtime.mjs diff --git a/example/js/lib/api/diplomat-wasm.mjs b/example/js/lib/api/diplomat-wasm.mjs index 70ad14546..12a340b17 100644 --- a/example/js/lib/api/diplomat-wasm.mjs +++ b/example/js/lib/api/diplomat-wasm.mjs @@ -1,5 +1,5 @@ -import cfg from '../diplomat.config.js'; -import {readString8} from './diplomat-runtime.js' +import cfg from '../diplomat.config.mjs'; +import {readString8} from './diplomat-runtime.mjs' let wasm; diff --git a/example/js/lib/api/index.d.ts b/example/js/lib/api/index.d.ts index a1818ce68..14599fe64 100644 --- a/example/js/lib/api/index.d.ts +++ b/example/js/lib/api/index.d.ts @@ -1,7 +1,7 @@ -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { ICU4XDataProvider } from './ICU4XDataProvider.js'; -export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.js'; -export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.js'; -export { ICU4XFixedDecimalFormatterOptions } from './ICU4XFixedDecimalFormatterOptions.js'; -export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.js'; -export { ICU4XLocale } from './ICU4XLocale.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { ICU4XDataProvider } from './ICU4XDataProvider.mjs'; +export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.mjs'; +export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.mjs'; +export { ICU4XFixedDecimalFormatterOptions } from './ICU4XFixedDecimalFormatterOptions.mjs'; +export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.mjs'; +export { ICU4XLocale } from './ICU4XLocale.mjs'; diff --git a/example/js/lib/api/index.js b/example/js/lib/api/index.js deleted file mode 100644 index d31fda63c..000000000 --- a/example/js/lib/api/index.js +++ /dev/null @@ -1,7 +0,0 @@ -export { FFIError } from './diplomat-runtime.js'; -export { ICU4XDataProvider } from './ICU4XDataProvider.js'; -export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.js'; -export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.js'; -export { ICU4XFixedDecimalFormatterOptions } from './ICU4XFixedDecimalFormatterOptions.js'; -export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.js'; -export { ICU4XLocale } from './ICU4XLocale.js'; diff --git a/example/js/lib/api/index.mjs b/example/js/lib/api/index.mjs new file mode 100644 index 000000000..a31f0286a --- /dev/null +++ b/example/js/lib/api/index.mjs @@ -0,0 +1,7 @@ +export { FFIError } from './diplomat-runtime.mjs'; +export { ICU4XDataProvider } from './ICU4XDataProvider.mjs'; +export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.mjs'; +export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.mjs'; +export { ICU4XFixedDecimalFormatterOptions } from './ICU4XFixedDecimalFormatterOptions.mjs'; +export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.mjs'; +export { ICU4XLocale } from './ICU4XLocale.mjs'; diff --git a/feature_tests/js/api/AttrEnum.js b/feature_tests/js/api/AttrEnum.mjs similarity index 81% rename from feature_tests/js/api/AttrEnum.js rename to feature_tests/js/api/AttrEnum.mjs index 1def4cc79..e02a9fabe 100644 --- a/feature_tests/js/api/AttrEnum.js +++ b/feature_tests/js/api/AttrEnum.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const AttrEnum_js_to_rust = { "A": 0, diff --git a/feature_tests/js/api/AttrOpaque1.js b/feature_tests/js/api/AttrOpaque1.mjs similarity index 90% rename from feature_tests/js/api/AttrOpaque1.js rename to feature_tests/js/api/AttrOpaque1.mjs index f94535621..5fa7b0402 100644 --- a/feature_tests/js/api/AttrOpaque1.js +++ b/feature_tests/js/api/AttrOpaque1.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const AttrOpaque1_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.AttrOpaque1_destroy(underlying); diff --git a/feature_tests/js/api/AttrOpaque2.js b/feature_tests/js/api/AttrOpaque2.mjs similarity index 88% rename from feature_tests/js/api/AttrOpaque2.js rename to feature_tests/js/api/AttrOpaque2.mjs index 6e196464e..1a8ae9a68 100644 --- a/feature_tests/js/api/AttrOpaque2.js +++ b/feature_tests/js/api/AttrOpaque2.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const AttrOpaque2_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.AttrOpaque2_destroy(underlying); diff --git a/feature_tests/js/api/Bar.js b/feature_tests/js/api/Bar.mjs similarity index 87% rename from feature_tests/js/api/Bar.js rename to feature_tests/js/api/Bar.mjs index 14e90c565..66613b0e3 100644 --- a/feature_tests/js/api/Bar.js +++ b/feature_tests/js/api/Bar.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const Bar_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Bar_destroy(underlying); diff --git a/feature_tests/js/api/BorrowedFields.js b/feature_tests/js/api/BorrowedFields.mjs similarity index 91% rename from feature_tests/js/api/BorrowedFields.js rename to feature_tests/js/api/BorrowedFields.mjs index d6348ed32..743f9a0c8 100644 --- a/feature_tests/js/api/BorrowedFields.js +++ b/feature_tests/js/api/BorrowedFields.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export class BorrowedFields { constructor(underlying, edges_a) { diff --git a/feature_tests/js/api/BorrowedFieldsReturning.js b/feature_tests/js/api/BorrowedFieldsReturning.mjs similarity index 83% rename from feature_tests/js/api/BorrowedFieldsReturning.js rename to feature_tests/js/api/BorrowedFieldsReturning.mjs index ca5da0625..ee0ee5192 100644 --- a/feature_tests/js/api/BorrowedFieldsReturning.js +++ b/feature_tests/js/api/BorrowedFieldsReturning.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export class BorrowedFieldsReturning { constructor(underlying, edges_a) { diff --git a/feature_tests/js/api/ContiguousEnum.js b/feature_tests/js/api/ContiguousEnum.mjs similarity index 84% rename from feature_tests/js/api/ContiguousEnum.js rename to feature_tests/js/api/ContiguousEnum.mjs index 5c74ce3ae..53b7982c9 100644 --- a/feature_tests/js/api/ContiguousEnum.js +++ b/feature_tests/js/api/ContiguousEnum.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const ContiguousEnum_js_to_rust = { "C": 0, diff --git a/feature_tests/js/api/ErrorEnum.js b/feature_tests/js/api/ErrorEnum.mjs similarity index 80% rename from feature_tests/js/api/ErrorEnum.js rename to feature_tests/js/api/ErrorEnum.mjs index 5dfa06608..622f30cde 100644 --- a/feature_tests/js/api/ErrorEnum.js +++ b/feature_tests/js/api/ErrorEnum.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const ErrorEnum_js_to_rust = { "Foo": 0, diff --git a/feature_tests/js/api/ErrorStruct.js b/feature_tests/js/api/ErrorStruct.mjs similarity index 80% rename from feature_tests/js/api/ErrorStruct.js rename to feature_tests/js/api/ErrorStruct.mjs index 25c03b587..f12829c98 100644 --- a/feature_tests/js/api/ErrorStruct.js +++ b/feature_tests/js/api/ErrorStruct.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export class ErrorStruct { constructor(underlying) { diff --git a/feature_tests/js/api/Float64Vec.js b/feature_tests/js/api/Float64Vec.mjs similarity index 95% rename from feature_tests/js/api/Float64Vec.js rename to feature_tests/js/api/Float64Vec.mjs index 055baa22d..62ceebefa 100644 --- a/feature_tests/js/api/Float64Vec.js +++ b/feature_tests/js/api/Float64Vec.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const Float64Vec_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Float64Vec_destroy(underlying); diff --git a/feature_tests/js/api/Foo.js b/feature_tests/js/api/Foo.mjs similarity index 95% rename from feature_tests/js/api/Foo.js rename to feature_tests/js/api/Foo.mjs index 7210ea6ad..cd8e0387e 100644 --- a/feature_tests/js/api/Foo.js +++ b/feature_tests/js/api/Foo.mjs @@ -1,7 +1,7 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { Bar } from "./Bar.js" -import { BorrowedFieldsReturning } from "./BorrowedFieldsReturning.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { Bar } from "./Bar.mjs" +import { BorrowedFieldsReturning } from "./BorrowedFieldsReturning.mjs" const Foo_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Foo_destroy(underlying); diff --git a/feature_tests/js/api/ImportedStruct.js b/feature_tests/js/api/ImportedStruct.mjs similarity index 79% rename from feature_tests/js/api/ImportedStruct.js rename to feature_tests/js/api/ImportedStruct.mjs index 071c60170..be605f311 100644 --- a/feature_tests/js/api/ImportedStruct.js +++ b/feature_tests/js/api/ImportedStruct.mjs @@ -1,6 +1,6 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { UnimportedEnum_js_to_rust, UnimportedEnum_rust_to_js } from "./UnimportedEnum.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { UnimportedEnum_js_to_rust, UnimportedEnum_rust_to_js } from "./UnimportedEnum.mjs" export class ImportedStruct { constructor(underlying) { diff --git a/feature_tests/js/api/MyEnum.js b/feature_tests/js/api/MyEnum.mjs similarity index 85% rename from feature_tests/js/api/MyEnum.js rename to feature_tests/js/api/MyEnum.mjs index 39b075fff..aba17a929 100644 --- a/feature_tests/js/api/MyEnum.js +++ b/feature_tests/js/api/MyEnum.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const MyEnum_js_to_rust = { "A": -2, diff --git a/feature_tests/js/api/MyString.js b/feature_tests/js/api/MyString.mjs similarity index 95% rename from feature_tests/js/api/MyString.js rename to feature_tests/js/api/MyString.mjs index 34bc29c6b..84ed9b35a 100644 --- a/feature_tests/js/api/MyString.js +++ b/feature_tests/js/api/MyString.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyString_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyString_destroy(underlying); diff --git a/feature_tests/js/api/MyStruct.js b/feature_tests/js/api/MyStruct.mjs similarity index 91% rename from feature_tests/js/api/MyStruct.js rename to feature_tests/js/api/MyStruct.mjs index ebf5ec5c3..19bbf4cdd 100644 --- a/feature_tests/js/api/MyStruct.js +++ b/feature_tests/js/api/MyStruct.mjs @@ -1,6 +1,6 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { MyEnum_js_to_rust, MyEnum_rust_to_js } from "./MyEnum.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { MyEnum_js_to_rust, MyEnum_rust_to_js } from "./MyEnum.mjs" export class MyStruct { constructor(underlying) { diff --git a/feature_tests/js/api/One.js b/feature_tests/js/api/One.mjs similarity index 98% rename from feature_tests/js/api/One.js rename to feature_tests/js/api/One.mjs index bc428a21c..b7ecfe9bb 100644 --- a/feature_tests/js/api/One.js +++ b/feature_tests/js/api/One.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const One_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.One_destroy(underlying); diff --git a/feature_tests/js/api/Opaque.js b/feature_tests/js/api/Opaque.mjs similarity index 87% rename from feature_tests/js/api/Opaque.js rename to feature_tests/js/api/Opaque.mjs index 8d8ddb2e2..09375c70c 100644 --- a/feature_tests/js/api/Opaque.js +++ b/feature_tests/js/api/Opaque.mjs @@ -1,8 +1,8 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { ImportedStruct } from "./ImportedStruct.js" -import { MyEnum_js_to_rust, MyEnum_rust_to_js } from "./MyEnum.js" -import { UnimportedEnum_js_to_rust, UnimportedEnum_rust_to_js } from "./UnimportedEnum.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { ImportedStruct } from "./ImportedStruct.mjs" +import { MyEnum_js_to_rust, MyEnum_rust_to_js } from "./MyEnum.mjs" +import { UnimportedEnum_js_to_rust, UnimportedEnum_rust_to_js } from "./UnimportedEnum.mjs" const Opaque_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Opaque_destroy(underlying); diff --git a/feature_tests/js/api/OptionOpaque.js b/feature_tests/js/api/OptionOpaque.mjs similarity index 93% rename from feature_tests/js/api/OptionOpaque.js rename to feature_tests/js/api/OptionOpaque.mjs index 016f0c577..837fe49f9 100644 --- a/feature_tests/js/api/OptionOpaque.js +++ b/feature_tests/js/api/OptionOpaque.mjs @@ -1,6 +1,6 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { OptionStruct } from "./OptionStruct.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { OptionStruct } from "./OptionStruct.mjs" const OptionOpaque_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.OptionOpaque_destroy(underlying); diff --git a/feature_tests/js/api/OptionOpaqueChar.js b/feature_tests/js/api/OptionOpaqueChar.mjs similarity index 90% rename from feature_tests/js/api/OptionOpaqueChar.js rename to feature_tests/js/api/OptionOpaqueChar.mjs index 82935403e..30c41bdbe 100644 --- a/feature_tests/js/api/OptionOpaqueChar.js +++ b/feature_tests/js/api/OptionOpaqueChar.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const OptionOpaqueChar_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.OptionOpaqueChar_destroy(underlying); diff --git a/feature_tests/js/api/OptionStruct.js b/feature_tests/js/api/OptionStruct.mjs similarity index 81% rename from feature_tests/js/api/OptionStruct.js rename to feature_tests/js/api/OptionStruct.mjs index b7ea47fd3..170e88b8d 100644 --- a/feature_tests/js/api/OptionStruct.js +++ b/feature_tests/js/api/OptionStruct.mjs @@ -1,7 +1,7 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { OptionOpaque } from "./OptionOpaque.js" -import { OptionOpaqueChar } from "./OptionOpaqueChar.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { OptionOpaque } from "./OptionOpaque.mjs" +import { OptionOpaqueChar } from "./OptionOpaqueChar.mjs" export class OptionStruct { constructor(underlying) { diff --git a/feature_tests/js/api/RefList.js b/feature_tests/js/api/RefList.mjs similarity index 90% rename from feature_tests/js/api/RefList.js rename to feature_tests/js/api/RefList.mjs index 87a6e5fe4..4882abe27 100644 --- a/feature_tests/js/api/RefList.js +++ b/feature_tests/js/api/RefList.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const RefList_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.RefList_destroy(underlying); diff --git a/feature_tests/js/api/RefListParameter.js b/feature_tests/js/api/RefListParameter.mjs similarity index 88% rename from feature_tests/js/api/RefListParameter.js rename to feature_tests/js/api/RefListParameter.mjs index 2032f1f5b..53de1cbbf 100644 --- a/feature_tests/js/api/RefListParameter.js +++ b/feature_tests/js/api/RefListParameter.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const RefListParameter_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.RefListParameter_destroy(underlying); diff --git a/feature_tests/js/api/ResultOpaque.js b/feature_tests/js/api/ResultOpaque.mjs similarity index 98% rename from feature_tests/js/api/ResultOpaque.js rename to feature_tests/js/api/ResultOpaque.mjs index ac9581fbc..0f041ebff 100644 --- a/feature_tests/js/api/ResultOpaque.js +++ b/feature_tests/js/api/ResultOpaque.mjs @@ -1,7 +1,7 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { ErrorEnum_js_to_rust, ErrorEnum_rust_to_js } from "./ErrorEnum.js" -import { ErrorStruct } from "./ErrorStruct.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" +import { ErrorEnum_js_to_rust, ErrorEnum_rust_to_js } from "./ErrorEnum.mjs" +import { ErrorStruct } from "./ErrorStruct.mjs" const ResultOpaque_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.ResultOpaque_destroy(underlying); diff --git a/feature_tests/js/api/Two.js b/feature_tests/js/api/Two.mjs similarity index 87% rename from feature_tests/js/api/Two.js rename to feature_tests/js/api/Two.mjs index 259a8628f..ec52e3e73 100644 --- a/feature_tests/js/api/Two.js +++ b/feature_tests/js/api/Two.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" const Two_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Two_destroy(underlying); diff --git a/feature_tests/js/api/UnimportedEnum.js b/feature_tests/js/api/UnimportedEnum.mjs similarity index 82% rename from feature_tests/js/api/UnimportedEnum.js rename to feature_tests/js/api/UnimportedEnum.mjs index ef2588970..a3f818cce 100644 --- a/feature_tests/js/api/UnimportedEnum.js +++ b/feature_tests/js/api/UnimportedEnum.mjs @@ -1,5 +1,5 @@ import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" +import * as diplomatRuntime from "./diplomat-runtime.mjs" export const UnimportedEnum_js_to_rust = { "A": 0, diff --git a/feature_tests/js/api/diplomat-runtime.js b/feature_tests/js/api/diplomat-runtime.mjs similarity index 100% rename from feature_tests/js/api/diplomat-runtime.js rename to feature_tests/js/api/diplomat-runtime.mjs diff --git a/feature_tests/js/api/diplomat-wasm.mjs b/feature_tests/js/api/diplomat-wasm.mjs index 70ad14546..12a340b17 100644 --- a/feature_tests/js/api/diplomat-wasm.mjs +++ b/feature_tests/js/api/diplomat-wasm.mjs @@ -1,5 +1,5 @@ -import cfg from '../diplomat.config.js'; -import {readString8} from './diplomat-runtime.js' +import cfg from '../diplomat.config.mjs'; +import {readString8} from './diplomat-runtime.mjs' let wasm; diff --git a/feature_tests/js/api/index.d.ts b/feature_tests/js/api/index.d.ts index 6a0d05488..c3e795a46 100644 --- a/feature_tests/js/api/index.d.ts +++ b/feature_tests/js/api/index.d.ts @@ -1,26 +1,26 @@ -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { AttrEnum } from './AttrEnum.js'; -export { AttrOpaque1 } from './AttrOpaque1.js'; -export { AttrOpaque2 } from './AttrOpaque2.js'; -export { Bar } from './Bar.js'; -export { BorrowedFields } from './BorrowedFields.js'; -export { BorrowedFieldsReturning } from './BorrowedFieldsReturning.js'; -export { ContiguousEnum } from './ContiguousEnum.js'; -export { ErrorEnum } from './ErrorEnum.js'; -export { ErrorStruct } from './ErrorStruct.js'; -export { Float64Vec } from './Float64Vec.js'; -export { Foo } from './Foo.js'; -export { ImportedStruct } from './ImportedStruct.js'; -export { MyEnum } from './MyEnum.js'; -export { MyString } from './MyString.js'; -export { MyStruct } from './MyStruct.js'; -export { One } from './One.js'; -export { Opaque } from './Opaque.js'; -export { OptionOpaque } from './OptionOpaque.js'; -export { OptionOpaqueChar } from './OptionOpaqueChar.js'; -export { OptionStruct } from './OptionStruct.js'; -export { RefList } from './RefList.js'; -export { RefListParameter } from './RefListParameter.js'; -export { ResultOpaque } from './ResultOpaque.js'; -export { Two } from './Two.js'; -export { UnimportedEnum } from './UnimportedEnum.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { AttrEnum } from './AttrEnum.mjs'; +export { AttrOpaque1 } from './AttrOpaque1.mjs'; +export { AttrOpaque2 } from './AttrOpaque2.mjs'; +export { Bar } from './Bar.mjs'; +export { BorrowedFields } from './BorrowedFields.mjs'; +export { BorrowedFieldsReturning } from './BorrowedFieldsReturning.mjs'; +export { ContiguousEnum } from './ContiguousEnum.mjs'; +export { ErrorEnum } from './ErrorEnum.mjs'; +export { ErrorStruct } from './ErrorStruct.mjs'; +export { Float64Vec } from './Float64Vec.mjs'; +export { Foo } from './Foo.mjs'; +export { ImportedStruct } from './ImportedStruct.mjs'; +export { MyEnum } from './MyEnum.mjs'; +export { MyString } from './MyString.mjs'; +export { MyStruct } from './MyStruct.mjs'; +export { One } from './One.mjs'; +export { Opaque } from './Opaque.mjs'; +export { OptionOpaque } from './OptionOpaque.mjs'; +export { OptionOpaqueChar } from './OptionOpaqueChar.mjs'; +export { OptionStruct } from './OptionStruct.mjs'; +export { RefList } from './RefList.mjs'; +export { RefListParameter } from './RefListParameter.mjs'; +export { ResultOpaque } from './ResultOpaque.mjs'; +export { Two } from './Two.mjs'; +export { UnimportedEnum } from './UnimportedEnum.mjs'; diff --git a/feature_tests/js/api/index.js b/feature_tests/js/api/index.js deleted file mode 100644 index b9b372f85..000000000 --- a/feature_tests/js/api/index.js +++ /dev/null @@ -1,26 +0,0 @@ -export { FFIError } from './diplomat-runtime.js'; -export { AttrEnum } from './AttrEnum.js'; -export { AttrOpaque1 } from './AttrOpaque1.js'; -export { AttrOpaque2 } from './AttrOpaque2.js'; -export { Bar } from './Bar.js'; -export { BorrowedFields } from './BorrowedFields.js'; -export { BorrowedFieldsReturning } from './BorrowedFieldsReturning.js'; -export { ContiguousEnum } from './ContiguousEnum.js'; -export { ErrorEnum } from './ErrorEnum.js'; -export { ErrorStruct } from './ErrorStruct.js'; -export { Float64Vec } from './Float64Vec.js'; -export { Foo } from './Foo.js'; -export { ImportedStruct } from './ImportedStruct.js'; -export { MyEnum } from './MyEnum.js'; -export { MyString } from './MyString.js'; -export { MyStruct } from './MyStruct.js'; -export { One } from './One.js'; -export { Opaque } from './Opaque.js'; -export { OptionOpaque } from './OptionOpaque.js'; -export { OptionOpaqueChar } from './OptionOpaqueChar.js'; -export { OptionStruct } from './OptionStruct.js'; -export { RefList } from './RefList.js'; -export { RefListParameter } from './RefListParameter.js'; -export { ResultOpaque } from './ResultOpaque.js'; -export { Two } from './Two.js'; -export { UnimportedEnum } from './UnimportedEnum.js'; diff --git a/feature_tests/js/api/index.mjs b/feature_tests/js/api/index.mjs new file mode 100644 index 000000000..1ce7e1314 --- /dev/null +++ b/feature_tests/js/api/index.mjs @@ -0,0 +1,26 @@ +export { FFIError } from './diplomat-runtime.mjs'; +export { AttrEnum } from './AttrEnum.mjs'; +export { AttrOpaque1 } from './AttrOpaque1.mjs'; +export { AttrOpaque2 } from './AttrOpaque2.mjs'; +export { Bar } from './Bar.mjs'; +export { BorrowedFields } from './BorrowedFields.mjs'; +export { BorrowedFieldsReturning } from './BorrowedFieldsReturning.mjs'; +export { ContiguousEnum } from './ContiguousEnum.mjs'; +export { ErrorEnum } from './ErrorEnum.mjs'; +export { ErrorStruct } from './ErrorStruct.mjs'; +export { Float64Vec } from './Float64Vec.mjs'; +export { Foo } from './Foo.mjs'; +export { ImportedStruct } from './ImportedStruct.mjs'; +export { MyEnum } from './MyEnum.mjs'; +export { MyString } from './MyString.mjs'; +export { MyStruct } from './MyStruct.mjs'; +export { One } from './One.mjs'; +export { Opaque } from './Opaque.mjs'; +export { OptionOpaque } from './OptionOpaque.mjs'; +export { OptionOpaqueChar } from './OptionOpaqueChar.mjs'; +export { OptionStruct } from './OptionStruct.mjs'; +export { RefList } from './RefList.mjs'; +export { RefListParameter } from './RefListParameter.mjs'; +export { ResultOpaque } from './ResultOpaque.mjs'; +export { Two } from './Two.mjs'; +export { UnimportedEnum } from './UnimportedEnum.mjs'; diff --git a/tool/src/js/mod.rs b/tool/src/js/mod.rs index 5cf821caf..edab94ffa 100644 --- a/tool/src/js/mod.rs +++ b/tool/src/js/mod.rs @@ -26,7 +26,7 @@ pub fn gen_bindings( outs: &mut HashMap, docs_url_gen: Option<&ast::DocsUrlGenerator>, ) -> fmt::Result { - outs.entry("diplomat-runtime.js".to_string()) + outs.entry("diplomat-runtime.mjs".to_string()) .or_default() .write_str(include_str!("runtime.mjs"))?; outs.entry("diplomat-runtime.d.ts".to_string()) @@ -42,19 +42,19 @@ pub fn gen_bindings( let header_exports: String = { let mut buf = String::new(); for (_, custom_type) in &all_types { - writeln!(buf, "export {{ {0} }} from './{0}.js';", custom_type.name())?; + writeln!(buf, "export {{ {0} }} from './{0}.mjs';", custom_type.name())?; } buf }; let index_ts = outs.entry("index.d.ts".to_string()).or_default(); - writeln!(index_ts, "export {{ FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char }} from './diplomat-runtime.js';")?; + writeln!(index_ts, "export {{ FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char }} from './diplomat-runtime.mjs';")?; index_ts.write_str(&header_exports)?; - let index_js = outs.entry("index.js".to_string()).or_default(); + let index_js = outs.entry("index.mjs".to_string()).or_default(); writeln!( index_js, - "export {{ FFIError }} from './diplomat-runtime.js';" + "export {{ FFIError }} from './diplomat-runtime.mjs';" )?; index_js.write_str(&header_exports)?; @@ -62,25 +62,25 @@ pub fn gen_bindings( let imports = Imports::new(custom_type, in_path, env); let out = outs - .entry(format!("{}.js", custom_type.name())) + .entry(format!("{}.mjs", custom_type.name())) .or_default(); writeln!(out, "import wasm from \"./diplomat-wasm.mjs\"")?; writeln!( out, - "import * as diplomatRuntime from \"./diplomat-runtime.js\"" + "import * as diplomatRuntime from \"./diplomat-runtime.mjs\"" )?; for custom_type in imports.js_imports.iter() { if let ast::CustomType::Enum(enm) = custom_type { writeln!( out, - "import {{ {0}_js_to_rust, {0}_rust_to_js }} from \"./{0}.js\"", + "import {{ {0}_js_to_rust, {0}_rust_to_js }} from \"./{0}.mjs\"", enm.name )?; } else { writeln!( out, - "import {{ {0} }} from \"./{0}.js\"", + "import {{ {0} }} from \"./{0}.mjs\"", custom_type.name() )?; } @@ -133,7 +133,7 @@ pub fn gen_bindings( Ok(()) } -/// A struct for detecting all the the imports required for .js and d.ts files. +/// A struct for detecting all the the imports required for .mjs and d.ts files. #[derive(Default)] struct Imports<'env> { /// Type that show up in a type's fields, or as a parameter or return value. diff --git a/tool/src/js/test_util.rs b/tool/src/js/test_util.rs index 5fb2a391b..597e1c81f 100644 --- a/tool/src/js/test_util.rs +++ b/tool/src/js/test_util.rs @@ -11,7 +11,7 @@ macro_rules! test_file { let mut out_docs = std::collections::HashMap::new(); crate::js::docs::gen_docs(&env, &mut out_docs, &Default::default()).unwrap(); - out_texts.remove("diplomat-runtime.js"); + out_texts.remove("diplomat-runtime.mjs"); out_texts.remove("diplomat-runtime.d.ts"); out_texts.remove("diplomat-wasm.mjs"); diff --git a/tool/src/js/wasm.mjs b/tool/src/js/wasm.mjs index 70ad14546..12a340b17 100644 --- a/tool/src/js/wasm.mjs +++ b/tool/src/js/wasm.mjs @@ -1,5 +1,5 @@ -import cfg from '../diplomat.config.js'; -import {readString8} from './diplomat-runtime.js' +import cfg from '../diplomat.config.mjs'; +import {readString8} from './diplomat-runtime.mjs' let wasm; From bd9891e79f6741cd59453db82629ee42a120b3d1 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:10:26 +0100 Subject: [PATCH 2/5] fix --- tool/src/js/mod.rs | 6 +++++- ...ests__borrowing_opaque_owned_by_struct@index.mjs.snap | 8 ++++++++ ..._js__conversions__tests__str_borrowing@index.mjs.snap | 7 +++++++ ...__conversions__tests__struct_borrowing@index.mjs.snap | 9 +++++++++ ...conversions__tests__unambiguous_names@index.d.ts.snap | 6 +++--- ...ructs__tests__method_returning_struct@index.d.ts.snap | 6 +++--- ...js__structs__tests__method_taking_str@index.d.ts.snap | 4 ++-- ..._structs__tests__method_writeable_out@index.d.ts.snap | 4 ++-- ...ructs__tests__simple_non_opaque_struct@index.mjs.snap | 7 +++++++ ..._structs__tests__simple_opaque_struct@index.d.ts.snap | 4 ++-- ...s__types__tests__option_types@MyOpaqueStruct.mjs.snap | 4 ++-- ...tool__js__types__tests__pointer_types@index.d.ts.snap | 6 +++--- ...s__types__tests__result_types@MyOpaqueStruct.mjs.snap | 4 ++-- ...l__js__types__tests__string_reference@index.d.ts.snap | 4 ++-- ...t_tool__js__types__tests__unit_type@MyStruct.mjs.snap | 4 ++-- ...ol__js__types__tests__writeable_out@MyStruct.mjs.snap | 4 ++-- 16 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.mjs.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.mjs.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.mjs.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.mjs.snap diff --git a/tool/src/js/mod.rs b/tool/src/js/mod.rs index edab94ffa..1024a923a 100644 --- a/tool/src/js/mod.rs +++ b/tool/src/js/mod.rs @@ -42,7 +42,11 @@ pub fn gen_bindings( let header_exports: String = { let mut buf = String::new(); for (_, custom_type) in &all_types { - writeln!(buf, "export {{ {0} }} from './{0}.mjs';", custom_type.name())?; + writeln!( + buf, + "export {{ {0} }} from './{0}.mjs';", + custom_type.name() + )?; } buf }; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.mjs.snap new file mode 100644 index 000000000..e84bfb42c --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/conversions.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { BorrowingOpaque } from './BorrowingOpaque.mjs'; +export { BorrowingStruct } from './BorrowingStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.mjs.snap new file mode 100644 index 000000000..8b4b3edec --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/conversions.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.mjs.snap new file mode 100644 index 000000000..cce1891e4 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.mjs.snap @@ -0,0 +1,9 @@ +--- +source: tool/src/js/conversions.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { Point } from './Point.mjs'; +export { PointTranspose } from './PointTranspose.mjs'; +export { Scalar } from './Scalar.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.d.ts.snap index a229e086b..f2755d6a2 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { Line } from './Line.js'; -export { Point } from './Point.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { Line } from './Line.mjs'; +export { Point } from './Point.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.d.ts.snap index 2b32470b3..e2dc688d2 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; -export { NonOpaqueStruct } from './NonOpaqueStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; +export { NonOpaqueStruct } from './NonOpaqueStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.d.ts.snap index 0413b8eae..8f34f24b7 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.d.ts.snap index 0413b8eae..8f34f24b7 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.mjs.snap new file mode 100644 index 000000000..5ce2b42f2 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/structs.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.d.ts.snap index 0413b8eae..8f34f24b7 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.mjs.snap index 37152f2a4..ed6c5e78d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyOpaqueStruct_destroy(underlying); }); -export default class MyOpaqueStruct { +export class MyOpaqueStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.d.ts.snap index 12233e7e8..482744d94 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.mjs.snap index 37152f2a4..ed6c5e78d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyOpaqueStruct_destroy(underlying); }); -export default class MyOpaqueStruct { +export class MyOpaqueStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.d.ts.snap index 3cc253c93..b9080f37d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.mjs.snap index 529db0aa5..0c18f24a3 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.mjs.snap index c49f552a7..cddec77b9 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; From 2668fb525ecd4927dd1530a7bfbd4448f13c735a Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:13:05 +0100 Subject: [PATCH 3/5] insta --- ...ue_owned_by_struct@BorrowingOpaque.js.snap | 22 ----- ...e_owned_by_struct@BorrowingOpaque.mjs.snap | 4 +- ...ue_owned_by_struct@BorrowingStruct.js.snap | 25 ------ ...e_owned_by_struct@BorrowingStruct.mjs.snap | 6 +- ...rowing_opaque_owned_by_struct@api.mjs.snap | 42 --------- ...ing_opaque_owned_by_struct@index.d.ts.snap | 6 +- ...owing_opaque_owned_by_struct@index.js.snap | 8 -- ...ons__tests__str_borrowing@MyStruct.js.snap | 43 --------- ...ns__tests__str_borrowing@MyStruct.mjs.snap | 20 +++-- ...ersions__tests__str_borrowing@api.mjs.snap | 42 --------- ...ions__tests__str_borrowing@index.d.ts.snap | 4 +- ...rsions__tests__str_borrowing@index.js.snap | 7 -- ...ons__tests__struct_borrowing@Point.js.snap | 21 ----- ...ns__tests__struct_borrowing@Point.mjs.snap | 6 +- ...s__struct_borrowing@PointTranspose.js.snap | 57 ------------ ...__struct_borrowing@PointTranspose.mjs.snap | 7 +- ...ns__tests__struct_borrowing@Scalar.js.snap | 22 ----- ...s__tests__struct_borrowing@Scalar.mjs.snap | 4 +- ...ions__tests__struct_borrowing@api.mjs.snap | 87 ------------------- ...s__tests__struct_borrowing@index.d.ts.snap | 8 +- ...ons__tests__struct_borrowing@index.js.snap | 9 -- ...ons__tests__unambiguous_names@Line.js.snap | 25 ------ ...ns__tests__unambiguous_names@Line.mjs.snap | 6 +- ...ns__tests__unambiguous_names@Point.js.snap | 14 --- ...s__tests__unambiguous_names@Point.mjs.snap | 4 +- ...ons__tests__unambiguous_names@api.mjs.snap | 34 -------- ...ns__tests__unambiguous_names@index.js.snap | 8 -- ...s__tests__unambiguous_names@index.mjs.snap | 8 ++ ...__method_returning_struct@MyStruct.js.snap | 33 ------- ..._method_returning_struct@MyStruct.mjs.snap | 6 +- ...d_returning_struct@NonOpaqueStruct.js.snap | 15 ---- ..._returning_struct@NonOpaqueStruct.mjs.snap | 4 +- ...ests__method_returning_struct@api.mjs.snap | 43 --------- ...sts__method_returning_struct@index.js.snap | 8 -- ...ts__method_returning_struct@index.mjs.snap | 8 ++ ..._tests__method_taking_str@MyStruct.js.snap | 35 -------- ...tests__method_taking_str@MyStruct.mjs.snap | 8 +- ...cts__tests__method_taking_str@api.mjs.snap | 38 -------- ...ts__tests__method_taking_str@index.js.snap | 7 -- ...s__tests__method_taking_str@index.mjs.snap | 7 ++ ...sts__method_writeable_out@MyStruct.js.snap | 53 ----------- ...ts__method_writeable_out@MyStruct.mjs.snap | 4 +- ...__tests__method_writeable_out@api.mjs.snap | 56 ------------ ..._tests__method_writeable_out@index.js.snap | 7 -- ...tests__method_writeable_out@index.mjs.snap | 7 ++ ..._simple_non_opaque_struct@MyStruct.js.snap | 32 ------- ...simple_non_opaque_struct@MyStruct.mjs.snap | 4 +- ...sts__simple_non_opaque_struct@api.mjs.snap | 35 -------- ...__simple_non_opaque_struct@index.d.ts.snap | 4 +- ...ts__simple_non_opaque_struct@index.js.snap | 7 -- ...sts__simple_opaque_struct@MyStruct.js.snap | 34 -------- ...ts__simple_opaque_struct@MyStruct.mjs.snap | 4 +- ...__tests__simple_opaque_struct@api.mjs.snap | 37 -------- ..._tests__simple_opaque_struct@index.js.snap | 7 -- ...tests__simple_opaque_struct@index.mjs.snap | 7 ++ ...tests__option_types@MyOpaqueStruct.js.snap | 22 ----- ...ypes__tests__option_types@MyStruct.js.snap | 17 ---- ...pes__tests__option_types@MyStruct.mjs.snap | 6 +- ...s__types__tests__option_types@api.mjs.snap | 34 -------- ...types__tests__option_types@index.d.ts.snap | 6 +- ...__types__tests__option_types@index.js.snap | 8 -- ..._types__tests__option_types@index.mjs.snap | 8 ++ ...ests__pointer_types@MyOpaqueStruct.js.snap | 22 ----- ...sts__pointer_types@MyOpaqueStruct.mjs.snap | 4 +- ...pes__tests__pointer_types@MyStruct.js.snap | 25 ------ ...es__tests__pointer_types@MyStruct.mjs.snap | 6 +- ...__types__tests__pointer_types@api.mjs.snap | 42 --------- ..._types__tests__pointer_types@index.js.snap | 8 -- ...types__tests__pointer_types@index.mjs.snap | 8 ++ ...tests__result_types@MyOpaqueStruct.js.snap | 22 ----- ...ypes__tests__result_types@MyStruct.js.snap | 31 ------- ...pes__tests__result_types@MyStruct.mjs.snap | 4 +- ...s__types__tests__result_types@api.mjs.snap | 49 ----------- ...types__tests__result_types@index.d.ts.snap | 6 +- ...__types__tests__result_types@index.js.snap | 8 -- ..._types__tests__result_types@index.mjs.snap | 8 ++ ...__tests__string_reference@MyStruct.js.snap | 27 ------ ..._tests__string_reference@MyStruct.mjs.snap | 6 +- ...ypes__tests__string_reference@api.mjs.snap | 30 ------- ...pes__tests__string_reference@index.js.snap | 7 -- ...es__tests__string_reference@index.mjs.snap | 7 ++ ...__types__tests__unit_type@MyStruct.js.snap | 20 ----- ...__js__types__tests__unit_type@api.mjs.snap | 23 ----- ...s__types__tests__unit_type@index.d.ts.snap | 4 +- ..._js__types__tests__unit_type@index.js.snap | 7 -- ...js__types__tests__unit_type@index.mjs.snap | 7 ++ ...pes__tests__writeable_out@MyStruct.js.snap | 22 ----- ...__types__tests__writeable_out@api.mjs.snap | 25 ------ ...ypes__tests__writeable_out@index.d.ts.snap | 4 +- ..._types__tests__writeable_out@index.js.snap | 7 -- ...types__tests__writeable_out@index.mjs.snap | 7 ++ 91 files changed, 161 insertions(+), 1445 deletions(-) delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.js.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@api.mjs.snap delete mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.js.snap create mode 100644 tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.mjs.snap diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.js.snap deleted file mode 100644 index 61459d6de..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const BorrowingOpaque_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.BorrowingOpaque_destroy(underlying); -}); - -export class BorrowingOpaque { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - BorrowingOpaque_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.mjs.snap index 6122dcfe3..5e17dcaf9 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingOpaque.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const BorrowingOpaque_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.BorrowingOpaque_destroy(underlying); }); -export default class BorrowingOpaque { +export class BorrowingOpaque { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.js.snap deleted file mode 100644 index 1b1b0ba8d..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.js.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { BorrowingOpaque } from "./BorrowingOpaque.js" - -export class BorrowingStruct { - constructor(underlying, edges_a) { - this.opaque = new BorrowingOpaque(diplomatRuntime.ptrRead(wasm, underlying), true, [...edges_a]); - this.x = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } - - static new(arg_opaque) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); - wasm.BorrowingStruct_new(diplomat_receive_buffer, arg_opaque.underlying); - const out = new BorrowingStruct(diplomat_receive_buffer, [arg_opaque]); - wasm.diplomat_free(diplomat_receive_buffer, 5, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.mjs.snap index a7670e631..98bc1b360 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@BorrowingStruct.mjs.snap @@ -2,11 +2,11 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import BorrowingOpaque from "./BorrowingOpaque.mjs" +import { BorrowingOpaque } from "./BorrowingOpaque.mjs" -export default class BorrowingStruct { +export class BorrowingStruct { constructor(underlying, edges_a) { this.opaque = new BorrowingOpaque(diplomatRuntime.ptrRead(wasm, underlying), true, [...edges_a]); this.x = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@api.mjs.snap deleted file mode 100644 index 0aff6d1b0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@api.mjs.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const BorrowingOpaque_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.BorrowingOpaque_destroy(underlying); -}); - -export class BorrowingOpaque { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - BorrowingOpaque_box_destroy_registry.register(this, underlying); - } - } -} - -export class BorrowingStruct { - constructor(underlying, edges_a) { - this.opaque = new BorrowingOpaque(diplomatRuntime.ptrRead(wasm, underlying), true, [...edges_a]); - this.x = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } - - static new(arg_opaque) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); - wasm.BorrowingStruct_new(diplomat_receive_buffer, arg_opaque.underlying); - const out = new BorrowingStruct(diplomat_receive_buffer, [arg_opaque]); - wasm.diplomat_free(diplomat_receive_buffer, 5, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.d.ts.snap index 6c0080053..895109d0b 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { BorrowingOpaque } from './BorrowingOpaque.js'; -export { BorrowingStruct } from './BorrowingStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { BorrowingOpaque } from './BorrowingOpaque.mjs'; +export { BorrowingStruct } from './BorrowingStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.js.snap deleted file mode 100644 index 0f81e8011..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__borrowing_opaque_owned_by_struct@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { BorrowingOpaque } from './BorrowingOpaque.js'; -export { BorrowingStruct } from './BorrowingStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.js.snap deleted file mode 100644 index a364e7bd0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.js.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying, edges_a) { - this.s = (() => { - const [ptr, size] = new Uint32Array(wasm.memory.buffer, underlying, 2); - return diplomatRuntime.readString8(wasm, ptr, size); - })(); - } - - static new(arg_s) { - const buf_arg_s = diplomatRuntime.DiplomatBuf.str8(wasm, arg_s); - const diplomat_out = (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size); - const out = new MyStruct(diplomat_receive_buffer, [buf_arg_s]); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - buf_arg_s.garbageCollect(); - return diplomat_out; - } - - get() { - const field_s_this = this["s"]; - const buf_field_s_this = diplomatRuntime.DiplomatBuf.str8(wasm, field_s_this); - const diplomat_out = (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_get(diplomat_receive_buffer, buf_field_s_this.ptr, buf_field_s_this.size); - const [ptr, size] = new Uint32Array(wasm.memory.buffer, diplomat_receive_buffer, 2); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return diplomatRuntime.readString8(wasm, ptr, size); - })(); - buf_field_s_this.garbageCollect(); - return diplomat_out; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.mjs.snap index faf6a470a..96219fcc4 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@MyStruct.mjs.snap @@ -2,38 +2,42 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying, edges_a) { this.s = (() => { const [ptr, size] = new Uint32Array(wasm.memory.buffer, underlying, 2); - return diplomatRuntime.readString(wasm, ptr, size); + return diplomatRuntime.readString8(wasm, ptr, size); })(); } static new(arg_s) { - const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); - return (() => { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str8(wasm, arg_s); + const diplomat_out = (() => { const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size); const out = new MyStruct(diplomat_receive_buffer, [buf_arg_s]); wasm.diplomat_free(diplomat_receive_buffer, 8, 4); return out; })(); + buf_arg_s.garbageCollect(); + return diplomat_out; } get() { const field_s_this = this["s"]; - const buf_field_s_this = diplomatRuntime.DiplomatBuf.str(wasm, field_s_this); - return (() => { + const buf_field_s_this = diplomatRuntime.DiplomatBuf.str8(wasm, field_s_this); + const diplomat_out = (() => { const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); wasm.MyStruct_get(diplomat_receive_buffer, buf_field_s_this.ptr, buf_field_s_this.size); const [ptr, size] = new Uint32Array(wasm.memory.buffer, diplomat_receive_buffer, 2); wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return diplomatRuntime.readString(wasm, ptr, size); + return diplomatRuntime.readString8(wasm, ptr, size); })(); + buf_field_s_this.garbageCollect(); + return diplomat_out; } } diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@api.mjs.snap deleted file mode 100644 index db83213ed..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@api.mjs.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class MyStruct { - constructor(underlying, edges_a) { - this.s = (() => { - const [ptr, size] = new Uint32Array(wasm.memory.buffer, underlying, 2); - return diplomatRuntime.readString(wasm, ptr, size); - })(); - } - - static new(arg_s) { - const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size); - const out = new MyStruct(diplomat_receive_buffer, [buf_arg_s]); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - } - - get() { - const field_s_this = this["s"]; - const buf_field_s_this = diplomatRuntime.DiplomatBuf.str(wasm, field_s_this); - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_get(diplomat_receive_buffer, buf_field_s_this.ptr, buf_field_s_this.size); - const [ptr, size] = new Uint32Array(wasm.memory.buffer, diplomat_receive_buffer, 2); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return diplomatRuntime.readString(wasm, ptr, size); - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.d.ts.snap index 1b5ee8b56..3961afbab 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.js.snap deleted file mode 100644 index 98e942ca6..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__str_borrowing@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.js.snap deleted file mode 100644 index 293912246..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.js.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { Scalar } from "./Scalar.js" - -export class Point { - constructor(underlying, edges_x, edges_y) { - this.x = new Scalar(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_x]); - this.y = new Scalar(diplomatRuntime.ptrRead(wasm, underlying + 4), false, [...edges_y]); - } - - get_x() { - const field_x_this = this["x"]; - const field_y_this = this["y"]; - return new Scalar(wasm.Point_get_x(field_x_this.underlying, field_y_this.underlying), false, [field_x_this]); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.mjs.snap index 0bfc3edd3..c118d3eda 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Point.mjs.snap @@ -2,11 +2,11 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import Scalar from "./Scalar.mjs" +import { Scalar } from "./Scalar.mjs" -export default class Point { +export class Point { constructor(underlying, edges_x, edges_y) { this.x = new Scalar(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_x]); this.y = new Scalar(diplomatRuntime.ptrRead(wasm, underlying + 4), false, [...edges_y]); diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.js.snap deleted file mode 100644 index 7d13b2ac8..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.js.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { Point } from "./Point.js" - -export class PointTranspose { - constructor(underlying, edges_u, edges_v) { - this.point = new Point(underlying, edges_u, edges_v); - this.transpose = new Point(underlying + 8, edges_v, edges_u); - } - - static new(arg_u, arg_v) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(16, 4); - wasm.PointTranspose_new(diplomat_receive_buffer, arg_u.underlying, arg_v.underlying); - const out = new PointTranspose(diplomat_receive_buffer, [arg_u], [arg_v]); - wasm.diplomat_free(diplomat_receive_buffer, 16, 4); - return out; - })(); - } - - transpose() { - const field_point_this = this["point"]; - const field_x_field_point_this = field_point_this["x"]; - const field_y_field_point_this = field_point_this["y"]; - const field_transpose_this = this["transpose"]; - const field_x_field_transpose_this = field_transpose_this["x"]; - const field_y_field_transpose_this = field_transpose_this["y"]; - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(16, 4); - wasm.PointTranspose_transpose(diplomat_receive_buffer, field_x_field_point_this.underlying, field_y_field_point_this.underlying, field_x_field_transpose_this.underlying, field_y_field_transpose_this.underlying); - const out = new PointTranspose(diplomat_receive_buffer, [field_y_field_point_this, field_x_field_transpose_this], [field_x_field_point_this, field_y_field_transpose_this]); - wasm.diplomat_free(diplomat_receive_buffer, 16, 4); - return out; - })(); - } - - point() { - const field_point_this = this["point"]; - const field_x_field_point_this = field_point_this["x"]; - const field_y_field_point_this = field_point_this["y"]; - const field_transpose_this = this["transpose"]; - const field_x_field_transpose_this = field_transpose_this["x"]; - const field_y_field_transpose_this = field_transpose_this["y"]; - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.PointTranspose_point(diplomat_receive_buffer, field_x_field_point_this.underlying, field_y_field_point_this.underlying, field_x_field_transpose_this.underlying, field_y_field_transpose_this.underlying); - const out = new Point(diplomat_receive_buffer, [field_x_field_point_this, field_y_field_transpose_this], [field_y_field_point_this, field_x_field_transpose_this]); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.mjs.snap index 95d494730..18acda8a4 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@PointTranspose.mjs.snap @@ -2,12 +2,11 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import Point from "./Point.mjs" -import Scalar from "./Scalar.mjs" +import { Point } from "./Point.mjs" -export default class PointTranspose { +export class PointTranspose { constructor(underlying, edges_u, edges_v) { this.point = new Point(underlying, edges_u, edges_v); this.transpose = new Point(underlying + 8, edges_v, edges_u); diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.js.snap deleted file mode 100644 index 9dad00b23..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const Scalar_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.Scalar_destroy(underlying); -}); - -export class Scalar { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - Scalar_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.mjs.snap index b7ea9f13a..b645850b9 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@Scalar.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const Scalar_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.Scalar_destroy(underlying); }); -export default class Scalar { +export class Scalar { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@api.mjs.snap deleted file mode 100644 index 2302c7c4a..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@api.mjs.snap +++ /dev/null @@ -1,87 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class Point { - constructor(underlying, edges_x, edges_y) { - this.x = new Scalar(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_x]); - this.y = new Scalar(diplomatRuntime.ptrRead(wasm, underlying + 4), false, [...edges_y]); - } - - get_x() { - const field_x_this = this["x"]; - const field_y_this = this["y"]; - return new Scalar(wasm.Point_get_x(field_x_this.underlying, field_y_this.underlying), false, [field_x_this]); - } -} - -export class PointTranspose { - constructor(underlying, edges_u, edges_v) { - this.point = new Point(underlying, edges_u, edges_v); - this.transpose = new Point(underlying + 8, edges_v, edges_u); - } - - static new(arg_u, arg_v) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(16, 4); - wasm.PointTranspose_new(diplomat_receive_buffer, arg_u.underlying, arg_v.underlying); - const out = new PointTranspose(diplomat_receive_buffer, [arg_u], [arg_v]); - wasm.diplomat_free(diplomat_receive_buffer, 16, 4); - return out; - })(); - } - - transpose() { - const field_point_this = this["point"]; - const field_x_field_point_this = field_point_this["x"]; - const field_y_field_point_this = field_point_this["y"]; - const field_transpose_this = this["transpose"]; - const field_x_field_transpose_this = field_transpose_this["x"]; - const field_y_field_transpose_this = field_transpose_this["y"]; - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(16, 4); - wasm.PointTranspose_transpose(diplomat_receive_buffer, field_x_field_point_this.underlying, field_y_field_point_this.underlying, field_x_field_transpose_this.underlying, field_y_field_transpose_this.underlying); - const out = new PointTranspose(diplomat_receive_buffer, [field_y_field_point_this, field_x_field_transpose_this], [field_x_field_point_this, field_y_field_transpose_this]); - wasm.diplomat_free(diplomat_receive_buffer, 16, 4); - return out; - })(); - } - - point() { - const field_point_this = this["point"]; - const field_x_field_point_this = field_point_this["x"]; - const field_y_field_point_this = field_point_this["y"]; - const field_transpose_this = this["transpose"]; - const field_x_field_transpose_this = field_transpose_this["x"]; - const field_y_field_transpose_this = field_transpose_this["y"]; - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.PointTranspose_point(diplomat_receive_buffer, field_x_field_point_this.underlying, field_y_field_point_this.underlying, field_x_field_transpose_this.underlying, field_y_field_transpose_this.underlying); - const out = new Point(diplomat_receive_buffer, [field_x_field_point_this, field_y_field_transpose_this], [field_y_field_point_this, field_x_field_transpose_this]); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - } -} - -const Scalar_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.Scalar_destroy(underlying); -}); - -export class Scalar { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - Scalar_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.d.ts.snap index d66ccf390..e8e66eb70 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.d.ts.snap @@ -2,8 +2,8 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { Point } from './Point.js'; -export { PointTranspose } from './PointTranspose.js'; -export { Scalar } from './Scalar.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { Point } from './Point.mjs'; +export { PointTranspose } from './PointTranspose.mjs'; +export { Scalar } from './Scalar.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.js.snap deleted file mode 100644 index 610d5090d..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__struct_borrowing@index.js.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { Point } from './Point.js'; -export { PointTranspose } from './PointTranspose.js'; -export { Scalar } from './Scalar.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.js.snap deleted file mode 100644 index c04663a4e..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.js.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { Point } from "./Point.js" - -export class Line { - constructor(underlying) { - this.start = new Point(underlying); - this.end = new Point(underlying + 8); - } - - do_stuff() { - const field_start_this = this["start"]; - const field_x_field_start_this = field_start_this["x"]; - const field_y_field_start_this = field_start_this["y"]; - const field_end_this = this["end"]; - const field_x_field_end_this = field_end_this["x"]; - const field_y_field_end_this = field_end_this["y"]; - wasm.Line_do_stuff(field_x_field_start_this, field_y_field_start_this, field_x_field_end_this, field_y_field_end_this); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.mjs.snap index 738dd6c23..ee75f5597 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Line.mjs.snap @@ -2,11 +2,11 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import Point from "./Point.mjs" +import { Point } from "./Point.mjs" -export default class Line { +export class Line { constructor(underlying) { this.start = new Point(underlying); this.end = new Point(underlying + 8); diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.js.snap deleted file mode 100644 index 4c6da0fd7..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.js.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class Point { - constructor(underlying) { - this.x = (new Int32Array(wasm.memory.buffer, underlying, 1))[0]; - this.y = (new Int32Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.mjs.snap index 22f741832..c517b9cfe 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@Point.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/conversions.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class Point { +export class Point { constructor(underlying) { this.x = (new Int32Array(wasm.memory.buffer, underlying, 1))[0]; this.y = (new Int32Array(wasm.memory.buffer, underlying + 4, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@api.mjs.snap deleted file mode 100644 index d07eee2c0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@api.mjs.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class Line { - constructor(underlying) { - this.start = new Point(underlying); - this.end = new Point(underlying + 8); - } - - do_stuff() { - const field_start_this = this["start"]; - const field_x_field_start_this = field_start_this["x"]; - const field_y_field_start_this = field_start_this["y"]; - const field_end_this = this["end"]; - const field_x_field_end_this = field_end_this["x"]; - const field_y_field_end_this = field_end_this["y"]; - wasm.Line_do_stuff(field_x_field_start_this, field_y_field_start_this, field_x_field_end_this, field_y_field_end_this); - } -} - -export class Point { - constructor(underlying) { - this.x = (new Int32Array(wasm.memory.buffer, underlying, 1))[0]; - this.y = (new Int32Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.js.snap deleted file mode 100644 index 59ed72c19..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/conversions.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { Line } from './Line.js'; -export { Point } from './Point.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.mjs.snap new file mode 100644 index 000000000..27d683e94 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__conversions__tests__unambiguous_names@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/conversions.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { Line } from './Line.mjs'; +export { Point } from './Point.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.js.snap deleted file mode 100644 index 56c0b47e8..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { NonOpaqueStruct } from "./NonOpaqueStruct.js" - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - get_non_opaque() { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_get_non_opaque(diplomat_receive_buffer, this.underlying); - const out = new NonOpaqueStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.mjs.snap index 0717aab51..ceceb27cb 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@MyStruct.mjs.snap @@ -2,15 +2,15 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import NonOpaqueStruct from "./NonOpaqueStruct.mjs" +import { NonOpaqueStruct } from "./NonOpaqueStruct.mjs" const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyStruct_destroy(underlying); }); -export default class MyStruct { +export class MyStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.js.snap deleted file mode 100644 index 29d0b62d0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.js.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class NonOpaqueStruct { - constructor(underlying) { - this.a = (new Uint16Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 2, 1))[0]; - this.c = (new Uint32Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.mjs.snap index 5274eade2..641c65eee 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@NonOpaqueStruct.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class NonOpaqueStruct { +export class NonOpaqueStruct { constructor(underlying) { this.a = (new Uint16Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 2, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@api.mjs.snap deleted file mode 100644 index 666e6cd95..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@api.mjs.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - get_non_opaque() { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); - wasm.MyStruct_get_non_opaque(diplomat_receive_buffer, this.underlying); - const out = new NonOpaqueStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 8, 4); - return out; - })(); - } -} - -export class NonOpaqueStruct { - constructor(underlying) { - this.a = (new Uint16Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 2, 1))[0]; - this.c = (new Uint32Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.js.snap deleted file mode 100644 index 6348cf3b2..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; -export { NonOpaqueStruct } from './NonOpaqueStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.mjs.snap new file mode 100644 index 000000000..fb035357a --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_returning_struct@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/structs.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; +export { NonOpaqueStruct } from './NonOpaqueStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.js.snap deleted file mode 100644 index 02efb93df..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.js.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - static new_str(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str8(wasm, arg_v); - const diplomat_out = new MyStruct(wasm.MyStruct_new_str(buf_arg_v.ptr, buf_arg_v.size), true, []); - buf_arg_v.free(); - return diplomat_out; - } - - set_str(arg_new_str) { - const buf_arg_new_str = diplomatRuntime.DiplomatBuf.str8(wasm, arg_new_str); - wasm.MyStruct_set_str(this.underlying, buf_arg_new_str.ptr, buf_arg_new_str.size); - buf_arg_new_str.free(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.mjs.snap index 0e7fd23de..8ce8453d2 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@MyStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyStruct_destroy(underlying); }); -export default class MyStruct { +export class MyStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; @@ -20,14 +20,14 @@ export default class MyStruct { } static new_str(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str(wasm, arg_v); + const buf_arg_v = diplomatRuntime.DiplomatBuf.str8(wasm, arg_v); const diplomat_out = new MyStruct(wasm.MyStruct_new_str(buf_arg_v.ptr, buf_arg_v.size), true, []); buf_arg_v.free(); return diplomat_out; } set_str(arg_new_str) { - const buf_arg_new_str = diplomatRuntime.DiplomatBuf.str(wasm, arg_new_str); + const buf_arg_new_str = diplomatRuntime.DiplomatBuf.str8(wasm, arg_new_str); wasm.MyStruct_set_str(this.underlying, buf_arg_new_str.ptr, buf_arg_new_str.size); buf_arg_new_str.free(); } diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@api.mjs.snap deleted file mode 100644 index 369a72773..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@api.mjs.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - static new_str(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str(wasm, arg_v); - const diplomat_out = new MyStruct(wasm.MyStruct_new_str(buf_arg_v.ptr, buf_arg_v.size), true, []); - buf_arg_v.free(); - return diplomat_out; - } - - set_str(arg_new_str) { - const buf_arg_new_str = diplomatRuntime.DiplomatBuf.str(wasm, arg_new_str); - wasm.MyStruct_set_str(this.underlying, buf_arg_new_str.ptr, buf_arg_new_str.size); - buf_arg_new_str.free(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.js.snap deleted file mode 100644 index 5d48ef622..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.mjs.snap new file mode 100644 index 000000000..5ce2b42f2 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_taking_str@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/structs.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.js.snap deleted file mode 100644 index 67b371f3f..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.js.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - write() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write(this.underlying, writeable); - }); - } - - write_unit() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write_unit(this.underlying, writeable); - }); - } - - write_result() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_write_result(diplomat_receive_buffer, this.underlying, writeable); - const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 1); - if (is_ok) { - const ok_value = {}; - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return ok_value; - } else { - const throw_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - throw new diplomatRuntime.FFIError(throw_value); - } - })(); - }); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.mjs.snap index 6a19c4005..c5e8345fb 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@MyStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyStruct_destroy(underlying); }); -export default class MyStruct { +export class MyStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@api.mjs.snap deleted file mode 100644 index b0e9e2b3b..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@api.mjs.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - write() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write(this.underlying, writeable); - }); - } - - write_unit() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write_unit(this.underlying, writeable); - }); - } - - write_result() { - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_write_result(diplomat_receive_buffer, this.underlying, writeable); - const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 1); - if (is_ok) { - const ok_value = {}; - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return ok_value; - } else { - const throw_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - throw new diplomatRuntime.FFIError(throw_value); - } - })(); - }); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.js.snap deleted file mode 100644 index 5d48ef622..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.mjs.snap new file mode 100644 index 000000000..5ce2b42f2 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__method_writeable_out@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/structs.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.js.snap deleted file mode 100644 index 2e0b7ec25..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.js.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new(arg_a, arg_b) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_new(diplomat_receive_buffer, arg_a, arg_b); - const out = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return out; - })(); - } - - get_a() { - return wasm.MyStruct_get_a(this.underlying); - } - - set_b(arg_b) { - wasm.MyStruct_set_b(this.underlying, arg_b); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.mjs.snap index e4e1191c3..31d351198 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@MyStruct.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@api.mjs.snap deleted file mode 100644 index 6224c027d..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@api.mjs.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new(arg_a, arg_b) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_new(diplomat_receive_buffer, arg_a, arg_b); - const out = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return out; - })(); - } - - get_a() { - return wasm.MyStruct_get_a(this.underlying); - } - - set_b(arg_b) { - wasm.MyStruct_set_b(this.underlying, arg_b); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.d.ts.snap index 0413b8eae..8f34f24b7 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.js.snap deleted file mode 100644 index 5d48ef622..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_non_opaque_struct@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.js.snap deleted file mode 100644 index 3146c6583..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.js.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - static new(arg_a, arg_b) { - return new MyStruct(wasm.MyStruct_new(arg_a, arg_b), true, []); - } - - get_a() { - return wasm.MyStruct_get_a(this.underlying); - } - - set_b(arg_b) { - wasm.MyStruct_set_b(this.underlying, arg_b); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.mjs.snap index d700a932f..026032276 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@MyStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/structs.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyStruct_destroy(underlying); }); -export default class MyStruct { +export class MyStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@api.mjs.snap deleted file mode 100644 index 072df958e..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@api.mjs.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyStruct_destroy(underlying); -}); - -export class MyStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyStruct_box_destroy_registry.register(this, underlying); - } - } - - static new(arg_a, arg_b) { - return new MyStruct(wasm.MyStruct_new(arg_a, arg_b), true, []); - } - - get_a() { - return wasm.MyStruct_get_a(this.underlying); - } - - set_b(arg_b) { - wasm.MyStruct_set_b(this.underlying, arg_b); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.js.snap deleted file mode 100644 index 5d48ef622..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/structs.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.mjs.snap new file mode 100644 index 000000000..5ce2b42f2 --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__structs__tests__simple_opaque_struct@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/structs.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.js.snap deleted file mode 100644 index f977c82ab..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyOpaqueStruct.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.js.snap deleted file mode 100644 index f207537ec..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.js.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { MyOpaqueStruct } from "./MyOpaqueStruct.js" - -export class MyStruct { - constructor(underlying) { - this.a = (() => { - const option_ptr = diplomatRuntime.ptrRead(wasm, underlying); - return (option_ptr == 0) ? null : new MyOpaqueStruct(option_ptr, true, []); - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.mjs.snap index 5d1cac519..dd3da8a35 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@MyStruct.mjs.snap @@ -2,11 +2,11 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import MyOpaqueStruct from "./MyOpaqueStruct.mjs" +import { MyOpaqueStruct } from "./MyOpaqueStruct.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (() => { const option_ptr = diplomatRuntime.ptrRead(wasm, underlying); diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@api.mjs.snap deleted file mode 100644 index ef9d8405e..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@api.mjs.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - -export class MyStruct { - constructor(underlying) { - this.a = (() => { - const option_ptr = diplomatRuntime.ptrRead(wasm, underlying); - return (option_ptr == 0) ? null : new MyOpaqueStruct(option_ptr, true, []); - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.d.ts.snap index 12233e7e8..482744d94 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.js.snap deleted file mode 100644 index da9a511b0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.mjs.snap new file mode 100644 index 000000000..09525806d --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__option_types@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.js.snap deleted file mode 100644 index f977c82ab..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.mjs.snap index 37152f2a4..ed6c5e78d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyOpaqueStruct.mjs.snap @@ -2,14 +2,14 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { wasm.MyOpaqueStruct_destroy(underlying); }); -export default class MyOpaqueStruct { +export class MyOpaqueStruct { #lifetimeEdges = []; constructor(underlying, owned, edges) { this.underlying = underlying; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.js.snap deleted file mode 100644 index 67af5f267..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.js.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" -import { MyOpaqueStruct } from "./MyOpaqueStruct.js" - -export class MyStruct { - constructor(underlying, edges_a) { - this.a = new MyOpaqueStruct(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_a]); - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } - - static new(arg_foo, arg_bar) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); - wasm.MyStruct_new(diplomat_receive_buffer, arg_foo.underlying, arg_bar.underlying); - const out = new MyStruct(diplomat_receive_buffer, [arg_foo, arg_bar]); - wasm.diplomat_free(diplomat_receive_buffer, 5, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.mjs.snap index b7bcb2045..1b7c4935b 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@MyStruct.mjs.snap @@ -2,11 +2,11 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -import MyOpaqueStruct from "./MyOpaqueStruct.mjs" +import { MyOpaqueStruct } from "./MyOpaqueStruct.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying, edges_a) { this.a = new MyOpaqueStruct(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_a]); this.b = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@api.mjs.snap deleted file mode 100644 index 35b553715..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@api.mjs.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - -export class MyStruct { - constructor(underlying, edges_a) { - this.a = new MyOpaqueStruct(diplomatRuntime.ptrRead(wasm, underlying), false, [...edges_a]); - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0]; - } - - static new(arg_foo, arg_bar) { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); - wasm.MyStruct_new(diplomat_receive_buffer, arg_foo.underlying, arg_bar.underlying); - const out = new MyStruct(diplomat_receive_buffer, [arg_foo, arg_bar]); - wasm.diplomat_free(diplomat_receive_buffer, 5, 4); - return out; - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.js.snap deleted file mode 100644 index da9a511b0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.mjs.snap new file mode 100644 index 000000000..09525806d --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__pointer_types@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.js.snap deleted file mode 100644 index f977c82ab..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyOpaqueStruct.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.js.snap deleted file mode 100644 index 14de52f74..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.js.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new() { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(3, 1); - wasm.MyStruct_new(diplomat_receive_buffer); - const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 2); - if (is_ok) { - const ok_value = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 3, 1); - return ok_value; - } else { - const throw_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; - wasm.diplomat_free(diplomat_receive_buffer, 3, 1); - throw new diplomatRuntime.FFIError(throw_value); - } - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.mjs.snap index 938de525e..5d791f59c 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@MyStruct.mjs.snap @@ -2,10 +2,10 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@api.mjs.snap deleted file mode 100644 index 7e2edc10c..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@api.mjs.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -const MyOpaqueStruct_box_destroy_registry = new FinalizationRegistry(underlying => { - wasm.MyOpaqueStruct_destroy(underlying); -}); - -export class MyOpaqueStruct { - #lifetimeEdges = []; - constructor(underlying, owned, edges) { - this.underlying = underlying; - this.#lifetimeEdges.push(...edges); - if (owned) { - MyOpaqueStruct_box_destroy_registry.register(this, underlying); - } - } -} - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new() { - return (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(3, 1); - wasm.MyStruct_new(diplomat_receive_buffer); - const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 2); - if (is_ok) { - const ok_value = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 3, 1); - return ok_value; - } else { - const throw_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; - wasm.diplomat_free(diplomat_receive_buffer, 3, 1); - throw new diplomatRuntime.FFIError(throw_value); - } - })(); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.d.ts.snap index 12233e7e8..482744d94 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.d.ts.snap @@ -2,7 +2,7 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.js.snap deleted file mode 100644 index da9a511b0..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.js.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyOpaqueStruct } from './MyOpaqueStruct.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.mjs.snap new file mode 100644 index 000000000..09525806d --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__result_types@index.mjs.snap @@ -0,0 +1,8 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyOpaqueStruct } from './MyOpaqueStruct.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.js.snap deleted file mode 100644 index d439d9477..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.js.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str8(wasm, arg_v); - const diplomat_out = (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_v.ptr, buf_arg_v.size); - const out = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return out; - })(); - buf_arg_v.free(); - return diplomat_out; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.mjs.snap index d146b3050..7a7934233 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.mjs.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@MyStruct.mjs.snap @@ -2,17 +2,17 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -import wasm from "../wasm.mjs" +import wasm from "./diplomat-wasm.mjs" import * as diplomatRuntime from "./diplomat-runtime.mjs" -export default class MyStruct { +export class MyStruct { constructor(underlying) { this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; } static new(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str(wasm, arg_v); + const buf_arg_v = diplomatRuntime.DiplomatBuf.str8(wasm, arg_v); const diplomat_out = (() => { const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_v.ptr, buf_arg_v.size); diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@api.mjs.snap deleted file mode 100644 index 0ee4d5d93..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@api.mjs.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - static new(arg_v) { - const buf_arg_v = diplomatRuntime.DiplomatBuf.str(wasm, arg_v); - const diplomat_out = (() => { - const diplomat_receive_buffer = wasm.diplomat_alloc(2, 1); - wasm.MyStruct_new(diplomat_receive_buffer, buf_arg_v.ptr, buf_arg_v.size); - const out = new MyStruct(diplomat_receive_buffer); - wasm.diplomat_free(diplomat_receive_buffer, 2, 1); - return out; - })(); - buf_arg_v.free(); - return diplomat_out; - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.js.snap deleted file mode 100644 index 11dc3f0e2..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.mjs.snap new file mode 100644 index 000000000..a15d156bb --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__string_reference@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.js.snap deleted file mode 100644 index e7be71efa..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@MyStruct.js.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - something() { - const field_a_this = this["a"]; - const field_b_this = this["b"]; - return wasm.MyStruct_something(field_a_this, field_b_this); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@api.mjs.snap deleted file mode 100644 index bd18f73a6..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@api.mjs.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - something() { - const field_a_this = this["a"]; - const field_b_this = this["b"]; - return wasm.MyStruct_something(field_a_this, field_b_this); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.d.ts.snap index 3cc253c93..b9080f37d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.js.snap deleted file mode 100644 index 11dc3f0e2..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.mjs.snap new file mode 100644 index 000000000..a15d156bb --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__unit_type@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.js.snap deleted file mode 100644 index 01a64348d..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@MyStruct.js.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./diplomat-wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.js" - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - write() { - const field_a_this = this["a"]; - const field_b_this = this["b"]; - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write(field_a_this, field_b_this, writeable); - }); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@api.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@api.mjs.snap deleted file mode 100644 index c8cc7de42..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@api.mjs.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -import wasm from "./wasm.mjs" -import * as diplomatRuntime from "./diplomat-runtime.mjs" -const diplomat_alloc_destroy_registry = new FinalizationRegistry(obj => { - wasm.diplomat_free(obj["ptr"], obj["size"], obj["align"]); -}); - -export class MyStruct { - constructor(underlying) { - this.a = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0]; - this.b = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0]; - } - - write() { - const field_a_this = this["a"]; - const field_b_this = this["b"]; - return diplomatRuntime.withWriteable(wasm, (writeable) => { - return wasm.MyStruct_write(field_a_this, field_b_this, writeable); - }); - } -} - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.d.ts.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.d.ts.snap index 3cc253c93..b9080f37d 100644 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.d.ts.snap +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.d.ts.snap @@ -2,6 +2,6 @@ source: tool/src/js/types.rs expression: out_texts.get(out).unwrap() --- -export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.js.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.js.snap deleted file mode 100644 index 11dc3f0e2..000000000 --- a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tool/src/js/types.rs -expression: out_texts.get(out).unwrap() ---- -export { FFIError } from './diplomat-runtime.js'; -export { MyStruct } from './MyStruct.js'; - diff --git a/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.mjs.snap b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.mjs.snap new file mode 100644 index 000000000..a15d156bb --- /dev/null +++ b/tool/src/js/snapshots/diplomat_tool__js__types__tests__writeable_out@index.mjs.snap @@ -0,0 +1,7 @@ +--- +source: tool/src/js/types.rs +expression: out_texts.get(out).unwrap() +--- +export { FFIError } from './diplomat-runtime.mjs'; +export { MyStruct } from './MyStruct.mjs'; + From 79014c13d8512fe40b8b3d32e9f58e57eaa61e57 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:16:49 +0100 Subject: [PATCH 4/5] fix --- example/js/lib/{diplomat.config.js => diplomat.config.mjs} | 0 example/js/lib/package.json | 6 ++++-- example/js/lib/test/fixed-decimal-ts.mjs | 2 +- example/js/lib/test/fixed-decimal-ts.mts | 2 +- example/js/lib/test/fixed-decimal.mjs | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) rename example/js/lib/{diplomat.config.js => diplomat.config.mjs} (100%) diff --git a/example/js/lib/diplomat.config.js b/example/js/lib/diplomat.config.mjs similarity index 100% rename from example/js/lib/diplomat.config.js rename to example/js/lib/diplomat.config.mjs diff --git a/example/js/lib/package.json b/example/js/lib/package.json index 6ae78759b..933b61f0c 100644 --- a/example/js/lib/package.json +++ b/example/js/lib/package.json @@ -2,8 +2,10 @@ "name": "demo", "version": "0.0.1", "description": "Diplomat WASM example", - "type": "module", - "main": "./api/index.js", + "main": "./api/index.mjs", + "exports": { + ".": "./api/index.mjs" + }, "directories": { "doc": "docs", "test": "test" diff --git a/example/js/lib/test/fixed-decimal-ts.mjs b/example/js/lib/test/fixed-decimal-ts.mjs index 60d61a85d..631c7bb77 100644 --- a/example/js/lib/test/fixed-decimal-ts.mjs +++ b/example/js/lib/test/fixed-decimal-ts.mjs @@ -1,5 +1,5 @@ import test from 'ava'; -import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "../api/index.js" +import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "demo"; test("multiply a fixed decimal by 0.1", t => { const my_decimal = ICU4XFixedDecimal.new(123); my_decimal.multiply_pow10(-1); diff --git a/example/js/lib/test/fixed-decimal-ts.mts b/example/js/lib/test/fixed-decimal-ts.mts index e29573b27..ead42cd42 100644 --- a/example/js/lib/test/fixed-decimal-ts.mts +++ b/example/js/lib/test/fixed-decimal-ts.mts @@ -1,6 +1,6 @@ import test from 'ava'; -import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "../api/index.js" +import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "demo"; test("multiply a fixed decimal by 0.1", t => { const my_decimal = ICU4XFixedDecimal.new(123); diff --git a/example/js/lib/test/fixed-decimal.mjs b/example/js/lib/test/fixed-decimal.mjs index e29573b27..ead42cd42 100644 --- a/example/js/lib/test/fixed-decimal.mjs +++ b/example/js/lib/test/fixed-decimal.mjs @@ -1,6 +1,6 @@ import test from 'ava'; -import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "../api/index.js" +import { ICU4XFixedDecimal, ICU4XLocale, ICU4XDataProvider, ICU4XFixedDecimalFormatter, ICU4XFixedDecimalFormatterOptions } from "demo"; test("multiply a fixed decimal by 0.1", t => { const my_decimal = ICU4XFixedDecimal.new(123); From 18382aaff41370c1b85331bf43ecc2c45d3febcf Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:09:37 +0100 Subject: [PATCH 5/5] fix --- .../js/{diplomat.config.js => diplomat.config.mjs} | 0 feature_tests/js/package.json | 5 ++++- feature_tests/js/test/option-ts.mjs | 3 ++- feature_tests/js/test/option-ts.mts | 2 +- feature_tests/js/test/option.mjs | 2 +- feature_tests/js/test/result-ts.mjs | 3 ++- feature_tests/js/test/result-ts.mts | 8 ++++---- feature_tests/js/test/result.mjs | 2 +- feature_tests/js/test/struct-ts.mjs | 4 ++-- feature_tests/js/test/struct-ts.mts | 4 +--- feature_tests/js/test/struct.mjs | 4 +--- 11 files changed, 19 insertions(+), 18 deletions(-) rename feature_tests/js/{diplomat.config.js => diplomat.config.mjs} (100%) diff --git a/feature_tests/js/diplomat.config.js b/feature_tests/js/diplomat.config.mjs similarity index 100% rename from feature_tests/js/diplomat.config.js rename to feature_tests/js/diplomat.config.mjs diff --git a/feature_tests/js/package.json b/feature_tests/js/package.json index eb649decc..02ef485bf 100644 --- a/feature_tests/js/package.json +++ b/feature_tests/js/package.json @@ -2,7 +2,10 @@ "name": "diplomat-wasm-feature-tests", "version": "0.0.1", "description": "Diplomat WASM Feature Tests", - "main": "./api/index.js", + "main": "./api/index.mjs", + "exports": { + ".": "./api/index.mjs" + }, "type": "module", "directories": { "doc": "docs", diff --git a/feature_tests/js/test/option-ts.mjs b/feature_tests/js/test/option-ts.mjs index 629b2b094..b1f2c0ba3 100644 --- a/feature_tests/js/test/option-ts.mjs +++ b/feature_tests/js/test/option-ts.mjs @@ -1,5 +1,6 @@ import test from 'ava'; -import { OptionOpaque } from "../api/OptionOpaque.js"; +import { OptionOpaque } from "diplomat-wasm-feature-tests"; + test("Verify option methods", t => { const o = OptionOpaque.new(5); o.assert_integer(5); diff --git a/feature_tests/js/test/option-ts.mts b/feature_tests/js/test/option-ts.mts index 24168550a..7080bb493 100644 --- a/feature_tests/js/test/option-ts.mts +++ b/feature_tests/js/test/option-ts.mts @@ -1,6 +1,6 @@ import test from 'ava'; -import { OptionOpaque } from "../api/OptionOpaque.js"; +import { OptionOpaque } from "diplomat-wasm-feature-tests"; test("Verify option methods", t => { const o = OptionOpaque.new(5); diff --git a/feature_tests/js/test/option.mjs b/feature_tests/js/test/option.mjs index 24168550a..7080bb493 100644 --- a/feature_tests/js/test/option.mjs +++ b/feature_tests/js/test/option.mjs @@ -1,6 +1,6 @@ import test from 'ava'; -import { OptionOpaque } from "../api/OptionOpaque.js"; +import { OptionOpaque } from "diplomat-wasm-feature-tests"; test("Verify option methods", t => { const o = OptionOpaque.new(5); diff --git a/feature_tests/js/test/result-ts.mjs b/feature_tests/js/test/result-ts.mjs index d52f61cfb..5fa3410e9 100644 --- a/feature_tests/js/test/result-ts.mjs +++ b/feature_tests/js/test/result-ts.mjs @@ -1,5 +1,6 @@ import test from 'ava'; -import { ResultOpaque } from "../api/ResultOpaque.js"; +import { ResultOpaque } from "diplomat-wasm-feature-tests"; + test("Verify result methods", t => { const s = ResultOpaque.new(5); s.assert_integer(5); diff --git a/feature_tests/js/test/result-ts.mts b/feature_tests/js/test/result-ts.mts index 66532f34f..e105cd45b 100644 --- a/feature_tests/js/test/result-ts.mts +++ b/feature_tests/js/test/result-ts.mts @@ -1,8 +1,8 @@ import test from 'ava'; -import { FFIError } from '../api/diplomat-runtime.js'; -import { ErrorEnum } from '../api/ErrorEnum.js'; -import { ErrorStruct } from '../api/ErrorStruct.js'; -import { ResultOpaque } from "../api/ResultOpaque.js" +import { FFIError } from "diplomat-wasm-feature-tests"; +import { ErrorEnum } from "diplomat-wasm-feature-tests"; +import { ErrorStruct } from "diplomat-wasm-feature-tests"; +import { ResultOpaque } from "diplomat-wasm-feature-tests" test("Verify result methods", t => { const s = ResultOpaque.new(5); diff --git a/feature_tests/js/test/result.mjs b/feature_tests/js/test/result.mjs index d02f2c816..6a9752b54 100644 --- a/feature_tests/js/test/result.mjs +++ b/feature_tests/js/test/result.mjs @@ -1,6 +1,6 @@ import test from 'ava'; -import { ResultOpaque } from "../api/ResultOpaque.js" +import { ResultOpaque } from "diplomat-wasm-feature-tests" test("Verify result methods", t => { const s = ResultOpaque.new(5); diff --git a/feature_tests/js/test/struct-ts.mjs b/feature_tests/js/test/struct-ts.mjs index c3f407457..b0ca51585 100644 --- a/feature_tests/js/test/struct-ts.mjs +++ b/feature_tests/js/test/struct-ts.mjs @@ -1,6 +1,6 @@ import test from 'ava'; -import { MyEnum } from '../api/MyEnum.js'; -import { MyStruct } from "../api/MyStruct.js"; +import { MyEnum, MyStruct } from "diplomat-wasm-feature-tests"; + test("Verify invariants of struct", t => { const s = MyStruct.new(); t.is(s["a"], 17); diff --git a/feature_tests/js/test/struct-ts.mts b/feature_tests/js/test/struct-ts.mts index a29311c11..b0ca51585 100644 --- a/feature_tests/js/test/struct-ts.mts +++ b/feature_tests/js/test/struct-ts.mts @@ -1,7 +1,5 @@ import test from 'ava'; -import { MyEnum } from '../api/MyEnum.js'; - -import { MyStruct } from "../api/MyStruct.js" +import { MyEnum, MyStruct } from "diplomat-wasm-feature-tests"; test("Verify invariants of struct", t => { const s = MyStruct.new(); diff --git a/feature_tests/js/test/struct.mjs b/feature_tests/js/test/struct.mjs index c83ee7ad8..b762ed0cd 100644 --- a/feature_tests/js/test/struct.mjs +++ b/feature_tests/js/test/struct.mjs @@ -1,7 +1,5 @@ import test from 'ava'; -import { MyEnum } from '../api/MyEnum.js'; - -import { MyStruct } from "../api/MyStruct.js" +import { MyEnum, MyStruct } from "diplomat-wasm-feature-tests"; test("Verify invariants of struct", t => { const s = MyStruct.new("hello");