@inlang/sdk 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/database/initDb.js +1 -4
  2. package/dist/database/initDb.js.map +1 -1
  3. package/dist/database/initDbAndSchema.test.js +1 -4
  4. package/dist/database/initDbAndSchema.test.js.map +1 -1
  5. package/dist/database/jsonbPlugin.js +1 -4
  6. package/dist/database/jsonbPlugin.js.map +1 -1
  7. package/dist/database/jsonbPlugin.test.js +1 -4
  8. package/dist/database/jsonbPlugin.test.js.map +1 -1
  9. package/dist/database/schema.js +1 -4
  10. package/dist/database/schema.js.map +1 -1
  11. package/dist/helper.js +1 -4
  12. package/dist/helper.js.map +1 -1
  13. package/dist/human-id/human-id.js +1 -4
  14. package/dist/human-id/human-id.js.map +1 -1
  15. package/dist/human-id/words.js +1 -4
  16. package/dist/human-id/words.js.map +1 -1
  17. package/dist/human-id/words.test.js +1 -4
  18. package/dist/human-id/words.test.js.map +1 -1
  19. package/dist/import-export/exportFiles.js +1 -4
  20. package/dist/import-export/exportFiles.js.map +1 -1
  21. package/dist/import-export/importFiles.js +1 -4
  22. package/dist/import-export/importFiles.js.map +1 -1
  23. package/dist/import-export/importFiles.test.js +1 -4
  24. package/dist/import-export/importFiles.test.js.map +1 -1
  25. package/dist/import-export/roundtrip.test.js +1 -4
  26. package/dist/import-export/roundtrip.test.js.map +1 -1
  27. package/dist/import-export/upsertBundleNestedMatchByProperties.js +1 -4
  28. package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -1
  29. package/dist/index.js +1 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/json-schema/old-v1-message/fromMessageV1.js +1 -4
  32. package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -1
  33. package/dist/json-schema/old-v1-message/fromMessageV1.test.js +1 -4
  34. package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -1
  35. package/dist/json-schema/old-v1-message/schemaV1.js +1 -4
  36. package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -1
  37. package/dist/json-schema/old-v1-message/toMessageV1.js +1 -4
  38. package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -1
  39. package/dist/json-schema/old-v1-message/toMessageV1.test.js +1 -4
  40. package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -1
  41. package/dist/json-schema/pattern.js +1 -4
  42. package/dist/json-schema/pattern.js.map +1 -1
  43. package/dist/json-schema/settings.js +1 -4
  44. package/dist/json-schema/settings.js.map +1 -1
  45. package/dist/json-schema/settings.test-d.js +1 -4
  46. package/dist/json-schema/settings.test-d.js.map +1 -1
  47. package/dist/json-schema/settings.test.js +1 -4
  48. package/dist/json-schema/settings.test.js.map +1 -1
  49. package/dist/lix/index.js +1 -4
  50. package/dist/lix/index.js.map +1 -1
  51. package/dist/lix-plugin/applyChanges.js +1 -4
  52. package/dist/lix-plugin/applyChanges.js.map +1 -1
  53. package/dist/lix-plugin/applyChanges.test.js +1 -4
  54. package/dist/lix-plugin/applyChanges.test.js.map +1 -1
  55. package/dist/lix-plugin/detectConflicts.js +1 -4
  56. package/dist/lix-plugin/detectConflicts.js.map +1 -1
  57. package/dist/lix-plugin/detectConflicts.test.js +1 -4
  58. package/dist/lix-plugin/detectConflicts.test.js.map +1 -1
  59. package/dist/lix-plugin/inlangLixPluginV1.js +1 -4
  60. package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -1
  61. package/dist/lix-plugin/inlangLixPluginV1.test.js +1 -4
  62. package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -1
  63. package/dist/lix-plugin/merge.test.js +1 -4
  64. package/dist/lix-plugin/merge.test.js.map +1 -1
  65. package/dist/lix-plugin/resolveConflictBySelecting.test.js +1 -4
  66. package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -1
  67. package/dist/migrations/v2/createMessageV1.js +1 -4
  68. package/dist/migrations/v2/createMessageV1.js.map +1 -1
  69. package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +1 -4
  70. package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -1
  71. package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +1 -4
  72. package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -1
  73. package/dist/plugin/cache.js +1 -4
  74. package/dist/plugin/cache.js.map +1 -1
  75. package/dist/plugin/cache.test.js +1 -4
  76. package/dist/plugin/cache.test.js.map +1 -1
  77. package/dist/plugin/errors.js +1 -4
  78. package/dist/plugin/errors.js.map +1 -1
  79. package/dist/plugin/importPlugins.js +1 -4
  80. package/dist/plugin/importPlugins.js.map +1 -1
  81. package/dist/plugin/importPlugins.test.js +1 -4
  82. package/dist/plugin/importPlugins.test.js.map +1 -1
  83. package/dist/plugin/meta/ideExtension.js +1 -4
  84. package/dist/plugin/meta/ideExtension.js.map +1 -1
  85. package/dist/plugin/schema.js +1 -4
  86. package/dist/plugin/schema.js.map +1 -1
  87. package/dist/project/api.js +1 -4
  88. package/dist/project/api.js.map +1 -1
  89. package/dist/project/loadProject.d.ts.map +1 -1
  90. package/dist/project/loadProject.js +1 -6
  91. package/dist/project/loadProject.js.map +1 -1
  92. package/dist/project/loadProject.test.js +1 -4
  93. package/dist/project/loadProject.test.js.map +1 -1
  94. package/dist/project/loadProjectFromDirectory.js +1 -4
  95. package/dist/project/loadProjectFromDirectory.js.map +1 -1
  96. package/dist/project/loadProjectFromDirectory.test.js +1 -4
  97. package/dist/project/loadProjectFromDirectory.test.js.map +1 -1
  98. package/dist/project/loadProjectInMemory.js +1 -4
  99. package/dist/project/loadProjectInMemory.js.map +1 -1
  100. package/dist/project/loadProjectInMemory.test.js +1 -4
  101. package/dist/project/loadProjectInMemory.test.js.map +1 -1
  102. package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -1
  103. package/dist/project/maybeCaptureTelemetry.js +1 -6
  104. package/dist/project/maybeCaptureTelemetry.js.map +1 -1
  105. package/dist/project/maybeCaptureTelemetry.test.js +1 -4
  106. package/dist/project/maybeCaptureTelemetry.test.js.map +1 -1
  107. package/dist/project/newProject.d.ts.map +1 -1
  108. package/dist/project/newProject.js +1 -6
  109. package/dist/project/newProject.js.map +1 -1
  110. package/dist/project/newProject.test.js +1 -4
  111. package/dist/project/newProject.test.js.map +1 -1
  112. package/dist/project/saveProjectToDirectory.js +1 -4
  113. package/dist/project/saveProjectToDirectory.js.map +1 -1
  114. package/dist/project/saveProjectToDirectory.test.js +1 -4
  115. package/dist/project/saveProjectToDirectory.test.js.map +1 -1
  116. package/dist/query-utilities/index.js +1 -4
  117. package/dist/query-utilities/index.js.map +1 -1
  118. package/dist/query-utilities/insertBundleNested.js +1 -4
  119. package/dist/query-utilities/insertBundleNested.js.map +1 -1
  120. package/dist/query-utilities/selectBundleNested.js +1 -4
  121. package/dist/query-utilities/selectBundleNested.js.map +1 -1
  122. package/dist/query-utilities/updateBundleNested.js +1 -4
  123. package/dist/query-utilities/updateBundleNested.js.map +1 -1
  124. package/dist/query-utilities/upsertBundleNested.js +1 -4
  125. package/dist/query-utilities/upsertBundleNested.js.map +1 -1
  126. package/dist/services/env-variables/index.js +2 -5
  127. package/dist/services/env-variables/index.js.map +1 -1
  128. package/dist/services/telemetry/capture.d.ts.map +1 -1
  129. package/dist/services/telemetry/capture.js +5 -9
  130. package/dist/services/telemetry/capture.js.map +1 -1
  131. package/dist/services/telemetry/capture.test.js +1 -4
  132. package/dist/services/telemetry/capture.test.js.map +1 -1
  133. package/dist/utilities/detectJsonFormatting.js +1 -4
  134. package/dist/utilities/detectJsonFormatting.js.map +1 -1
  135. package/dist/utilities/detectJsonFormatting.test.js +1 -4
  136. package/dist/utilities/detectJsonFormatting.test.js.map +1 -1
  137. package/package.json +5 -9
  138. package/src/project/loadProject.ts +0 -3
  139. package/src/project/maybeCaptureTelemetry.ts +0 -2
  140. package/src/project/newProject.ts +0 -2
  141. package/src/services/telemetry/capture.ts +4 -5
  142. package/dist/services/error-reporting/index.d.ts +0 -15
  143. package/dist/services/error-reporting/index.d.ts.map +0 -1
  144. package/dist/services/error-reporting/index.js +0 -30
  145. package/dist/services/error-reporting/index.js.map +0 -1
  146. package/src/services/error-reporting/index.ts +0 -28
@@ -1 +1 @@
1
- {"version":3,"file":"resolveConflictBySelecting.test.js","sources":["lix-plugin/resolveConflictBySelecting.test.ts"],"sourceRoot":"/","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { test, expect } from \"vitest\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\nimport {\n\tisInSimulatedCurrentBranch,\n\tresolveConflictBySelecting,\n} from \"@lix-js/sdk\";\nimport { contentFromDatabase } from \"sqlite-wasm-kysely\";\n\ntest.skip(\"it should resolve a conflict with the selected change\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tconst dbFile = await project.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"id\")\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst changes = await project.lix.db\n\t\t.insertInto(\"change\")\n\t\t.values([\n\t\t\t{\n\t\t\t\tid: \"e59b2fc6-612d-4087-9790-03b2ab724274\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"bundle\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"even_hour_mule_drum\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"c0c9e3f3-0eba-4233-813f-e1901401a653\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"message\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tbundleId: \"even_hour_mule_drum\",\n\t\t\t\t\tlocale: \"en\",\n\t\t\t\t\tselectors: [],\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"My Awesome Todo App\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"samuels-change\",\n\t\t\t\tauthor: \"Samuel\",\n\t\t\t\tparent_id: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"update\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"My awesome lix app\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 21:29:05\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"peters-change\",\n\t\t\t\tauthor: \"Peter\",\n\t\t\t\tparent_id: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"update\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"You are building an app\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 21:29:35\",\n\t\t\t},\n\t\t])\n\t\t.returningAll()\n\t\t.execute();\n\n\t// ---------------\n\t// Todo inlang sdk should auto write file to lix and differ must be\n\t// fault tolerant. without this code, the differ captures an old\n\t// change again\n\n\tfor (const change of changes) {\n\t\tawait project.db\n\t\t\t.insertInto(change.type as any)\n\t\t\t.values(change.value as any)\n\t\t\t.onConflict((c) => c.doNothing())\n\t\t\t.execute();\n\t}\n\tawait project.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set({ data: contentFromDatabase(project._sqlite) })\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n\t// ---------------\n\n\tconst conflicts = await project.lix.db\n\t\t.insertInto(\"conflict\")\n\t\t.values([\n\t\t\t{\n\t\t\t\tchange_id: \"samuels-change\",\n\t\t\t\tconflicting_change_id: \"peters-change\",\n\t\t\t\treason: \"\",\n\t\t\t},\n\t\t])\n\t\t.returningAll()\n\t\t.execute();\n\n\tconst changesInCurrentBranchBefore = await project.lix.db\n\t\t.selectFrom(\"change\")\n\t\t.selectAll()\n\t\t.where(isInSimulatedCurrentBranch)\n\t\t.execute();\n\n\texpect(changesInCurrentBranchBefore.map((c) => c.id)).toEqual([\n\t\tchanges[0]?.id,\n\t\tchanges[1]?.id,\n\t\tchanges[2]?.id,\n\t\t\"samuels-change\",\n\t]);\n\n\tawait resolveConflictBySelecting({\n\t\tlix: project.lix,\n\t\tconflict: conflicts[0]!,\n\t\tselectChangeId: \"peters-change\",\n\t});\n\n\tawait project.lix.settled();\n\n\tconst changesInCurrentBranch = await project.lix.db\n\t\t.selectFrom(\"change\")\n\t\t.selectAll()\n\t\t.where(isInSimulatedCurrentBranch)\n\t\t.execute();\n\n\texpect(changesInCurrentBranch.map((c) => c.id)).toEqual([\n\t\tchanges[0]?.id,\n\t\tchanges[1]?.id,\n\t\tchanges[2]?.id,\n\t\t\"peters-change\",\n\t]);\n});\n"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc;;;AAEd,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,IAAI,CAAC,IAAI,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;IAC7E,MAAM,OAAO,GAAG,MAAM,mBAA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,CAAC,CAAE;QACvB,cAAc,EAAE,eAAe;KAC/B,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAE5B,MAAM,sBAAsB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE;SACjD,UAAU,CAAC,QAAQ,CAAC;SACpB,SAAS,EAAE;SACX,KAAK,CAAC,0BAA0B,CAAC;SACjC,OAAO,EAAE,CAAC;IAEZ,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACvD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,eAAe;KACf,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","debug_id":"83e7ae0e-e607-5d89-8023-87b74e4c9b67"}
1
+ {"version":3,"file":"resolveConflictBySelecting.test.js","sourceRoot":"/","sources":["lix-plugin/resolveConflictBySelecting.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc;AAEd,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,IAAI,CAAC,IAAI,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;IAC7E,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAExE,MAAM,MAAM,GAAG,MAAM,OAAO,CA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E,CAAC;IAE5B,MAAM,sBAAsB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE;SACjD,UAAU,CAAC,QAAQ,CAAC;SACpB,SAAS,EAAE;SACX,KAAK,CAAC,0BAA0B,CAAC;SACjC,OAAO,EAAE,CAAC;IAEZ,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACvD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,eAAe;KACf,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { test, expect } from \"vitest\";\nimport { newProject } from \"../project/newProject.js\";\nimport { loadProjectInMemory } from \"../project/loadProjectInMemory.js\";\nimport {\n\tisInSimulatedCurrentBranch,\n\tresolveConflictBySelecting,\n} from \"@lix-js/sdk\";\nimport { contentFromDatabase } from \"sqlite-wasm-kysely\";\n\ntest.skip(\"it should resolve a conflict with the selected change\", async () => {\n\tconst project = await loadProjectInMemory({ blob: await newProject() });\n\n\tconst dbFile = await project.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"id\")\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst changes = await project.lix.db\n\t\t.insertInto(\"change\")\n\t\t.values([\n\t\t\t{\n\t\t\t\tid: \"e59b2fc6-612d-4087-9790-03b2ab724274\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"bundle\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"even_hour_mule_drum\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"c0c9e3f3-0eba-4233-813f-e1901401a653\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"message\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tbundleId: \"even_hour_mule_drum\",\n\t\t\t\t\tlocale: \"en\",\n\t\t\t\t\tselectors: [],\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tauthor: \"Anonymous\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"create\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"My Awesome Todo App\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 20:58:04\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"samuels-change\",\n\t\t\t\tauthor: \"Samuel\",\n\t\t\t\tparent_id: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"update\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"My awesome lix app\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 21:29:05\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"peters-change\",\n\t\t\t\tauthor: \"Peter\",\n\t\t\t\tparent_id: \"b92a634f-1e25-410f-af5a-e8702cc92ef0\",\n\t\t\t\tfile_id: dbFile.id,\n\t\t\t\tplugin_key: \"inlang-lix-plugin-v1\",\n\t\t\t\toperation: \"update\",\n\t\t\t\ttype: \"variant\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t\tmessageId: \"c2684c3d-3e14-47e4-96b7-8d33579bb7e9\",\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\tvalue: \"You are building an app\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tmeta: {\n\t\t\t\t\tid: \"6a860f96-0cf3-477c-80ad-7893d8fde852\",\n\t\t\t\t},\n\t\t\t\tcreated_at: \"2024-08-28 21:29:35\",\n\t\t\t},\n\t\t])\n\t\t.returningAll()\n\t\t.execute();\n\n\t// ---------------\n\t// Todo inlang sdk should auto write file to lix and differ must be\n\t// fault tolerant. without this code, the differ captures an old\n\t// change again\n\n\tfor (const change of changes) {\n\t\tawait project.db\n\t\t\t.insertInto(change.type as any)\n\t\t\t.values(change.value as any)\n\t\t\t.onConflict((c) => c.doNothing())\n\t\t\t.execute();\n\t}\n\tawait project.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set({ data: contentFromDatabase(project._sqlite) })\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n\t// ---------------\n\n\tconst conflicts = await project.lix.db\n\t\t.insertInto(\"conflict\")\n\t\t.values([\n\t\t\t{\n\t\t\t\tchange_id: \"samuels-change\",\n\t\t\t\tconflicting_change_id: \"peters-change\",\n\t\t\t\treason: \"\",\n\t\t\t},\n\t\t])\n\t\t.returningAll()\n\t\t.execute();\n\n\tconst changesInCurrentBranchBefore = await project.lix.db\n\t\t.selectFrom(\"change\")\n\t\t.selectAll()\n\t\t.where(isInSimulatedCurrentBranch)\n\t\t.execute();\n\n\texpect(changesInCurrentBranchBefore.map((c) => c.id)).toEqual([\n\t\tchanges[0]?.id,\n\t\tchanges[1]?.id,\n\t\tchanges[2]?.id,\n\t\t\"samuels-change\",\n\t]);\n\n\tawait resolveConflictBySelecting({\n\t\tlix: project.lix,\n\t\tconflict: conflicts[0]!,\n\t\tselectChangeId: \"peters-change\",\n\t});\n\n\tawait project.lix.settled();\n\n\tconst changesInCurrentBranch = await project.lix.db\n\t\t.selectFrom(\"change\")\n\t\t.selectAll()\n\t\t.where(isInSimulatedCurrentBranch)\n\t\t.execute();\n\n\texpect(changesInCurrentBranch.map((c) => c.id)).toEqual([\n\t\tchanges[0]?.id,\n\t\tchanges[1]?.id,\n\t\tchanges[2]?.id,\n\t\t\"peters-change\",\n\t]);\n});\n"]}
@@ -8,8 +8,6 @@
8
8
  * - createMessage("id", { "en": "Hello" })
9
9
  * + createMessageV1("id", { "en": "Hello" })
10
10
  */
11
-
12
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bdac64ef-de99-5845-a6a6-61937ce17038")}catch(e){}}();
13
11
  export const createMessageV1 = (id, patterns) => ({
14
12
  id,
15
13
  alias: {},
@@ -27,5 +25,4 @@ export const createMessageV1 = (id, patterns) => ({
27
25
  : patterns,
28
26
  })),
29
27
  });
30
- //# sourceMappingURL=createMessageV1.js.map
31
- //# debugId=bdac64ef-de99-5845-a6a6-61937ce17038
28
+ //# sourceMappingURL=createMessageV1.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createMessageV1.js","sources":["migrations/v2/createMessageV1.ts"],"sourceRoot":"/","sourcesContent":["import type {\n\tMessageV1,\n\tPatternV1,\n} from \"../../json-schema/old-v1-message/schemaV1.js\";\n\n/**\n * @deprecated don't use the messageV1 type anymore.\n *\n * This function exists to ease migrations of v1 plugins to v2 plugins.\n * The tests can call `createMessageV1` to create a message object that satisfies the v1 schema.\n *\n * @example\n * - createMessage(\"id\", { \"en\": \"Hello\" })\n * + createMessageV1(\"id\", { \"en\": \"Hello\" })\n */\nexport const createMessageV1 = (\n\tid: string,\n\tpatterns: Record<string, PatternV1 | string>\n) =>\n\t({\n\t\tid,\n\t\talias: {},\n\t\tselectors: [],\n\t\tvariants: Object.entries(patterns).map(([languageTag, patterns]) => ({\n\t\t\tlanguageTag,\n\t\t\tmatch: [],\n\t\t\tpattern:\n\t\t\t\ttypeof patterns === \"string\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\t\t\t\tvalue: patterns,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t: patterns,\n\t\t})),\n\t}) satisfies MessageV1;\n"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;;;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,EAAU,EACV,QAA4C,EAC3C,EAAE,CACH,CAAC;IACA,EAAE;IACF,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,WAAW;QACX,KAAK,EAAE,EAAE;QACT,OAAO,EACN,OAAO,QAAQ,KAAK,QAAQ;YAC3B,CAAC,CAAC;gBACA;oBACC,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,QAAQ;iBACf;aACD;YACF,CAAC,CAAC,QAAQ;KACZ,CAAC,CAAC;CACH,CAAqB,CAAC","debug_id":"bdac64ef-de99-5845-a6a6-61937ce17038"}
1
+ {"version":3,"file":"createMessageV1.js","sourceRoot":"/","sources":["migrations/v2/createMessageV1.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,EAAU,EACV,QAA4C,EAC3C,EAAE,CACH,CAAC;IACA,EAAE;IACF,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,WAAW;QACX,KAAK,EAAE,EAAE;QACT,OAAO,EACN,OAAO,QAAQ,KAAK,QAAQ;YAC3B,CAAC,CAAC;gBACA;oBACC,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,QAAQ;iBACf;aACD;YACF,CAAC,CAAC,QAAQ;KACZ,CAAC,CAAC;CACH,CAAqB,CAAC","sourcesContent":["import type {\n\tMessageV1,\n\tPatternV1,\n} from \"../../json-schema/old-v1-message/schemaV1.js\";\n\n/**\n * @deprecated don't use the messageV1 type anymore.\n *\n * This function exists to ease migrations of v1 plugins to v2 plugins.\n * The tests can call `createMessageV1` to create a message object that satisfies the v1 schema.\n *\n * @example\n * - createMessage(\"id\", { \"en\": \"Hello\" })\n * + createMessageV1(\"id\", { \"en\": \"Hello\" })\n */\nexport const createMessageV1 = (\n\tid: string,\n\tpatterns: Record<string, PatternV1 | string>\n) =>\n\t({\n\t\tid,\n\t\talias: {},\n\t\tselectors: [],\n\t\tvariants: Object.entries(patterns).map(([languageTag, patterns]) => ({\n\t\t\tlanguageTag,\n\t\t\tmatch: [],\n\t\t\tpattern:\n\t\t\t\ttypeof patterns === \"string\"\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"Text\",\n\t\t\t\t\t\t\t\tvalue: patterns,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t: patterns,\n\t\t})),\n\t}) satisfies MessageV1;\n"]}
@@ -4,8 +4,6 @@
4
4
  * The sourceLanguageTag and languageTags are now deprecated
5
5
  * in favor of baseLocale and locales.
6
6
  */
7
-
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f85c25cb-c61c-5c89-8f33-739f01dbd3c5")}catch(e){}}();
9
7
  export function withLanguageTagToLocaleMigration(settings) {
10
8
  if (settings.sourceLanguageTag === undefined) {
11
9
  settings.sourceLanguageTag = settings.baseLocale;
@@ -27,5 +25,4 @@ export function withLanguageTagToLocaleMigration(settings) {
27
25
  }
28
26
  return settings;
29
27
  }
30
- //# sourceMappingURL=withLanguageTagToLocaleMigration.js.map
31
- //# debugId=f85c25cb-c61c-5c89-8f33-739f01dbd3c5
28
+ //# sourceMappingURL=withLanguageTagToLocaleMigration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withLanguageTagToLocaleMigration.js","sources":["migrations/v2/withLanguageTagToLocaleMigration.ts"],"sourceRoot":"/","sourcesContent":["import type { ProjectSettings } from \"../../json-schema/settings.js\";\n\n/**\n * Change introduced in v2.\n *\n * The sourceLanguageTag and languageTags are now deprecated\n * in favor of baseLocale and locales.\n */\nexport function withLanguageTagToLocaleMigration(\n\tsettings: ProjectSettings\n): ProjectSettings {\n\tif (settings.sourceLanguageTag === undefined) {\n\t\tsettings.sourceLanguageTag = settings.baseLocale;\n\t}\n\tif (settings.languageTags === undefined) {\n\t\tsettings.languageTags = settings.locales;\n\t}\n\tif (settings.baseLocale === undefined) {\n\t\tsettings.baseLocale = settings.sourceLanguageTag;\n\t}\n\tif (settings.locales === undefined) {\n\t\tsettings.locales = settings.languageTags;\n\t}\n\tif (settings.sourceLanguageTag !== settings.baseLocale) {\n\t\tsettings.sourceLanguageTag = settings.baseLocale;\n\t}\n\tif (settings.languageTags !== settings.locales) {\n\t\tsettings.languageTags = settings.locales;\n\t}\n\treturn settings;\n}\n"],"names":[],"mappings":"AAEA;;;;;GAKG;;;AACH,MAAM,UAAU,gCAAgC,CAC/C,QAAyB;IAEzB,IAAI,QAAQ,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC9C,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACzC,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC1C,CAAC;IACD,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACvC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACpC,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC1C,CAAC;IACD,IAAI,QAAQ,CAAC,iBAAiB,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxD,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QAChD,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","debug_id":"f85c25cb-c61c-5c89-8f33-739f01dbd3c5"}
1
+ {"version":3,"file":"withLanguageTagToLocaleMigration.js","sourceRoot":"/","sources":["migrations/v2/withLanguageTagToLocaleMigration.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC/C,QAAyB;IAEzB,IAAI,QAAQ,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC9C,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACzC,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC1C,CAAC;IACD,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACvC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACpC,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC1C,CAAC;IACD,IAAI,QAAQ,CAAC,iBAAiB,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxD,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QAChD,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import type { ProjectSettings } from \"../../json-schema/settings.js\";\n\n/**\n * Change introduced in v2.\n *\n * The sourceLanguageTag and languageTags are now deprecated\n * in favor of baseLocale and locales.\n */\nexport function withLanguageTagToLocaleMigration(\n\tsettings: ProjectSettings\n): ProjectSettings {\n\tif (settings.sourceLanguageTag === undefined) {\n\t\tsettings.sourceLanguageTag = settings.baseLocale;\n\t}\n\tif (settings.languageTags === undefined) {\n\t\tsettings.languageTags = settings.locales;\n\t}\n\tif (settings.baseLocale === undefined) {\n\t\tsettings.baseLocale = settings.sourceLanguageTag;\n\t}\n\tif (settings.locales === undefined) {\n\t\tsettings.locales = settings.languageTags;\n\t}\n\tif (settings.sourceLanguageTag !== settings.baseLocale) {\n\t\tsettings.sourceLanguageTag = settings.baseLocale;\n\t}\n\tif (settings.languageTags !== settings.locales) {\n\t\tsettings.languageTags = settings.locales;\n\t}\n\treturn settings;\n}\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7ae848d6-3c60-531f-8c1c-dbe12ac6c624")}catch(e){}}();
3
1
  import { expect, test } from "vitest";
4
2
  import { withLanguageTagToLocaleMigration } from "./withLanguageTagToLocaleMigration.js";
5
3
  test("it should set sourceLanguageTag and languageTags if non-existent to make v1 plugins work", async () => {
@@ -41,5 +39,4 @@ test("it should treat baseLocale and locales as source of truth", async () => {
41
39
  expect(withMigration.languageTags).toEqual(["de", "en", "fr", "es"]);
42
40
  expect(withMigration.locales).toEqual(["de", "en", "fr", "es"]);
43
41
  });
44
- //# sourceMappingURL=withLanguageTagToLocaleMigration.test.js.map
45
- //# debugId=7ae848d6-3c60-531f-8c1c-dbe12ac6c624
42
+ //# sourceMappingURL=withLanguageTagToLocaleMigration.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withLanguageTagToLocaleMigration.test.js","sources":["migrations/v2/withLanguageTagToLocaleMigration.test.ts"],"sourceRoot":"/","sourcesContent":["import { expect, test } from \"vitest\";\nimport type { ProjectSettings } from \"../../json-schema/settings.js\";\nimport { withLanguageTagToLocaleMigration } from \"./withLanguageTagToLocaleMigration.js\";\n\ntest(\"it should set sourceLanguageTag and languageTags if non-existent to make v1 plugins work\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t};\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"en\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"en\");\n\texpect(withMigration.locales).toEqual([\"en\", \"de\"]);\n\texpect(withMigration.languageTags).toEqual([\"en\", \"de\"]);\n});\n\ntest(\"it should set baseLocale and locales if non-existent to ensure first load of an old project works\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tsourceLanguageTag: \"en\",\n\t\tlanguageTags: [\"en\", \"de\"],\n\t} as ProjectSettings;\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"en\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"en\");\n\texpect(withMigration.languageTags).toEqual([\"en\", \"de\"]);\n\texpect(withMigration.locales).toEqual([\"en\", \"de\"]);\n});\n\n/**\n * Users are expected to treat baseLocale and locales as the source of truth.\n * The alternative is complicated merging logic which is not worth the effort.\n */\ntest(\"it should treat baseLocale and locales as source of truth\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tbaseLocale: \"de\",\n\t\tlocales: [\"de\", \"en\", \"fr\", \"es\"],\n\t\tsourceLanguageTag: \"en\",\n\t\tlanguageTags: [\"en\", \"nl\"],\n\t};\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"de\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"de\");\n\texpect(withMigration.languageTags).toEqual([\"de\", \"en\", \"fr\", \"es\"]);\n\texpect(withMigration.locales).toEqual([\"de\", \"en\",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CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;IAC5E,MAAM,QAAQ,GAAoB;QACjC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KAC1B,CAAC;IAEF,MAAM,aAAa,GAAG,gCAAgC,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC","debug_id":"7ae848d6-3c60-531f-8c1c-dbe12ac6c624"}
1
+ {"version":3,"file":"withLanguageTagToLocaleMigration.test.js","sourceRoot":"/","sources":["migrations/v2/withLanguageTagToLocaleMigration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,IAAI,CAAC,0FAA0F,EAAE,KAAK,IAAI,EAAE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AE;IAC5E,MAAM,QAAQ,GAAoB;QACjC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KAC1B,CAAC;IAEF,MAAM,aAAa,GAAG,gCAAgC,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport type { ProjectSettings } from \"../../json-schema/settings.js\";\nimport { withLanguageTagToLocaleMigration } from \"./withLanguageTagToLocaleMigration.js\";\n\ntest(\"it should set sourceLanguageTag and languageTags if non-existent to make v1 plugins work\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t};\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"en\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"en\");\n\texpect(withMigration.locales).toEqual([\"en\", \"de\"]);\n\texpect(withMigration.languageTags).toEqual([\"en\", \"de\"]);\n});\n\ntest(\"it should set baseLocale and locales if non-existent to ensure first load of an old project works\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tsourceLanguageTag: \"en\",\n\t\tlanguageTags: [\"en\", \"de\"],\n\t} as ProjectSettings;\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"en\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"en\");\n\texpect(withMigration.languageTags).toEqual([\"en\", \"de\"]);\n\texpect(withMigration.locales).toEqual([\"en\", \"de\"]);\n});\n\n/**\n * Users are expected to treat baseLocale and locales as the source of truth.\n * The alternative is complicated merging logic which is not worth the effort.\n */\ntest(\"it should treat baseLocale and locales as source of truth\", async () => {\n\tconst settings: ProjectSettings = {\n\t\tbaseLocale: \"de\",\n\t\tlocales: [\"de\", \"en\", \"fr\", \"es\"],\n\t\tsourceLanguageTag: \"en\",\n\t\tlanguageTags: [\"en\", \"nl\"],\n\t};\n\n\tconst withMigration = withLanguageTagToLocaleMigration(settings);\n\n\texpect(withMigration.baseLocale).toBe(\"de\");\n\texpect(withMigration.sourceLanguageTag).toBe(\"de\");\n\texpect(withMigration.languageTags).toEqual([\"de\", \"en\", \"fr\", \"es\"]);\n\texpect(withMigration.locales).toEqual([\"de\", \"en\", \"fr\", \"es\"]);\n});\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="31b19957-d98d-56fa-89ad-951e158d47c8")}catch(e){}}();
3
1
  function escape(url) {
4
2
  const bytes = new TextEncoder().encode(url);
5
3
  // 64-bit FNV1a hash to make the file-names shorter
@@ -55,5 +53,4 @@ export function withCache(moduleLoader, lix) {
55
53
  }
56
54
  };
57
55
  }
58
- //# sourceMappingURL=cache.js.map
59
- //# debugId=31b19957-d98d-56fa-89ad-951e158d47c8
56
+ //# sourceMappingURL=cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sources":["plugin/cache.ts"],"sourceRoot":"/","sourcesContent":["import type { Lix } from \"@lix-js/sdk\";\n\nfunction escape(url: string) {\n\tconst bytes = new TextEncoder().encode(url);\n\n\t// 64-bit FNV1a hash to make the file-names shorter\n\t// https://en.wikipedia.org/wiki/FNV-1a\n\tconst hash = bytes.reduce(\n\t\t(hash, byte) =>\n\t\t\tBigInt.asUintN(64, (hash ^ BigInt(byte)) * 1_099_511_628_211n),\n\t\t14_695_981_039_346_656_037n\n\t);\n\n\treturn hash.toString(36);\n}\n\nasync function readModuleFromCache(\n\tmoduleURI: string,\n\tlix: Lix\n): Promise<string | undefined> {\n\tconst moduleHash = escape(moduleURI);\n\tconst filePath = `/cache/plugins/${moduleHash}`;\n\n\tconst file = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.where(\"path\", \"=\", filePath)\n\t\t.selectAll()\n\t\t.executeTakeFirst();\n\n\tif (file) {\n\t\treturn new TextDecoder().decode(file.data);\n\t}\n\treturn undefined;\n}\n\nasync function writeModuleToCache(\n\tmoduleURI: string,\n\tmoduleContent: string,\n\tlix: Lix\n): Promise<void> {\n\tconst moduleHash = escape(moduleURI);\n\tconst filePath = `/cache/plugins/${moduleHash}`;\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: filePath,\n\t\t\tdata: new TextEncoder().encode(moduleContent),\n\t\t})\n\t\t// update the cache\n\t\t.onConflict((oc) =>\n\t\t\toc.doUpdateSet({ data: new TextEncoder().encode(moduleContent) })\n\t\t)\n\t\t.execute();\n}\n\n/**\n * Implements a \"Network-First\" caching strategy.\n */\nexport function withCache(\n\tmoduleLoader: (uri: string) => Promise<string>,\n\tlix: Lix\n): (uri: string) => Promise<string> {\n\treturn async (uri: string) => {\n\t\ttry {\n\t\t\tconst moduleAsText = await moduleLoader(uri);\n\t\t\tawait writeModuleToCache(uri, moduleAsText, lix);\n\t\t\treturn moduleAsText;\n\t\t} catch (e) {\n\t\t\t// network fetch failed, try to read from cache\n\t\t\tconst cacheResult = await readMod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CAAC,EAAE,CAAC,CACjE;SACA,OAAO,EAAE,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACxB,YAA8C,EAC9C,GAAQ;IAER,OAAO,KAAK,EAAE,GAAW,EAAE,EAAE;QAC5B,IAAI,CAAC;YACJ,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;YAC7C,MAAM,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;YACjD,OAAO,YAAY,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,+CAA+C;YAC/C,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACxD,IAAI,WAAW,EAAE,CAAC;gBACjB,OAAO,WAAW,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,CAAC;YACT,CAAC;QACF,CAAC;IACF,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { Lix } from \"@lix-js/sdk\";\n\nfunction escape(url: string) {\n\tconst bytes = new TextEncoder().encode(url);\n\n\t// 64-bit FNV1a hash to make the file-names shorter\n\t// https://en.wikipedia.org/wiki/FNV-1a\n\tconst hash = bytes.reduce(\n\t\t(hash, byte) =>\n\t\t\tBigInt.asUintN(64, (hash ^ BigInt(byte)) * 1_099_511_628_211n),\n\t\t14_695_981_039_346_656_037n\n\t);\n\n\treturn hash.toString(36);\n}\n\nasync function readModuleFromCache(\n\tmoduleURI: string,\n\tlix: Lix\n): Promise<string | undefined> {\n\tconst moduleHash = escape(moduleURI);\n\tconst filePath = `/cache/plugins/${moduleHash}`;\n\n\tconst file = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.where(\"path\", \"=\", filePath)\n\t\t.selectAll()\n\t\t.executeTakeFirst();\n\n\tif (file) {\n\t\treturn new TextDecoder().decode(file.data);\n\t}\n\treturn undefined;\n}\n\nasync function writeModuleToCache(\n\tmoduleURI: string,\n\tmoduleContent: string,\n\tlix: Lix\n): Promise<void> {\n\tconst moduleHash = escape(moduleURI);\n\tconst filePath = `/cache/plugins/${moduleHash}`;\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: filePath,\n\t\t\tdata: new TextEncoder().encode(moduleContent),\n\t\t})\n\t\t// update the cache\n\t\t.onConflict((oc) =>\n\t\t\toc.doUpdateSet({ data: new TextEncoder().encode(moduleContent) })\n\t\t)\n\t\t.execute();\n}\n\n/**\n * Implements a \"Network-First\" caching strategy.\n */\nexport function withCache(\n\tmoduleLoader: (uri: string) => Promise<string>,\n\tlix: Lix\n): (uri: string) => Promise<string> {\n\treturn async (uri: string) => {\n\t\ttry {\n\t\t\tconst moduleAsText = await moduleLoader(uri);\n\t\t\tawait writeModuleToCache(uri, moduleAsText, lix);\n\t\t\treturn moduleAsText;\n\t\t} catch (e) {\n\t\t\t// network fetch failed, try to read from cache\n\t\t\tconst cacheResult = await readModuleFromCache(uri, lix);\n\t\t\tif (cacheResult) {\n\t\t\t\treturn cacheResult;\n\t\t\t} else {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2528caec-29b9-569d-a353-9888c7c50eac")}catch(e){}}();
3
1
  import { test, expect, vi } from "vitest";
4
2
  import { withCache } from "./cache.js";
5
3
  import { newLixFile, openLixInMemory } from "@lix-js/sdk";
@@ -57,5 +55,4 @@ test("it should fallback to the cache if the loader fails", async () => {
57
55
  const result = await withCache(mockLoader, lix)(mockModulePath);
58
56
  expect(result).toBe("cached module content");
59
57
  });
60
- //# sourceMappingURL=cache.test.js.map
61
- //# debugId=2528caec-29b9-569d-a353-9888c7c50eac
58
+ //# sourceMappingURL=cache.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.test.js","sources":["plugin/cache.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { withCache } from \"./cache.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\nimport { sql } from \"kysely\";\n\ntest(\"it should be network-first\", async () => {\n\tconst mockLoader = vi\n\t\t.fn()\n\t\t.mockResolvedValueOnce(\"module content 1\")\n\t\t.mockResolvedValueOnce(\"module content 2\");\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result1 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(1);\n\texpect(result1).toBe(\"module content 1\");\n\n\tconst cachedPlugins = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins.length).toBe(1);\n\n\tconst parsed = new TextDecoder().decode(cachedPlugins[0]!.data);\n\n\texpect(parsed).toBe(\"module content 1\");\n\n\tconst result2 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(2);\n\texpect(result2).toBe(\"module content 2\");\n\n\tconst cachedPlugins2 = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins2.length).toBe(1);\n\n\tconst parsed2 = new TextDecoder().decode(cachedPlugins2[0]!.data);\n\n\texpect(parsed2).toBe(\"module content 2\");\n});\n\ntest(\"it should throw the error from the loader if the cache does not exist\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\texpect(\n\t\tasync () => await withCache(mockLoader, lix)(mockModulePath)\n\t).rejects.toThrowError(\"Network error\");\n});\n\ntest(\"it should fallback to the cache if the loader fails\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"cached module content\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await withCache(mockLoader, lix)(mockModulePath);\n\texpect(result).toBe(\"cached module content\");\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC7C,MAAM,UAAU,GAAG,EAAE;SACnB,EAAE,EAAE;SACJ,qBAAqB,CAAC,kBAAkB,CAAC;SACzC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAE5C,MAAM,cAAc,GAAG,4BAA4B,CAAC;IAEpD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;IAEjE,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,C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IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;IACtE,MAAM,UAAU,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAE7E,MAAM,cAAc,GAAG,4BAA4B,CAAC;IACpD,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;IAE3D,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAEhE,MAAM,GAAG,CAAC,EAAE;SACV,UAAU,CAAC,MAAM,CAAC;SAClB,MAAM,CAAC;QACP,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACvD,CAAC;SACD,OAAO,EAAE,CAAC;IAEZ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { withCache } from \"./cache.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\nimport { sql } from \"kysely\";\n\ntest(\"it should be network-first\", async () => {\n\tconst mockLoader = vi\n\t\t.fn()\n\t\t.mockResolvedValueOnce(\"module content 1\")\n\t\t.mockResolvedValueOnce(\"module content 2\");\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result1 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(1);\n\texpect(result1).toBe(\"module content 1\");\n\n\tconst cachedPlugins = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins.length).toBe(1);\n\n\tconst parsed = new TextDecoder().decode(cachedPlugins[0]!.data);\n\n\texpect(parsed).toBe(\"module content 1\");\n\n\tconst result2 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(2);\n\texpect(result2).toBe(\"module content 2\");\n\n\tconst cachedPlugins2 = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins2.length).toBe(1);\n\n\tconst parsed2 = new TextDecoder().decode(cachedPlugins2[0]!.data);\n\n\texpect(parsed2).toBe(\"module content 2\");\n});\n\ntest(\"it should throw the error from the loader if the cache does not exist\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\texpect(\n\t\tasync () => await withCache(mockLoader, lix)(mockModulePath)\n\t).rejects.toThrowError(\"Network error\");\n});\n\ntest(\"it should fallback to the cache if the loader fails\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"cached module content\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await withCache(mockLoader, lix)(mockModulePath);\n\texpect(result).toBe(\"cached module content\");\n});\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="80038c16-cc9c-5214-8c46-54bb2f3bc458")}catch(e){}}();
3
1
  export class PluginError extends Error {
4
2
  plugin;
5
3
  constructor(message, options) {
@@ -44,5 +42,4 @@ export class PluginMissingError extends PluginError {
44
42
  this.name = "PluginMissingError";
45
43
  }
46
44
  }
47
- //# sourceMappingURL=errors.js.map
48
- //# debugId=80038c16-cc9c-5214-8c46-54bb2f3bc458
45
+ //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["plugin/errors.ts"],"sourceRoot":"/","sourcesContent":["import type { ValueError } from \"@sinclair/typebox/errors\";\n\nexport class PluginError extends Error {\n\tpublic readonly plugin: string;\n\n\tconstructor(message: string, options: { plugin: string; cause?: Error }) {\n\t\tsuper(message);\n\t\tthis.name = \"PluginError\";\n\t\tthis.plugin = options.plugin;\n\t\tthis.cause = options.cause;\n\t}\n}\n\n/**\n * Error when a plugin cannot be imported.\n */\nexport class PluginImportError extends PluginError {\n\tconstructor(options: { plugin: string; cause: Error }) {\n\t\tsuper(\n\t\t\t`Couldn't import the plugin \"${options.plugin}\":\\n\\n${options.cause}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginImportError\";\n\t}\n}\n\nexport class PluginSettingsAreInvalidError extends PluginError {\n\tconstructor(options: { plugin: string; errors: ValueError[] }) {\n\t\tsuper(\n\t\t\t`The settings of \"${options.plugin}\" are invalid:\\n\\n${options.errors\n\t\t\t\t.map(\n\t\t\t\t\t(error) =>\n\t\t\t\t\t\t`Path \"${error.path}\" with value \"${JSON.stringify(\n\t\t\t\t\t\t\terror.value,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t)}\": \"${error.message}\"`\n\t\t\t\t)\n\t\t\t\t.join(\"\\n\")}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginSettingsAreInvalidError\";\n\t}\n}\n\n/**\n * Error when a plugin does not implement a required function\n */\nexport class PluginDoesNotImplementFunctionError extends PluginError {\n\tconstructor(options: { plugin: string; function: string }) {\n\t\tsuper(\n\t\t\t`The plugin \"${options.plugin}\" does not implement the \"${options.function}\" function.`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginDoesNotImplementFunction\";\n\t}\n}\n\n/**\n * Error when a plugin was expected to exist, but doesn't\n */\nexport class PluginMissingError extends PluginError {\n\tconstructor(options: { plugin: string }) {\n\t\tsuper(`The plugin \"${options.plugin}\" does not exist`, options);\n\t\tthis.name = \"PluginMissingError\";\n\t}\n}\n"],"names":[],"mappings":";;AAEA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACrB,MAAM,CAAS;IAE/B,YAAY,OAAe,EAAE,OAA0C;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IACjD,YAAY,OAAyC;QACpD,KAAK,CACJ,+BAA+B,OAAO,CAAC,MAAM,SAAS,OAAO,CAAC,KAAK,EAAE,EACrE,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD;AAED,MAAM,OAAO,6BAA8B,SAAQ,WAAW;IAC7D,YAAY,OAAiD;QAC5D,KAAK,CACJ,oBAAoB,OAAO,CAAC,MAAM,qBAAqB,OAAO,CAAC,MAAM;aACnE,GAAG,CACH,CAAC,KAAK,EAAE,EAAE,CACT,SAAS,KAAK,CAAC,IAAI,iBAAiB,IAAI,CAAC,SAAS,CACjD,KAAK,CAAC,KAAK,EACX,SAAS,EACT,CAAC,CACD,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AO,6BAA8B,SAAQ,WAAW;IAC7D,YAAY,OAAiD;QAC5D,KAAK,CACJ,oBAAoB,OAAO,CAAC,MAAM,qBAAqB,OAAO,CAAC,MAAM;aACnE,GAAG,CACH,CAAC,KAAK,EAAE,EAAE,CACT,SAAS,KAAK,CAAC,IAAI,iBAAiB,IAAI,CAAC,SAAS,CACjD,KAAK,CAAC,KAAK,EACX,SAAS,EACT,CAAC,CACD,OAAO,KAAK,CAAC,OAAO,GAAG,CACzB;aACA,IAAI,CAAC,IAAI,CAAC,EAAE,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC7C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,mCAAoC,SAAQ,WAAW;IACnE,YAAY,OAA6C;QACxD,KAAK,CACJ,eAAe,OAAO,CAAC,MAAM,6BAA6B,OAAO,CAAC,QAAQ,aAAa,EACvF,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC9C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAClD,YAAY,OAA2B;QACtC,KAAK,CAAC,eAAe,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD","sourcesContent":["import type { ValueError } from \"@sinclair/typebox/errors\";\n\nexport class PluginError extends Error {\n\tpublic readonly plugin: string;\n\n\tconstructor(message: string, options: { plugin: string; cause?: Error }) {\n\t\tsuper(message);\n\t\tthis.name = \"PluginError\";\n\t\tthis.plugin = options.plugin;\n\t\tthis.cause = options.cause;\n\t}\n}\n\n/**\n * Error when a plugin cannot be imported.\n */\nexport class PluginImportError extends PluginError {\n\tconstructor(options: { plugin: string; cause: Error }) {\n\t\tsuper(\n\t\t\t`Couldn't import the plugin \"${options.plugin}\":\\n\\n${options.cause}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginImportError\";\n\t}\n}\n\nexport class PluginSettingsAreInvalidError extends PluginError {\n\tconstructor(options: { plugin: string; errors: ValueError[] }) {\n\t\tsuper(\n\t\t\t`The settings of \"${options.plugin}\" are invalid:\\n\\n${options.errors\n\t\t\t\t.map(\n\t\t\t\t\t(error) =>\n\t\t\t\t\t\t`Path \"${error.path}\" with value \"${JSON.stringify(\n\t\t\t\t\t\t\terror.value,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t)}\": \"${error.message}\"`\n\t\t\t\t)\n\t\t\t\t.join(\"\\n\")}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginSettingsAreInvalidError\";\n\t}\n}\n\n/**\n * Error when a plugin does not implement a required function\n */\nexport class PluginDoesNotImplementFunctionError extends PluginError {\n\tconstructor(options: { plugin: string; function: string }) {\n\t\tsuper(\n\t\t\t`The plugin \"${options.plugin}\" does not implement the \"${options.function}\" function.`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginDoesNotImplementFunction\";\n\t}\n}\n\n/**\n * Error when a plugin was expected to exist, but doesn't\n */\nexport class PluginMissingError extends PluginError {\n\tconstructor(options: { plugin: string }) {\n\t\tsuper(`The plugin \"${options.plugin}\" does not exist`, options);\n\t\tthis.name = \"PluginMissingError\";\n\t}\n}\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="922b0ccf-6503-5077-b1ae-ef03acdecbf1")}catch(e){}}();
3
1
  import { PluginError, PluginImportError } from "./errors.js";
4
2
  import { withCache } from "./cache.js";
5
3
  export async function importPlugins(args) {
@@ -39,5 +37,4 @@ async function fetchPlugin(uri) {
39
37
  });
40
38
  }
41
39
  }
42
- //# sourceMappingURL=importPlugins.js.map
43
- //# debugId=922b0ccf-6503-5077-b1ae-ef03acdecbf1
40
+ //# sourceMappingURL=importPlugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"importPlugins.js","sources":["plugin/importPlugins.ts"],"sourceRoot":"/","sourcesContent":["import type { Lix } from \"@lix-js/sdk\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport { PluginError, PluginImportError } from \"./errors.js\";\nimport type { InlangPlugin } from \"./schema.js\";\nimport { withCache } from \"./cache.js\";\n\n/**\n * Function that preprocesses the plugin before importing it.\n *\n * - used by sherlock to convert ESM to CJS\n */\nexport type PreprocessPluginBeforeImportFunction = (\n\tmoduleText: string\n) => Promise<string> | string;\n\nexport async function importPlugins(args: {\n\tlix: Lix;\n\tsettings: ProjectSettings;\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n}): Promise<{\n\tplugins: InlangPlugin[];\n\terrors: PluginError[];\n}> {\n\tconst plugins: InlangPlugin[] = [];\n\tconst errors: PluginError[] = [];\n\tfor (const uri of args.settings.modules ?? []) {\n\t\ttry {\n\t\t\tlet moduleAsText = await withCache(fetchPlugin, args.lix)(uri);\n\t\t\tif (args.preprocessPluginBeforeImport) {\n\t\t\t\tmoduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);\n\t\t\t}\n\t\t\tconst moduleWithMimeType =\n\t\t\t\t\"data:application/javascript,\" + encodeURIComponent(moduleAsText);\n\t\t\tconst { default: module } = await import(\n\t\t\t\t/* @vite-ignore */ moduleWithMimeType\n\t\t\t);\n\t\t\t// old legacy message lint rules are not supported\n\t\t\t// and ingored for backwards compatibility\n\t\t\tif (module.id?.includes(\"messageLintRule\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tplugins.push(module);\n\t\t} catch (e) {\n\t\t\terrors.push(new PluginImportError({ plugin: uri, cause: e as Error }));\n\t\t}\n\t}\n\treturn { plugins, errors };\n}\n\nasync function fetchPlugin(uri: string): Promise<string> {\n\ttry {\n\t\tconst response = await fetch(uri);\n\t\tre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rC,CAAC;YACF,kDAAkD;YAClD,0CAA0C;YAC1C,IAAI,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC5C,SAAS;YACV,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAU,EAAE,CAAC,CAAC,CAAC;QACxE,CAAC;IACF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAiB,CAAC;YAC3B,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,KAAc;SACrB,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["import type { Lix } from \"@lix-js/sdk\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport { PluginError, PluginImportError } from \"./errors.js\";\nimport type { InlangPlugin } from \"./schema.js\";\nimport { withCache } from \"./cache.js\";\n\n/**\n * Function that preprocesses the plugin before importing it.\n *\n * - used by sherlock to convert ESM to CJS\n */\nexport type PreprocessPluginBeforeImportFunction = (\n\tmoduleText: string\n) => Promise<string> | string;\n\nexport async function importPlugins(args: {\n\tlix: Lix;\n\tsettings: ProjectSettings;\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n}): Promise<{\n\tplugins: InlangPlugin[];\n\terrors: PluginError[];\n}> {\n\tconst plugins: InlangPlugin[] = [];\n\tconst errors: PluginError[] = [];\n\tfor (const uri of args.settings.modules ?? []) {\n\t\ttry {\n\t\t\tlet moduleAsText = await withCache(fetchPlugin, args.lix)(uri);\n\t\t\tif (args.preprocessPluginBeforeImport) {\n\t\t\t\tmoduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);\n\t\t\t}\n\t\t\tconst moduleWithMimeType =\n\t\t\t\t\"data:application/javascript,\" + encodeURIComponent(moduleAsText);\n\t\t\tconst { default: module } = await import(\n\t\t\t\t/* @vite-ignore */ moduleWithMimeType\n\t\t\t);\n\t\t\t// old legacy message lint rules are not supported\n\t\t\t// and ingored for backwards compatibility\n\t\t\tif (module.id?.includes(\"messageLintRule\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tplugins.push(module);\n\t\t} catch (e) {\n\t\t\terrors.push(new PluginImportError({ plugin: uri, cause: e as Error }));\n\t\t}\n\t}\n\treturn { plugins, errors };\n}\n\nasync function fetchPlugin(uri: string): Promise<string> {\n\ttry {\n\t\tconst response = await fetch(uri);\n\t\treturn await response.text();\n\t} catch (error) {\n\t\tthrow new PluginImportError({\n\t\t\tplugin: uri,\n\t\t\tcause: error as Error,\n\t\t});\n\t}\n}\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d56eea49-1483-5227-ae80-1f01de298ace")}catch(e){}}();
3
1
  import { test, expect, vi } from "vitest";
4
2
  import { importPlugins } from "./importPlugins.js";
5
3
  import { PluginImportError } from "./errors.js";
@@ -90,5 +88,4 @@ test("cache should work", async () => {
90
88
  expect(result.plugins).lengthOf(1);
91
89
  expect(result.plugins[0]?.key).toBe("mock");
92
90
  });
93
- //# sourceMappingURL=importPlugins.test.js.map
94
- //# debugId=d56eea49-1483-5227-ae80-1f01de298ace
91
+ //# sourceMappingURL=importPlugins.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"importPlugins.test.js","sources":["plugin/importPlugins.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { importPlugins } from \"./importPlugins.js\";\nimport { PluginImportError } from \"./errors.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\n\ntest(\"it should preprocess a plugin\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi.fn().mockResolvedValue(\"export default { key: 'mock' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t\tpreprocessPluginBeforeImport: async (moduleText) => {\n\t\t\treturn moduleText.replace(\"mock\", \"preprocessed\");\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(1);\n\texpect(result.errors.length).toBe(0);\n\texpect(result.plugins[0]?.key).toBe(\"preprocessed\");\n});\n\ntest(\"if a fetch fails, a plugin import error is expected\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t\tstatusText: \"HTTP 404\",\n\t});\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalledTimes(1);\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(1);\n\texpect(result.errors[0]).toBeInstanceOf(PluginImportError);\n});\n\ntest(\"it should filter message lint rules for legacy reasons\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi\n\t\t\t.fn()\n\t\t\t.mockResolvedValue(\"export default { id: 'messageLintRule.something' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(0);\n});\n\n// more tests are found in cache.test.ts\ntest(\"cache should work\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t});\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"export default { key: 'mock' }\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [mockModulePath],\n\t\t},\n\t});\n\n\texpect(result.errors).lengthOf(0);\n\texpect(result.plugins).lengthOf(1);\n\texpect(result.plugins[0]?.key).toBe(\"mock\");\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,IAAI,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;IAChD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QACxC,EAAE,EAAE,IAAI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AC,MAAM,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { importPlugins } from \"./importPlugins.js\";\nimport { PluginImportError } from \"./errors.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\n\ntest(\"it should preprocess a plugin\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi.fn().mockResolvedValue(\"export default { key: 'mock' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t\tpreprocessPluginBeforeImport: async (moduleText) => {\n\t\t\treturn moduleText.replace(\"mock\", \"preprocessed\");\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(1);\n\texpect(result.errors.length).toBe(0);\n\texpect(result.plugins[0]?.key).toBe(\"preprocessed\");\n});\n\ntest(\"if a fetch fails, a plugin import error is expected\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t\tstatusText: \"HTTP 404\",\n\t});\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalledTimes(1);\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(1);\n\texpect(result.errors[0]).toBeInstanceOf(PluginImportError);\n});\n\ntest(\"it should filter message lint rules for legacy reasons\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi\n\t\t\t.fn()\n\t\t\t.mockResolvedValue(\"export default { id: 'messageLintRule.something' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(0);\n});\n\n// more tests are found in cache.test.ts\ntest(\"cache should work\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t});\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"export default { key: 'mock' }\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [mockModulePath],\n\t\t},\n\t});\n\n\texpect(result.errors).lengthOf(0);\n\texpect(result.plugins).lengthOf(1);\n\texpect(result.plugins[0]?.key).toBe(\"mock\");\n});\n"]}
@@ -1,5 +1,2 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6b094482-1e1c-5a82-b9ff-edb0247348e7")}catch(e){}}();
3
1
  export {};
4
- //# sourceMappingURL=ideExtension.js.map
5
- //# debugId=6b094482-1e1c-5a82-b9ff-edb0247348e7
2
+ //# sourceMappingURL=ideExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ideExtension.js","sources":["plugin/meta/ideExtension.ts"],"sourceRoot":"/","sourcesContent":["// Basic structure for a position in the document\ninterface Position {\n\tline: number;\n\tcharacter: number;\n}\n\n// Basic structure for a message reference match\ninterface MessageReferenceMatch {\n\tbundleId: string;\n\tposition: {\n\t\tstart: Position;\n\t\tend: Position;\n\t};\n}\n\n// Main IDE extension configuration schema\ninterface IdeExtensionConfigSchema {\n\t/**\n\t * Defines matchers for message references inside the code.\n\t *\n\t * @param args - Represents the data to conduct the search on.\n\t * @returns A promise with matched message references.\n\t */\n\tmessageReferenceMatchers: Array<\n\t\t(args: { documentText: string }) => Promise<MessageReferenceMatch[]>\n\t>;\n\n\t/**\n\t * Defines options to extract messages.\n\t */\n\textractMessageOptions: Array<{\n\t\t/**\n\t\t * Function which is called when the user finishes the message extraction command.\n\t\t *\n\t\t * @param args - Contains messageId and selection.\n\t\t * @returns The code which is inserted into the document.\n\t\t */\n\t\tcallback: (args: { bundleId: string; selection: string }) => {\n\t\t\tbundleId: string;\n\t\t\tmessageReplacement: string;\n\t\t};\n\t}>;\n\n\t/**\n\t * An array of Visual Studio Code DocumentSelectors.\n\t *\n\t * The document selectors specify for which files/programming languages\n\t * (typescript, svelte, etc.) the extension should be activated.\n\t *\n\t * See https://code.visualstudio.com/api/references/document-selector\n\t */\n\tdocumentSelectors?: Array<{ language?: string }>;\n}\n\n// Export the type for external use\nexport type IdeExtensionConfig = IdeExtensionConfigSchema;\n"],"names":[],"mappings":"","debug_id":"6b094482-1e1c-5a82-b9ff-edb0247348e7"}
1
+ {"version":3,"file":"ideExtension.js","sourceRoot":"/","sources":["plugin/meta/ideExtension.ts"],"names":[],"mappings":"","sourcesContent":["// Basic structure for a position in the document\ninterface Position {\n\tline: number;\n\tcharacter: number;\n}\n\n// Basic structure for a message reference match\ninterface MessageReferenceMatch {\n\tbundleId: string;\n\tposition: {\n\t\tstart: Position;\n\t\tend: Position;\n\t};\n}\n\n// Main IDE extension configuration schema\ninterface IdeExtensionConfigSchema {\n\t/**\n\t * Defines matchers for message references inside the code.\n\t *\n\t * @param args - Represents the data to conduct the search on.\n\t * @returns A promise with matched message references.\n\t */\n\tmessageReferenceMatchers: Array<\n\t\t(args: { documentText: string }) => Promise<MessageReferenceMatch[]>\n\t>;\n\n\t/**\n\t * Defines options to extract messages.\n\t */\n\textractMessageOptions: Array<{\n\t\t/**\n\t\t * Function which is called when the user finishes the message extraction command.\n\t\t *\n\t\t * @param args - Contains messageId and selection.\n\t\t * @returns The code which is inserted into the document.\n\t\t */\n\t\tcallback: (args: { bundleId: string; selection: string }) => {\n\t\t\tbundleId: string;\n\t\t\tmessageReplacement: string;\n\t\t};\n\t}>;\n\n\t/**\n\t * An array of Visual Studio Code DocumentSelectors.\n\t *\n\t * The document selectors specify for which files/programming languages\n\t * (typescript, svelte, etc.) the extension should be activated.\n\t *\n\t * See https://code.visualstudio.com/api/references/document-selector\n\t */\n\tdocumentSelectors?: Array<{ language?: string }>;\n}\n\n// Export the type for external use\nexport type IdeExtensionConfig = IdeExtensionConfigSchema;\n"]}
@@ -1,5 +1,2 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4dbbc1bc-ac41-5301-b32c-65db7bd6cf85")}catch(e){}}();
3
1
  export {};
4
- //# sourceMappingURL=schema.js.map
5
- //# debugId=4dbbc1bc-ac41-5301-b32c-65db7bd6cf85
2
+ //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sources":["plugin/schema.ts"],"sourceRoot":"/","sourcesContent":["import type { TObject } from \"@sinclair/typebox\";\nimport type { MessageV1 } from \"../json-schema/old-v1-message/schemaV1.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type {\n\tBundle,\n\tMessage,\n\tNewBundle,\n\tNewMessage,\n\tNewVariant,\n\tVariant,\n} from \"../database/schema.js\";\nimport type { ExportFile, ImportFile } from \"../project/api.js\";\n\nexport type InlangPlugin<\n\tExternalSettings extends Record<string, any> | unknown = unknown,\n> = {\n\t/**\n\t * @deprecated Use `key` instead.\n\t */\n\tid?: string;\n\t/**\n\t * The key of the plugin.\n\t */\n\tkey: string;\n\tsettingsSchema?: TObject;\n\t/**\n\t * @deprecated Use `importFiles` instead.\n\t */\n\tloadMessages?: (args: {\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<MessageV1[]> | MessageV1[];\n\t/**\n\t * @deprecated Use `exportFiles` instead.\n\t */\n\tsaveMessages?: (args: {\n\t\tmessages: MessageV1[];\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<void> | void;\n\t/**\n\t * Files that should be imported by the inlang SDK.\n\t *\n\t * - `metadata` is optional and can be used to store additional information\n\t * that is accessible in `importFiles` via `toBeImportedMetadata`. See\n\t * https://github.com/opral/inlang-sdk/issues/218 for more info.\n\t *\n\t */\n\ttoBeImportedFiles?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<\n\t\tArray<{ path: string; locale: string; metadata?: Record<string, any> }>\n\t>;\n\timportFiles?: (args: {\n\t\tfiles: ImportFile[];\n\t\tsettings: ProjectSettings & ExternalSettings; // we expose the settings in case the importFunction needs to access the plugin config\n\t}) => MaybePromise<{\n\t\tbundles: BundleImport[];\n\t\tmessages: MessageImport[];\n\t\tvariants: VariantImport[];\n\t}>;\n\texportFiles?: (args: {\n\t\tbundles: Bundle[];\n\t\tmessages: Message[];\n\t\tvariants: Variant[];\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<Array<ExportFile>>;\n\t/**\n\t * @deprecated Use the `meta` field instead.\n\t */\n\taddCustomApi?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => Record<string, unknown>;\n\t/**\n\t * Define app-specific APIs under a `meta` field.\n\t *\n\t * @example\n\t * meta: {\n\t * \"app.inlang.ide-extension\": {\n\t * documentPaths: [\"*.json\"]\n\t * }\n\t * }\n\t */\n\tmeta?: Record<string, Record<string, unknown>>;\n};\n\n/**\n * Exposing only a subset to ease mapping of fs functions.\n *\n * https://github.com/opral/inlang-sdk/issues/136\n */\nexport type NodeFsPromisesSubsetLegacy = {\n\treadFile:\n\t\t| ((path: string) => Promise<ArrayBuffer>)\n\t\t| ((path: string, options?: { encoding: \"utf-8\" }) => Promise<string>);\n\treaddir: (path: string) => Promise<string[]>;\n\twriteFile: (path: string, data: ArrayBuffer | string) => Promise<void>;\n\tmkdir: (path: string) => Promise<void>;\n};\n\n/**\n * A to be imported bundle.\n */\nexport type BundleImport = NewBundle;\n\n/**\n * A to be imported message.\n *\n * The `id` property is omitted because it is generated by the SDK.\n */\nexport type MessageImport = Omit<NewMessage, \"id\"> & {\n\t/**\n\t * If the id is not provided, the SDK will generate one.\n\t */\n\tid?: string;\n};\n\n/**\n * A to be imported variant.\n *\n * - The `id` and `messageId` properties are omitted because they are generated by the SDK.\n * - The `bundleId` and `locale` properties are added to the import variant to match the variant\n * with a message.\n */\nexport type VariantImport =\n\t| (NewVariant & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale?: undefined;\n\t })\n\t| (Omit<NewVariant, \"id\" | \"messageId\"> & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid?: undefined;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale: string;\n\t });\n\ntype MaybePromise<T> = T | Promise<T>;\n"],"names":[],"mappings":"","debug_id":"4dbbc1bc-ac41-5301-b32c-65db7bd6cf85"}
1
+ {"version":3,"file":"schema.js","sourceRoot":"/","sources":["plugin/schema.ts"],"names":[],"mappings":"","sourcesContent":["import type { TObject } from \"@sinclair/typebox\";\nimport type { MessageV1 } from \"../json-schema/old-v1-message/schemaV1.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type {\n\tBundle,\n\tMessage,\n\tNewBundle,\n\tNewMessage,\n\tNewVariant,\n\tVariant,\n} from \"../database/schema.js\";\nimport type { ExportFile, ImportFile } from \"../project/api.js\";\n\nexport type InlangPlugin<\n\tExternalSettings extends Record<string, any> | unknown = unknown,\n> = {\n\t/**\n\t * @deprecated Use `key` instead.\n\t */\n\tid?: string;\n\t/**\n\t * The key of the plugin.\n\t */\n\tkey: string;\n\tsettingsSchema?: TObject;\n\t/**\n\t * @deprecated Use `importFiles` instead.\n\t */\n\tloadMessages?: (args: {\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<MessageV1[]> | MessageV1[];\n\t/**\n\t * @deprecated Use `exportFiles` instead.\n\t */\n\tsaveMessages?: (args: {\n\t\tmessages: MessageV1[];\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<void> | void;\n\t/**\n\t * Files that should be imported by the inlang SDK.\n\t *\n\t * - `metadata` is optional and can be used to store additional information\n\t * that is accessible in `importFiles` via `toBeImportedMetadata`. See\n\t * https://github.com/opral/inlang-sdk/issues/218 for more info.\n\t *\n\t */\n\ttoBeImportedFiles?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<\n\t\tArray<{ path: string; locale: string; metadata?: Record<string, any> }>\n\t>;\n\timportFiles?: (args: {\n\t\tfiles: ImportFile[];\n\t\tsettings: ProjectSettings & ExternalSettings; // we expose the settings in case the importFunction needs to access the plugin config\n\t}) => MaybePromise<{\n\t\tbundles: BundleImport[];\n\t\tmessages: MessageImport[];\n\t\tvariants: VariantImport[];\n\t}>;\n\texportFiles?: (args: {\n\t\tbundles: Bundle[];\n\t\tmessages: Message[];\n\t\tvariants: Variant[];\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<Array<ExportFile>>;\n\t/**\n\t * @deprecated Use the `meta` field instead.\n\t */\n\taddCustomApi?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => Record<string, unknown>;\n\t/**\n\t * Define app-specific APIs under a `meta` field.\n\t *\n\t * @example\n\t * meta: {\n\t * \"app.inlang.ide-extension\": {\n\t * documentPaths: [\"*.json\"]\n\t * }\n\t * }\n\t */\n\tmeta?: Record<string, Record<string, unknown>>;\n};\n\n/**\n * Exposing only a subset to ease mapping of fs functions.\n *\n * https://github.com/opral/inlang-sdk/issues/136\n */\nexport type NodeFsPromisesSubsetLegacy = {\n\treadFile:\n\t\t| ((path: string) => Promise<ArrayBuffer>)\n\t\t| ((path: string, options?: { encoding: \"utf-8\" }) => Promise<string>);\n\treaddir: (path: string) => Promise<string[]>;\n\twriteFile: (path: string, data: ArrayBuffer | string) => Promise<void>;\n\tmkdir: (path: string) => Promise<void>;\n};\n\n/**\n * A to be imported bundle.\n */\nexport type BundleImport = NewBundle;\n\n/**\n * A to be imported message.\n *\n * The `id` property is omitted because it is generated by the SDK.\n */\nexport type MessageImport = Omit<NewMessage, \"id\"> & {\n\t/**\n\t * If the id is not provided, the SDK will generate one.\n\t */\n\tid?: string;\n};\n\n/**\n * A to be imported variant.\n *\n * - The `id` and `messageId` properties are omitted because they are generated by the SDK.\n * - The `bundleId` and `locale` properties are added to the import variant to match the variant\n * with a message.\n */\nexport type VariantImport =\n\t| (NewVariant & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale?: undefined;\n\t })\n\t| (Omit<NewVariant, \"id\" | \"messageId\"> & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid?: undefined;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale: string;\n\t });\n\ntype MaybePromise<T> = T | Promise<T>;\n"]}
@@ -1,5 +1,2 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b543d2d-4604-5a02-a455-7740240ab059")}catch(e){}}();
3
1
  export {};
4
- //# sourceMappingURL=api.js.map
5
- //# debugId=8b543d2d-4604-5a02-a455-7740240ab059
2
+ //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["project/api.ts"],"sourceRoot":"/","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type { InlangDatabaseSchema } from \"../database/schema.js\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type { Lix } from \"@lix-js/sdk\";\nimport type { SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\n\nexport type InlangProject = {\n\tdb: Kysely<InlangDatabaseSchema>;\n\t/**\n\t * @deprecated Don't use this. Only an internal hack to unblock\n\t * fink v2.\n\t *\n\t * TODO remove this\n\t */\n\t_sqlite: SqliteWasmDatabase;\n\tid: {\n\t\tget: () => Promise<string>;\n\t};\n\tplugins: {\n\t\tget: () => Promise<readonly InlangPlugin[]>;\n\t};\n\terrors: {\n\t\tget: () => Promise<readonly Error[]>;\n\t};\n\tsettings: {\n\t\tget: () => Promise<ProjectSettings>;\n\t\tset: (settings: ProjectSettings) => Promise<void>;\n\t};\n\tlix: Lix;\n\timportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t\tfiles: ImportFile[];\n\t}) => Promise<void>;\n\texportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t}) => Promise<ExportFile[]>;\n\tclose: () => Promise<void>;\n\ttoBlob: () => Promise<Blob>;\n};\n\nexport type ImportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n\t/**\n\t * The metadata of the file to be imported.\n\t *\n\t * Used to store additional information that is accessible in `importFiles` via `toBeImportedFilesMetadata`.\n\t * https://github.com/opral/inlang-sdk/issues/218\n\t */\n\ttoBeImportedFilesMetadata?: Record<string, any>;\n};\n\nexport type ExportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/**\n\t * The name of the file.\n\t *\n\t * @example\n\t * \"en.json\"\n\t * \"common-de.json\"\n\t *\n\t */\n\tname: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n};\n\n/**\n * Minimal RxJS compatible (generic) subscription type.\n */\nexport type Subscription<T> = (callback: (value: T) => void) => {\n\tunsubscribe: () => void;\n};\n"],"names":[],"mappings":"","debug_id":"8b543d2d-4604-5a02-a455-7740240ab059"}
1
+ {"version":3,"file":"api.js","sourceRoot":"/","sources":["project/api.ts"],"names":[],"mappings":"","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type { InlangDatabaseSchema } from \"../database/schema.js\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type { Lix } from \"@lix-js/sdk\";\nimport type { SqliteWasmDatabase } from \"sqlite-wasm-kysely\";\n\nexport type InlangProject = {\n\tdb: Kysely<InlangDatabaseSchema>;\n\t/**\n\t * @deprecated Don't use this. Only an internal hack to unblock\n\t * fink v2.\n\t *\n\t * TODO remove this\n\t */\n\t_sqlite: SqliteWasmDatabase;\n\tid: {\n\t\tget: () => Promise<string>;\n\t};\n\tplugins: {\n\t\tget: () => Promise<readonly InlangPlugin[]>;\n\t};\n\terrors: {\n\t\tget: () => Promise<readonly Error[]>;\n\t};\n\tsettings: {\n\t\tget: () => Promise<ProjectSettings>;\n\t\tset: (settings: ProjectSettings) => Promise<void>;\n\t};\n\tlix: Lix;\n\timportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t\tfiles: ImportFile[];\n\t}) => Promise<void>;\n\texportFiles: (args: {\n\t\tpluginKey: InlangPlugin[\"key\"];\n\t}) => Promise<ExportFile[]>;\n\tclose: () => Promise<void>;\n\ttoBlob: () => Promise<Blob>;\n};\n\nexport type ImportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n\t/**\n\t * The metadata of the file to be imported.\n\t *\n\t * Used to store additional information that is accessible in `importFiles` via `toBeImportedFilesMetadata`.\n\t * https://github.com/opral/inlang-sdk/issues/218\n\t */\n\ttoBeImportedFilesMetadata?: Record<string, any>;\n};\n\nexport type ExportFile = {\n\t/** The locale of the resource file */\n\tlocale: string;\n\t/**\n\t * The name of the file.\n\t *\n\t * @example\n\t * \"en.json\"\n\t * \"common-de.json\"\n\t *\n\t */\n\tname: string;\n\t/** The binary content of the resource */\n\tcontent: Uint8Array;\n};\n\n/**\n * Minimal RxJS compatible (generic) subscription type.\n */\nexport type Subscription<T> = (callback: (value: T) => void) => {\n\tunsubscribe: () => void;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"loadProject.d.ts","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEN,KAAK,oCAAoC,EACzC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQ9C;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC;;;;;;;;;;;OAWG;IACH,4BAA4B,CAAC,EAAE,oCAAoC,CAAC;IACpE;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAmJzB"}
1
+ {"version":3,"file":"loadProject.d.ts","sourceRoot":"/","sources":["project/loadProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEN,KAAK,oCAAoC,EACzC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO9C;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC;;;;;;;;;;;OAWG;IACH,4BAA4B,CAAC,EAAE,oCAAoC,CAAC;IACpE;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAiJzB"}
@@ -1,12 +1,9 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="92ebad4d-e869-5c7c-88e4-2a6561f4a358")}catch(e){}}();
3
1
  import { toBlob } from "@lix-js/sdk";
4
2
  import { contentFromDatabase, } from "sqlite-wasm-kysely";
5
3
  import { initDb } from "../database/initDb.js";
6
4
  import { importPlugins, } from "../plugin/importPlugins.js";
7
5
  import { withLanguageTagToLocaleMigration } from "../migrations/v2/withLanguageTagToLocaleMigration.js";
8
6
  import { v4 } from "uuid";
9
- import { initErrorReporting } from "../services/error-reporting/index.js";
10
7
  import { maybeCaptureLoadedProject } from "./maybeCaptureTelemetry.js";
11
8
  import { importFiles } from "../import-export/importFiles.js";
12
9
  import { exportFiles } from "../import-export/exportFiles.js";
@@ -47,7 +44,6 @@ export async function loadProject(args) {
47
44
  lix: args.lix,
48
45
  appId: args.appId,
49
46
  });
50
- initErrorReporting({ projectId: id });
51
47
  return {
52
48
  db,
53
49
  id: {
@@ -162,5 +158,4 @@ async function maybeMigrateFirstProjectId(args) {
162
158
  .execute();
163
159
  }
164
160
  }
165
- //# sourceMappingURL=loadProject.js.map
166
- //# debugId=92ebad4d-e869-5c7c-88e4-2a6561f4a358
161
+ //# sourceMappingURL=loadProject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadProject.js","sources":["project/loadProject.ts"],"sourceRoot":"/","sourcesContent":["import { toBlob, type Account, type Lix } from \"@lix-js/sdk\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport {\n\tcontentFromDatabase,\n\ttype SqliteWasmDatabase,\n} from \"sqlite-wasm-kysely\";\nimport { initDb } from \"../database/initDb.js\";\nimport {\n\timportPlugins,\n\ttype PreprocessPluginBeforeImportFunction,\n} from \"../plugin/importPlugins.js\";\nimport type { InlangProject } from \"./api.js\";\nimport { withLanguageTagToLocaleMigration } from \"../migrations/v2/withLanguageTagToLocaleMigration.js\";\nimport { v4 } from \"uuid\";\nimport { initErrorReporting } from \"../services/error-reporting/index.js\";\nimport { maybeCaptureLoadedProject } from \"./maybeCaptureTelemetry.js\";\nimport { importFiles } from \"../import-export/importFiles.js\";\nimport { exportFiles } from \"../import-export/exportFiles.js\";\n\n/**\n * Common load project logic.\n */\nexport async function loadProject(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n\t/**\n\t * The account that loaded the project.\n\t *\n\t * Defaults to an anonymous/new account if undefined.\n\t *\n\t * @example\n\t * const account = localStorage.getItem(\"account\")\n\t * const project = await loadProject({ account })\n\t */\n\taccount?: Account;\n\t/**\n\t * Provide plugins to the project.\n\t *\n\t * This is useful for testing or providing plugins that are\n\t * app specific. Keep in mind that provided plugins\n\t * are not shared with other instances.\n\t */\n\tprovidePlugins?: InlangPlugin[];\n\t/**\n\t * Function that preprocesses the plugin before importing it.\n\t *\n\t * The callback can be used to process plugins as needed in the\n\t * environment of the app. For example, Sherlock uses this to convert\n\t * ESM, which all inlang plugins are written in, to CJS which Sherlock\n\t * runs in.\n\t *\n\t * @example\n\t * const project = await loadProject({ preprocessPluginBeforeImport: (moduleText) => convertEsmToCjs(moduleText) })\n\t *\n\t */\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n\t/**\n\t * The id of the app that is using the SDK.\n\t *\n\t * The is used for telemetry purposes. To derive insights like\n\t * which app is using the SDK, how many projects are loaded, etc.\n\t *\n\t * The app id can be removed at any time in the future\n\t */\n\tappId?: string;\n}): Promise<InlangProject> {\n\tconst db = initDb({ sqlite: args.sqlite });\n\n\tawait maybeMigrateFirstProjectId({ lix: args.lix });\n\n\tconst settingsFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst settings = withLanguageTagToLocaleMigration(\n\t\tJSON.parse(new TextDecoder().decode(settingsFile.data)) as ProjectSettings\n\t);\n\n\tconst importedPlugins = await importPlugins({\n\t\tsettings,\n\t\tlix: args.lix,\n\t\tpreprocessPluginBeforeImport: args.preprocessPluginBeforeImport,\n\t});\n\n\tconst plugins = [...(args.providePlugins ?? []), ...importedPlugins.plugins];\n\n\tconst idFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.select(\"data\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst id = new TextDecoder().decode(idFile.data);\n\n\t// const state = createProjectState({\n\t// \t...args,\n\t// \tsettings,\n\t// });\n\n\t// not awaiting to not block the load time of a project\n\tmaybeCaptureLoadedProject({\n\t\tdb,\n\t\tid,\n\t\tsettings,\n\t\tplugins,\n\t\tlix: args.lix,\n\t\tappId: args.appId,\n\t});\n\n\tinitErrorReporting({ projectId: id });\n\n\treturn {\n\t\tdb,\n\t\tid: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn new TextDecoder().decode(file.data);\n\t\t\t},\n\t\t},\n\t\tsettings: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn withLanguageTagToLocaleMigration(\n\t\t\t\t\tJSON.parse(new TextDecoder().decode(file.data))\n\t\t\t\t);\n\t\t\t},\n\t\t\tset: async (newSettings) => {\n\t\t\t\tconst cloned = JSON.parse(JSON.stringify(newSettings));\n\t\t\t\tcloned.languageTags = cloned.locales;\n\t\t\t\tcloned.sourceLanguageTag = cloned.baseLocale;\n\n\t\t\t\tawait args.lix.db\n\t\t\t\t\t.updateTable(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.set({\n\t\t\t\t\t\tdata: new TextEncoder().encode(\n\t\t\t\t\t\t\tJSON.stringify(cloned, undefined, 2)\n\t\t\t\t\t\t),\n\t\t\t\t\t})\n\t\t\t\t\t.execute();\n\t\t\t},\n\t\t},\n\t\tplugins: {\n\t\t\tget: async () => plugins,\n\t\t},\n\t\terrors: {\n\t\t\tget: async () => [...importedPlugins.errors],\n\t\t},\n\t\t// errors: state.errors,\n\t\timportFiles: async ({ files, pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn await importFiles({\n\t\t\t\tfiles,\n\t\t\t\tpluginKey,\n\t\t\t\tsettings,\n\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\tplugins,\n\t\t\t\tdb,\n\t\t\t});\n\t\t},\n\t\texportFiles: async ({ pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn (\n\t\t\t\tawait exportFiles({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tdb,\n\t\t\t\t\tsettings,\n\t\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\t\tplugins,\n\t\t\t\t})\n\t\t\t).map((output) => ({ ...output, pluginKey }));\n\t\t},\n\t\tclose: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\tawait db.destroy();\n\t\t\tawait args.lix.db.destroy();\n\t\t},\n\t\t_sqlite: args.sqlite,\n\t\ttoBlob: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\treturn await toBlob({ lix: args.lix });\n\t\t},\n\t\tlix: args.lix,\n\t};\n}\n\nasync function saveDbToLix(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n}): Promise<void> {\n\tconst data = contentFromDatabase(args.sqlite);\n\tawait args.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set(\"data\", data)\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n}\n\n/**\n * Old leftover migration from v1. Probably not needed anymore.\n *\n * Kept it in just in case.\n */\nasync function maybeMigrateFirstProjectId(args: { lix: Lix }): Promise<void> {\n\tconst firstProjectIdFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.executeTakeFirst();\n\n\tif (!firstProjectIdFile) {\n\t\tawait args.lix.db\n\t\t\t.insertInto(\"file\")\n\t\t\t.values({\n\t\t\t\tpath: \"/project_id\",\n\t\t\t\tdata: new TextEncoder().encode(v4()),\n\t\t\t})\n\t\t\t.execute();\n\t}\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,aAAa,CAAC;AAG7D,OAAO,EACN,mBAAmB,GAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACN,aAAa,GAEb,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IA2CjC;IACA,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAE3C,MAAM,0BAA0B,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;SACpC,UAAU,CAAC,MAAM,CAAC;SAClB,MAAM,CAAC,MAAM,CAAC;SACd,KAAK,CAAC,MAAM,EAAE,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CAAC,kBAAkB,EAAE,CAAC;QACzB,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;aACf,UAAU,CAAC,MAAM,CAAC;aAClB,MAAM,CAAC;YACP,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;SACpC,CAAC;aACD,OAAO,EAAE,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["import { toBlob, type Account, type Lix } from \"@lix-js/sdk\";\nimport type { InlangPlugin } from \"../plugin/schema.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport {\n\tcontentFromDatabase,\n\ttype SqliteWasmDatabase,\n} from \"sqlite-wasm-kysely\";\nimport { initDb } from \"../database/initDb.js\";\nimport {\n\timportPlugins,\n\ttype PreprocessPluginBeforeImportFunction,\n} from \"../plugin/importPlugins.js\";\nimport type { InlangProject } from \"./api.js\";\nimport { withLanguageTagToLocaleMigration } from \"../migrations/v2/withLanguageTagToLocaleMigration.js\";\nimport { v4 } from \"uuid\";\nimport { maybeCaptureLoadedProject } from \"./maybeCaptureTelemetry.js\";\nimport { importFiles } from \"../import-export/importFiles.js\";\nimport { exportFiles } from \"../import-export/exportFiles.js\";\n\n/**\n * Common load project logic.\n */\nexport async function loadProject(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n\t/**\n\t * The account that loaded the project.\n\t *\n\t * Defaults to an anonymous/new account if undefined.\n\t *\n\t * @example\n\t * const account = localStorage.getItem(\"account\")\n\t * const project = await loadProject({ account })\n\t */\n\taccount?: Account;\n\t/**\n\t * Provide plugins to the project.\n\t *\n\t * This is useful for testing or providing plugins that are\n\t * app specific. Keep in mind that provided plugins\n\t * are not shared with other instances.\n\t */\n\tprovidePlugins?: InlangPlugin[];\n\t/**\n\t * Function that preprocesses the plugin before importing it.\n\t *\n\t * The callback can be used to process plugins as needed in the\n\t * environment of the app. For example, Sherlock uses this to convert\n\t * ESM, which all inlang plugins are written in, to CJS which Sherlock\n\t * runs in.\n\t *\n\t * @example\n\t * const project = await loadProject({ preprocessPluginBeforeImport: (moduleText) => convertEsmToCjs(moduleText) })\n\t *\n\t */\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n\t/**\n\t * The id of the app that is using the SDK.\n\t *\n\t * The is used for telemetry purposes. To derive insights like\n\t * which app is using the SDK, how many projects are loaded, etc.\n\t *\n\t * The app id can be removed at any time in the future\n\t */\n\tappId?: string;\n}): Promise<InlangProject> {\n\tconst db = initDb({ sqlite: args.sqlite });\n\n\tawait maybeMigrateFirstProjectId({ lix: args.lix });\n\n\tconst settingsFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst settings = withLanguageTagToLocaleMigration(\n\t\tJSON.parse(new TextDecoder().decode(settingsFile.data)) as ProjectSettings\n\t);\n\n\tconst importedPlugins = await importPlugins({\n\t\tsettings,\n\t\tlix: args.lix,\n\t\tpreprocessPluginBeforeImport: args.preprocessPluginBeforeImport,\n\t});\n\n\tconst plugins = [...(args.providePlugins ?? []), ...importedPlugins.plugins];\n\n\tconst idFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.select(\"data\")\n\t\t.executeTakeFirstOrThrow();\n\n\tconst id = new TextDecoder().decode(idFile.data);\n\n\t// const state = createProjectState({\n\t// \t...args,\n\t// \tsettings,\n\t// });\n\n\t// not awaiting to not block the load time of a project\n\tmaybeCaptureLoadedProject({\n\t\tdb,\n\t\tid,\n\t\tsettings,\n\t\tplugins,\n\t\tlix: args.lix,\n\t\tappId: args.appId,\n\t});\n\n\treturn {\n\t\tdb,\n\t\tid: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn new TextDecoder().decode(file.data);\n\t\t\t},\n\t\t},\n\t\tsettings: {\n\t\t\tget: async () => {\n\t\t\t\tconst file = await args.lix.db\n\t\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.select(\"file.data\")\n\t\t\t\t\t.executeTakeFirstOrThrow();\n\t\t\t\treturn withLanguageTagToLocaleMigration(\n\t\t\t\t\tJSON.parse(new TextDecoder().decode(file.data))\n\t\t\t\t);\n\t\t\t},\n\t\t\tset: async (newSettings) => {\n\t\t\t\tconst cloned = JSON.parse(JSON.stringify(newSettings));\n\t\t\t\tcloned.languageTags = cloned.locales;\n\t\t\t\tcloned.sourceLanguageTag = cloned.baseLocale;\n\n\t\t\t\tawait args.lix.db\n\t\t\t\t\t.updateTable(\"file\")\n\t\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t\t.set({\n\t\t\t\t\t\tdata: new TextEncoder().encode(\n\t\t\t\t\t\t\tJSON.stringify(cloned, undefined, 2)\n\t\t\t\t\t\t),\n\t\t\t\t\t})\n\t\t\t\t\t.execute();\n\t\t\t},\n\t\t},\n\t\tplugins: {\n\t\t\tget: async () => plugins,\n\t\t},\n\t\terrors: {\n\t\t\tget: async () => [...importedPlugins.errors],\n\t\t},\n\t\t// errors: state.errors,\n\t\timportFiles: async ({ files, pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn await importFiles({\n\t\t\t\tfiles,\n\t\t\t\tpluginKey,\n\t\t\t\tsettings,\n\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\tplugins,\n\t\t\t\tdb,\n\t\t\t});\n\t\t},\n\t\texportFiles: async ({ pluginKey }) => {\n\t\t\tconst settingsFile = await args.lix.db\n\t\t\t\t.selectFrom(\"file\")\n\t\t\t\t.where(\"path\", \"=\", \"/settings.json\")\n\t\t\t\t.select(\"file.data\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tconst settings = JSON.parse(\n\t\t\t\tnew TextDecoder().decode(settingsFile.data)\n\t\t\t) as ProjectSettings;\n\n\t\t\treturn (\n\t\t\t\tawait exportFiles({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tdb,\n\t\t\t\t\tsettings,\n\t\t\t\t\t// TODO don't use global state, might be stale\n\t\t\t\t\tplugins,\n\t\t\t\t})\n\t\t\t).map((output) => ({ ...output, pluginKey }));\n\t\t},\n\t\tclose: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\tawait db.destroy();\n\t\t\tawait args.lix.db.destroy();\n\t\t},\n\t\t_sqlite: args.sqlite,\n\t\ttoBlob: async () => {\n\t\t\tawait saveDbToLix({ sqlite: args.sqlite, lix: args.lix });\n\t\t\treturn await toBlob({ lix: args.lix });\n\t\t},\n\t\tlix: args.lix,\n\t};\n}\n\nasync function saveDbToLix(args: {\n\tsqlite: SqliteWasmDatabase;\n\tlix: Lix;\n}): Promise<void> {\n\tconst data = contentFromDatabase(args.sqlite);\n\tawait args.lix.db\n\t\t.updateTable(\"file\")\n\t\t.set(\"data\", data)\n\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t.execute();\n}\n\n/**\n * Old leftover migration from v1. Probably not needed anymore.\n *\n * Kept it in just in case.\n */\nasync function maybeMigrateFirstProjectId(args: { lix: Lix }): Promise<void> {\n\tconst firstProjectIdFile = await args.lix.db\n\t\t.selectFrom(\"file\")\n\t\t.select(\"data\")\n\t\t.where(\"path\", \"=\", \"/project_id\")\n\t\t.executeTakeFirst();\n\n\tif (!firstProjectIdFile) {\n\t\tawait args.lix.db\n\t\t\t.insertInto(\"file\")\n\t\t\t.values({\n\t\t\t\tpath: \"/project_id\",\n\t\t\t\tdata: new TextEncoder().encode(v4()),\n\t\t\t})\n\t\t\t.execute();\n\t}\n}\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d1aa7d55-973a-5652-b6c6-b87ef78216ef")}catch(e){}}();
3
1
  import { expect, test } from "vitest";
4
2
  import { newProject } from "./newProject.js";
5
3
  import { loadProjectInMemory } from "./loadProjectInMemory.js";
@@ -142,5 +140,4 @@ test("closing a project should not lead to a throw", async () => {
142
140
  // capture async throws
143
141
  await new Promise((resolve) => setTimeout(resolve, 250));
144
142
  });
145
- //# sourceMappingURL=loadProject.test.js.map
146
- //# debugId=d1aa7d55-973a-5652-b6c6-b87ef78216ef
143
+ //# sourceMappingURL=loadProject.test.js.map