{"version":3,"sources":["../../../src/server/test-utils/vitest.ts"],"names":[],"mappings":";AAEO,SAAS,2BAAA,GAAsC;AACpD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,yBAAA;AAAA,IACN,OAAA,EAAS,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKT,MAAA,GAAS;AACP,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,MAAA,EAAQ,CAAC,aAAa,CAAA,EAAE,EAAE;AAAE,OACxD;AAAA,IACF,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,UAAU,EAAA,EAAI;AACZ,MAAA,IAAI,EAAA,CAAG,UAAA,CAAW,kBAAkB,CAAA,EAAG;AACrC,QAAA,OAAO,+BAAA;AAAA,MACT;AACA,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,IACA,KAAK,EAAA,EAAI;AACP,MAAA,IAAI,EAAA,KAAO,iCAAiC,OAAO,IAAA;AACnD,MAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAA,CAAA;AAAA,IA+BT;AAAA,GACF;AACF","file":"vitest.mjs","sourcesContent":["import type { Plugin, UserConfig } from 'vite';\n\nexport function spacetimedbModuleTestPlugin(): Plugin {\n  return {\n    name: 'spacetimedb-module-test',\n    enforce: 'pre',\n    // The SDK imports `spacetime:sys` itself, not just the module under test.\n    // Vitest hands dependencies in node_modules straight to Node's loader,\n    // which never consults this plugin and rejects the scheme, so the SDK\n    // has to be inlined to go through Vite instead.\n    config() {\n      return {\n        test: { server: { deps: { inline: ['spacetimedb'] } } },\n      } as UserConfig;\n    },\n    // Every ABI version resolves to the one stub below, which exports the\n    // union of their functions. A new version then needs only its new\n    // functions added there, not another case here.\n    resolveId(id) {\n      if (id.startsWith('spacetime:sys@2.')) {\n        return '\\0spacetimedb-module-test-sys';\n      }\n      return null;\n    },\n    load(id) {\n      if (id !== '\\0spacetimedb-module-test-sys') return null;\n      return `\n        export const moduleHooks = Symbol.for('spacetimedb.moduleHooks');\n        const unsupported = name => () => {\n          throw new Error('Unsupported SpacetimeDB host syscall in module unit test: ' + name);\n        };\n        export const identity = unsupported('identity');\n        export const get_jwt_payload = unsupported('get_jwt_payload');\n        export const table_id_from_name = unsupported('table_id_from_name');\n        export const index_id_from_name = unsupported('index_id_from_name');\n        export const datastore_table_row_count = unsupported('datastore_table_row_count');\n        export const datastore_table_scan_bsatn = unsupported('datastore_table_scan_bsatn');\n        export const datastore_insert_bsatn = unsupported('datastore_insert_bsatn');\n        export const datastore_delete_all_by_eq_bsatn = unsupported('datastore_delete_all_by_eq_bsatn');\n        export const datastore_index_scan_point_bsatn = unsupported('datastore_index_scan_point_bsatn');\n        export const datastore_index_scan_range_bsatn = unsupported('datastore_index_scan_range_bsatn');\n        export const datastore_delete_by_index_scan_point_bsatn = unsupported('datastore_delete_by_index_scan_point_bsatn');\n        export const datastore_delete_by_index_scan_range_bsatn = unsupported('datastore_delete_by_index_scan_range_bsatn');\n        export const datastore_update_bsatn = unsupported('datastore_update_bsatn');\n        export const datastore_clear = unsupported('datastore_clear');\n        export const row_iter_bsatn_advance = unsupported('row_iter_bsatn_advance');\n        export const row_iter_bsatn_close = unsupported('row_iter_bsatn_close');\n        export const procedure_start_mut_tx = unsupported('procedure_start_mut_tx');\n        export const procedure_commit_mut_tx = unsupported('procedure_commit_mut_tx');\n        export const procedure_abort_mut_tx = unsupported('procedure_abort_mut_tx');\n        export const procedure_http_request = unsupported('procedure_http_request');\n        export const env_get = unsupported('env_get');\n        export const console_log = () => {};\n        export const console_timer_start = () => 0;\n        export const console_timer_end = () => {};\n        export const volatile_nonatomic_schedule_immediate = unsupported('volatile_nonatomic_schedule_immediate');\n      `;\n    },\n  };\n}\n"]}