mage-obsidian 1.1.2 → 2.1.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 (180) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -0
  3. package/dist/cli/buildThemes.d.ts +3 -0
  4. package/dist/cli/buildThemes.d.ts.map +1 -0
  5. package/dist/cli/buildThemes.js +219 -0
  6. package/dist/cli/buildThemes.js.map +1 -0
  7. package/dist/config/default.d.ts +16 -0
  8. package/dist/config/default.d.ts.map +1 -0
  9. package/dist/config/default.js +22 -0
  10. package/dist/config/default.js.map +1 -0
  11. package/dist/config/eslint.js +60 -0
  12. package/dist/core/configResolver.d.ts +38 -0
  13. package/dist/core/configResolver.d.ts.map +1 -0
  14. package/dist/core/configResolver.js +102 -0
  15. package/dist/core/configResolver.js.map +1 -0
  16. package/dist/core/contractValidator.d.ts +16 -0
  17. package/dist/core/contractValidator.d.ts.map +1 -0
  18. package/dist/core/contractValidator.js +49 -0
  19. package/dist/core/contractValidator.js.map +1 -0
  20. package/dist/core/cssResolver.d.ts +5 -0
  21. package/dist/core/cssResolver.d.ts.map +1 -0
  22. package/dist/core/cssResolver.js +126 -0
  23. package/dist/core/cssResolver.js.map +1 -0
  24. package/dist/core/generateInterceptors.d.ts +10 -0
  25. package/dist/core/generateInterceptors.d.ts.map +1 -0
  26. package/{src/service → dist/core}/generateInterceptors.js +72 -93
  27. package/dist/core/generateInterceptors.js.map +1 -0
  28. package/dist/core/generateJsconfig.d.ts +45 -0
  29. package/dist/core/generateJsconfig.d.ts.map +1 -0
  30. package/dist/core/generateJsconfig.js +145 -0
  31. package/dist/core/generateJsconfig.js.map +1 -0
  32. package/dist/core/moduleResolver.d.ts +22 -0
  33. package/dist/core/moduleResolver.d.ts.map +1 -0
  34. package/dist/core/moduleResolver.js +177 -0
  35. package/dist/core/moduleResolver.js.map +1 -0
  36. package/dist/core/preCompileFiles.d.ts +6 -0
  37. package/dist/core/preCompileFiles.d.ts.map +1 -0
  38. package/dist/core/preCompileFiles.js +79 -0
  39. package/dist/core/preCompileFiles.js.map +1 -0
  40. package/dist/core/preCompileMagentoFiles.d.ts +3 -0
  41. package/dist/core/preCompileMagentoFiles.d.ts.map +1 -0
  42. package/dist/core/preCompileMagentoFiles.js +28 -0
  43. package/dist/core/preCompileMagentoFiles.js.map +1 -0
  44. package/dist/core/themeResolverSync.d.ts +6 -0
  45. package/dist/core/themeResolverSync.d.ts.map +1 -0
  46. package/dist/core/themeResolverSync.js +65 -0
  47. package/dist/core/themeResolverSync.js.map +1 -0
  48. package/dist/runtime/i18nCore.d.ts +55 -0
  49. package/dist/runtime/i18nCore.d.ts.map +1 -0
  50. package/dist/runtime/i18nCore.js +77 -0
  51. package/dist/runtime/i18nCore.js.map +1 -0
  52. package/dist/runtime/interceptorManager.d.ts +45 -0
  53. package/dist/runtime/interceptorManager.d.ts.map +1 -0
  54. package/{src/service → dist/runtime}/interceptorManager.js +43 -52
  55. package/dist/runtime/interceptorManager.js.map +1 -0
  56. package/dist/runtime/islands.d.ts +45 -0
  57. package/dist/runtime/islands.d.ts.map +1 -0
  58. package/dist/runtime/islands.js +59 -0
  59. package/dist/runtime/islands.js.map +1 -0
  60. package/dist/runtime/sectionStoreCore.d.ts +108 -0
  61. package/dist/runtime/sectionStoreCore.d.ts.map +1 -0
  62. package/dist/runtime/sectionStoreCore.js +189 -0
  63. package/dist/runtime/sectionStoreCore.js.map +1 -0
  64. package/dist/utils/findComponents.d.ts +17 -0
  65. package/dist/utils/findComponents.d.ts.map +1 -0
  66. package/dist/utils/findComponents.js +66 -0
  67. package/dist/utils/findComponents.js.map +1 -0
  68. package/dist/utils/runWithConcurrency.d.ts +10 -0
  69. package/dist/utils/runWithConcurrency.d.ts.map +1 -0
  70. package/dist/utils/runWithConcurrency.js +29 -0
  71. package/dist/utils/runWithConcurrency.js.map +1 -0
  72. package/dist/vite/defaultNodeResolver.d.ts +9 -0
  73. package/dist/vite/defaultNodeResolver.d.ts.map +1 -0
  74. package/dist/vite/defaultNodeResolver.js +19 -0
  75. package/dist/vite/defaultNodeResolver.js.map +1 -0
  76. package/dist/vite/inheritAssetsModuleResolver.d.ts +8 -0
  77. package/dist/vite/inheritAssetsModuleResolver.d.ts.map +1 -0
  78. package/{src/service → dist/vite}/inheritAssetsModuleResolver.js +10 -20
  79. package/dist/vite/inheritAssetsModuleResolver.js.map +1 -0
  80. package/dist/vite/inheritModuleResolver.d.ts +8 -0
  81. package/dist/vite/inheritModuleResolver.d.ts.map +1 -0
  82. package/{src/service → dist/vite}/inheritModuleResolver.js +8 -17
  83. package/dist/vite/inheritModuleResolver.js.map +1 -0
  84. package/dist/vite/interceptorsPlugin.d.ts +10 -0
  85. package/dist/vite/interceptorsPlugin.d.ts.map +1 -0
  86. package/{src/service → dist/vite}/interceptorsPlugin.js +17 -28
  87. package/dist/vite/interceptorsPlugin.js.map +1 -0
  88. package/dist/vite/magentoHrmRewrite.d.ts +6 -0
  89. package/dist/vite/magentoHrmRewrite.d.ts.map +1 -0
  90. package/dist/vite/magentoHrmRewrite.js +45 -0
  91. package/dist/vite/magentoHrmRewrite.js.map +1 -0
  92. package/dist/vite/sharedPlugins.d.ts +35 -0
  93. package/dist/vite/sharedPlugins.d.ts.map +1 -0
  94. package/dist/vite/sharedPlugins.js +52 -0
  95. package/dist/vite/sharedPlugins.js.map +1 -0
  96. package/dist/vite/themeSourceWatcher.d.ts +16 -0
  97. package/dist/vite/themeSourceWatcher.d.ts.map +1 -0
  98. package/dist/vite/themeSourceWatcher.js +91 -0
  99. package/dist/vite/themeSourceWatcher.js.map +1 -0
  100. package/dist/vite/unresolvedModuleGuard.d.ts +17 -0
  101. package/dist/vite/unresolvedModuleGuard.d.ts.map +1 -0
  102. package/dist/vite/unresolvedModuleGuard.js +87 -0
  103. package/dist/vite/unresolvedModuleGuard.js.map +1 -0
  104. package/package.json +89 -13
  105. package/.github/workflows/publish.yml +0 -35
  106. package/jest.config.js +0 -5
  107. package/src/__tests__/__mocks__/configResolver.js +0 -35
  108. package/src/__tests__/fixtures/interceptors/emptyTarget.js +0 -2
  109. package/src/__tests__/fixtures/interceptors/pluginForNonFunction.js +0 -7
  110. package/src/__tests__/fixtures/interceptors/pluginModule.js +0 -13
  111. package/src/__tests__/fixtures/interceptors/targetModule.js +0 -12
  112. package/src/__tests__/fixtures/interceptors/targetNonFunction.js +0 -7
  113. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/components/ComponentA.vue +0 -0
  114. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/components/ComponentB.vue +0 -0
  115. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/css/module.extend.css +0 -0
  116. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/js/main.js +0 -0
  117. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/main.js +0 -0
  118. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/module.config.js +0 -9
  119. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/components/ComponentA.vue +0 -0
  120. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/components/ComponentB.vue +0 -0
  121. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/css/module.extend.css +0 -2
  122. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/js/main.js +0 -0
  123. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/module.config.js +0 -7
  124. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/components/ComponentA.vue +0 -0
  125. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/components/ComponentB.vue +0 -0
  126. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/css/module.extend.css +0 -2
  127. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/js/main.js +0 -0
  128. package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/module.config.js +0 -7
  129. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/components/ComponentA.vue +0 -0
  130. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/components/ComponentB.vue +0 -0
  131. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/css/module.extend.css +0 -0
  132. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/js/main.js +0 -0
  133. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/module.config.js +0 -2
  134. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/components/ComponentA.vue +0 -0
  135. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/components/ComponentB.vue +0 -0
  136. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/css/module.extend.css +0 -0
  137. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/js/main.js +0 -0
  138. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/module.config.js +0 -2
  139. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/components/ComponentA.vue +0 -0
  140. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/components/ComponentB.vue +0 -0
  141. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/css/module.extend.css +0 -0
  142. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/js/main.js +0 -0
  143. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/module.config.js +0 -2
  144. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/components/ComponentA.vue +0 -0
  145. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/components/ComponentB.vue +0 -0
  146. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/css/theme.source.css +0 -6
  147. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/js/main.js +0 -0
  148. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/theme.config.js +0 -5
  149. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-b/web/css/theme.source.css +0 -6
  150. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-b/web/theme.config.js +0 -5
  151. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/components/ComponentA.vue +0 -0
  152. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/components/ComponentB.vue +0 -0
  153. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/css/module.extend.css +0 -0
  154. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/js/main.js +0 -0
  155. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/module.config.js +0 -2
  156. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/web/css/theme.source.css +0 -6
  157. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/web/theme.config.js +0 -2
  158. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-d/web/css/theme.source.css +0 -6
  159. package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-d/web/theme.config.js +0 -3
  160. package/src/__tests__/magento_scenarios/app/etc/mage_obsidian_frontend_modules_a.json +0 -53
  161. package/src/__tests__/magento_scenarios/app/etc/mage_obsidian_frontend_modules_b.json +0 -50
  162. package/src/__tests__/service/generateInterceptors.test.js +0 -196
  163. package/src/__tests__/service/inheritModuleResolver.test.js +0 -61
  164. package/src/__tests__/service/interceptorManager_magento_behavior.test.js +0 -137
  165. package/src/__tests__/service/moduleResolver.test.js +0 -194
  166. package/src/__tests__/service/themeResolverSync.test.js +0 -97
  167. package/src/__tests__/vite-plugins/interceptorsPlugin.test.js +0 -121
  168. package/src/config/default.js +0 -27
  169. package/src/scripts/buildThemes.js +0 -132
  170. package/src/service/configResolver.js +0 -63
  171. package/src/service/cssResolver.js +0 -73
  172. package/src/service/defaultNodeResolver.js +0 -16
  173. package/src/service/magentoHrmRewrite.js +0 -43
  174. package/src/service/moduleResolver.js +0 -178
  175. package/src/service/preCompileFiles.js +0 -37
  176. package/src/service/preCompileMagentoFiles.js +0 -16
  177. package/src/service/setupGlobals.js +0 -19
  178. package/src/service/themeResolverSync.js +0 -67
  179. package/src/utils/findComponents.js +0 -70
  180. /package/{src → dist}/templates/base_main_js_file.js +0 -0
@@ -0,0 +1,126 @@
1
+ import themeResolver from "./themeResolverSync.js";
2
+ import path from "node:path";
3
+ import { MODULE_TEMPLATES_PATH, MODULE_WEB_PATH, THEME_CSS_FOLDER, THEME_MODULE_WEB_PATH, } from "../config/default.js";
4
+ import { resolveFileByTheme, getAllJsVueFilesWithInheritanceCached } from "./moduleResolver.js";
5
+ import configResolver from "./configResolver.js";
6
+ import fs from "node:fs/promises";
7
+ const { getMagentoConfig, getModuleDefinition, getThemeDefinition, getModulesConfigArray } = configResolver;
8
+ const MODULE_CSS_EXTEND_FILE = getMagentoConfig().MODULE_CSS_EXTEND_FILE;
9
+ const THEME_CSS_SOURCE_FILE = getMagentoConfig().THEME_CSS_SOURCE_FILE;
10
+ async function getThemeImports(themeName, themeConfig) {
11
+ if (!themeConfig) {
12
+ themeConfig = await themeResolver.getThemeConfig(themeName);
13
+ }
14
+ const themeDefinition = getThemeDefinition(themeName);
15
+ const themePath = themeDefinition.src;
16
+ let imports = "";
17
+ if (themeConfig.includeCssSourceFromParentThemes && themeDefinition.parent) {
18
+ imports += await getThemeImports(themeDefinition.parent, themeConfig);
19
+ }
20
+ imports += `@import "${path.join(themePath, THEME_MODULE_WEB_PATH, THEME_CSS_FOLDER, THEME_CSS_SOURCE_FILE)}";\n`;
21
+ return imports;
22
+ }
23
+ function resolveModuleCssSourcePath(moduleName, themeName) {
24
+ let moduleConfigSourcePath = resolveFileByTheme(themeName, moduleName, path.join("css", MODULE_CSS_EXTEND_FILE));
25
+ if (!moduleConfigSourcePath) {
26
+ const moduleDefinition = getModuleDefinition(moduleName);
27
+ moduleConfigSourcePath = path.join(moduleDefinition.src, MODULE_WEB_PATH, "css", MODULE_CSS_EXTEND_FILE);
28
+ }
29
+ return moduleConfigSourcePath;
30
+ }
31
+ // Walk the theme -> parent chain emitting a @source for each theme root so
32
+ // Tailwind scans the Twig/phtml templates of every theme in the inheritance
33
+ // chain (a child theme's classes plus everything it inherits unchanged).
34
+ async function getThemeTemplateSources(themeName) {
35
+ const theme = getThemeDefinition(themeName);
36
+ if (!theme)
37
+ return "";
38
+ let sources = "";
39
+ if (theme.parent) {
40
+ sources += await getThemeTemplateSources(theme.parent);
41
+ }
42
+ sources += `@source "${theme.src}";\n`;
43
+ return sources;
44
+ }
45
+ // Reads the source-scan opt-out: a theme (merged with its parents) lists the
46
+ // modules whose files Tailwind must NOT scan via `ignoredTailwindConfigFromModules`
47
+ // in theme.config.js — an array of module names, or "all" to skip every module.
48
+ // The theme's own files are always scanned.
49
+ async function getScanExclusions(themeName) {
50
+ const themeConfig = await themeResolver.getThemeConfig(themeName);
51
+ const ignored = themeConfig?.ignoredTailwindConfigFromModules;
52
+ return {
53
+ ignoreAllModules: ignored === "all",
54
+ excludedModules: new Set(Array.isArray(ignored) ? ignored : []),
55
+ };
56
+ }
57
+ // Templates (.twig/.phtml) are not auto-scanned by Tailwind in this pipeline
58
+ // (its base path is the Vite root, not the Magento tree), and the engine only
59
+ // emits @source for JS/Vue components. This registers the template dirs of
60
+ // every compatible module plus the whole theme inheritance chain, mirroring how
61
+ // components already resolve module + parent-theme sources, and honours the
62
+ // per-module scan opt-out.
63
+ async function getTemplateSources(themeName) {
64
+ const { ignoreAllModules, excludedModules } = await getScanExclusions(themeName);
65
+ let sources = "";
66
+ if (!ignoreAllModules) {
67
+ for (const [moduleName, moduleConfig] of getModulesConfigArray()) {
68
+ if (excludedModules.has(moduleName))
69
+ continue;
70
+ const templatesDir = path.join(moduleConfig.src, MODULE_TEMPLATES_PATH);
71
+ try {
72
+ await fs.access(templatesDir);
73
+ sources += `@source "${templatesDir}";\n`;
74
+ }
75
+ catch {
76
+ // module ships no frontend templates
77
+ }
78
+ }
79
+ }
80
+ sources += await getThemeTemplateSources(themeName);
81
+ return sources;
82
+ }
83
+ async function getVueComponentsSource(themeName) {
84
+ const { ignoreAllModules, excludedModules } = await getScanExclusions(themeName);
85
+ const vueComponents = await getAllJsVueFilesWithInheritanceCached(themeName);
86
+ // Inheritance keys look like "Vendor_Module/components/X" or "Theme/...";
87
+ // "Theme" entries are the theme's own files and are always scanned.
88
+ const vueComponentSources = Object.entries(vueComponents)
89
+ .filter(([key]) => {
90
+ const owner = key.split("/")[0];
91
+ if (owner === "Theme")
92
+ return true;
93
+ if (ignoreAllModules)
94
+ return false;
95
+ return !excludedModules.has(owner);
96
+ })
97
+ .map(([, url]) => `@source "${url}";\n`);
98
+ return vueComponentSources.join("");
99
+ }
100
+ async function getCssImports(themeName) {
101
+ const themeConfig = await themeResolver.getThemeConfig(themeName);
102
+ const excludedModules = new Set(themeConfig.ignoredCssFromModules || []);
103
+ const modulesConfig = getModulesConfigArray();
104
+ const cssSource = await getVueComponentsSource(themeName);
105
+ let cssImports = "";
106
+ if (themeConfig.ignoredCssFromModules !== "all") {
107
+ for (const [moduleName] of modulesConfig) {
108
+ if (excludedModules.has(moduleName))
109
+ continue;
110
+ const filePath = resolveModuleCssSourcePath(moduleName, themeName);
111
+ try {
112
+ await fs.access(filePath);
113
+ cssImports += `@import "${filePath}";\n`;
114
+ }
115
+ catch {
116
+ // ignore if file doesn't exist
117
+ }
118
+ }
119
+ }
120
+ cssImports += await getThemeImports(themeName);
121
+ const templateSources = await getTemplateSources(themeName);
122
+ return `${cssSource}${templateSources}\n${cssImports}`;
123
+ }
124
+ export default getCssImports;
125
+ export { getTemplateSources };
126
+ //# sourceMappingURL=cssResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssResolver.js","sourceRoot":"","sources":["../../src/core/cssResolver.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACH,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,GACtF,cAAc,CAAC;AAEnB,MAAM,sBAAsB,GAAG,gBAAgB,EAAE,CAAC,sBAAsB,CAAC;AACzE,MAAM,qBAAqB,GAAG,gBAAgB,EAAE,CAAC,qBAAqB,CAAC;AAEvE,KAAK,UAAU,eAAe,CAAC,SAAS,EAAE,WAAY;IAClD,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,WAAW,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,eAAe,CAAC,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IAAI,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC;gBAAE,SAAS;YAE9C,MAAM,QAAQ,GAAG,0BAA0B,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YACnE,IAAI,CAAC;gBACD,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,UAAU,IAAI,YAAY,QAAQ,MAAM,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACL,+BAA+B;YACnC,CAAC;QACL,CAAC;IACL,CAAC;IAED,UAAU,IAAI,MAAM,eAAe,CAAC,SAAS,CAAC,CAAC;IAE/C,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5D,OAAO,GAAG,SAAS,GAAG,eAAe,KAAK,UAAU,EAAE,CAAC;AAC3D,CAAC;AAED,eAAe,aAAa,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const KEY_INTERCEPTED = "originalIntercepted";
2
+ declare function registerInterceptors(themeName: any): Promise<Record<string, any[]>>;
3
+ declare function generateInterceptors(themeName: any): Promise<any>;
4
+ declare const _default: {
5
+ registerInterceptors: typeof registerInterceptors;
6
+ generateInterceptors: typeof generateInterceptors;
7
+ KEY_INTERCEPTED: string;
8
+ };
9
+ export default _default;
10
+ //# sourceMappingURL=generateInterceptors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateInterceptors.d.ts","sourceRoot":"","sources":["../../src/core/generateInterceptors.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,wBAAwB,CAAC;AAmBrD,iBAAe,oBAAoB,CAAC,SAAS,KAAA,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAgD7E;AAED,iBAAe,oBAAoB,CAAC,SAAS,KAAA,gBAoJ5C;;;;;;AAsED,wBAIE"}
@@ -1,14 +1,20 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
1
9
  import path from "path";
2
- import { pathToFileURL, fileURLToPath } from "url";
3
- import themeResolver from 'mage-obsidian/service/themeResolverSync.js';
4
- import moduleResolver from 'mage-obsidian/service/moduleResolver.js';
5
- import interceptorManager from 'mage-obsidian/service/interceptorManager.js';
6
- import configResolver from "mage-obsidian/service/configResolver.js";
7
-
10
+ import { pathToFileURL } from "url";
11
+ import themeResolver from "./themeResolverSync.js";
12
+ import moduleResolver from "./moduleResolver.js";
13
+ import interceptorManager from "../runtime/interceptorManager.js";
14
+ import configResolver from "./configResolver.js";
8
15
  const interceptorsRegisteredByTheme = new Map();
9
16
  const generatedInterceptorsCache = new Map();
10
- export const KEY_INTERCEPTED = 'originalIntercepted';
11
-
17
+ export const KEY_INTERCEPTED = "originalIntercepted";
12
18
  /**
13
19
  * Resolves the absolute path of a file using the cached file map
14
20
  * @param {string} identifier
@@ -16,21 +22,18 @@ export const KEY_INTERCEPTED = 'originalIntercepted';
16
22
  * @returns {string|null}
17
23
  */
18
24
  function resolvePathFromMap(identifier, fileMap) {
19
- const [moduleName, relativePath] = identifier.split('::');
20
- if (!moduleName || !relativePath) return null;
21
-
25
+ const [moduleName, relativePath] = identifier.split("::");
26
+ if (!moduleName || !relativePath)
27
+ return null;
22
28
  const parsed = path.parse(relativePath);
23
29
  const keyPath = path.join(parsed.dir, parsed.name);
24
30
  const key = `${moduleName}/${keyPath}`;
25
-
26
31
  return fileMap[key] || null;
27
32
  }
28
-
29
33
  async function registerInterceptors(themeName) {
30
34
  if (interceptorsRegisteredByTheme.has(themeName)) {
31
35
  return interceptorsRegisteredByTheme.get(themeName);
32
36
  }
33
-
34
37
  const themeConfig = await themeResolver.getThemeConfig(themeName);
35
38
  const modulesConfig = await moduleResolver.getModuleConfigByThemeConfig(themeName, themeConfig);
36
39
  if (!modulesConfig || modulesConfig.interceptors === undefined) {
@@ -39,59 +42,51 @@ async function registerInterceptors(themeName) {
39
42
  }
40
43
  // Map<Target, Map<PluginName, PluginConfig>>
41
44
  const interceptorsMap = new Map();
42
- for (const [interceptorName, interceptorDefinition] of Object.entries( modulesConfig.interceptors)) {
45
+ for (const [interceptorName, interceptorDefinition] of Object.entries(modulesConfig.interceptors)) {
43
46
  const { target } = interceptorDefinition;
44
- if (!interceptorName || !target) continue;
45
-
47
+ if (!interceptorName || !target)
48
+ continue;
46
49
  if (!interceptorsMap.has(target)) {
47
50
  interceptorsMap.set(target, new Map());
48
51
  }
49
-
50
52
  const targetPlugins = interceptorsMap.get(target);
51
-
52
53
  if (targetPlugins.has(interceptorName)) {
53
54
  // Merge existing plugin config with new config (allows overriding sortOrder, active, etc.)
54
55
  const existing = targetPlugins.get(interceptorName);
55
56
  targetPlugins.set(interceptorName, { ...existing, ...interceptorDefinition });
56
- } else {
57
+ }
58
+ else {
57
59
  targetPlugins.set(interceptorName, { ...interceptorDefinition });
58
60
  }
59
61
  }
60
-
61
62
  // Convert Map to structured object and sort plugins
62
63
  const result = {};
63
64
  for (const [target, pluginsMap] of interceptorsMap) {
64
65
  const plugins = Array.from(pluginsMap.values())
65
- .filter(p => p.active !== false) // Filter out inactive plugins
66
+ .filter((p) => p.active !== false) // Filter out inactive plugins
66
67
  .sort((a, b) => (a.sortOrder || 10) - (b.sortOrder || 10));
67
-
68
68
  if (plugins.length > 0) {
69
69
  result[target] = plugins;
70
70
  }
71
71
  }
72
-
73
72
  interceptorsRegisteredByTheme.set(themeName, result);
74
73
  return result;
75
74
  }
76
-
77
75
  async function generateInterceptors(themeName) {
78
76
  if (generatedInterceptorsCache.has(themeName)) {
79
77
  return generatedInterceptorsCache.get(themeName);
80
78
  }
81
-
82
79
  const interceptorsConfig = await registerInterceptors(themeName);
83
-
84
80
  // Get all files map from cache
85
- let allFilesMap = {};
81
+ let allFilesMap;
86
82
  try {
87
83
  allFilesMap = moduleResolver.getAllJsVueFilesWithInheritanceCached(themeName);
88
- } catch (e) {
89
- console.warn(`Cache not found for theme ${themeName}, falling back to async generation.`);
84
+ }
85
+ catch (e) {
86
+ console.warn(`Cache not found for theme ${themeName} (${e.message}), falling back to async generation.`);
90
87
  allFilesMap = await moduleResolver.getAllJsVueFilesWithInheritance(themeName);
91
88
  }
92
-
93
89
  const interceptors = {};
94
-
95
90
  for (const [target, plugins] of Object.entries(interceptorsConfig)) {
96
91
  // 1. Resolve Target Path
97
92
  const targetPath = resolvePathFromMap(target, allFilesMap);
@@ -99,18 +94,16 @@ async function generateInterceptors(themeName) {
99
94
  console.warn(`Target module not found for identifier: ${target}`);
100
95
  continue;
101
96
  }
102
-
103
97
  let targetModule;
104
98
  try {
105
- targetModule = await import(pathToFileURL(targetPath).href);
106
- } catch (e) {
99
+ targetModule = await import(__rewriteRelativeImportExtension(pathToFileURL(targetPath).href));
100
+ }
101
+ catch (e) {
107
102
  console.error(`Failed to import target module ${target}:`, e.message);
108
103
  continue;
109
104
  }
110
-
111
105
  const targetExports = Object.keys(targetModule);
112
106
  const methodsToIntercept = new Set();
113
-
114
107
  // 3. Validate and Register Interceptors
115
108
  const validInterceptors = [];
116
109
  for (const interceptorConfig of plugins) {
@@ -119,150 +112,136 @@ async function generateInterceptors(themeName) {
119
112
  console.warn(`Interceptor module not found: ${interceptorConfig.interceptor}`);
120
113
  continue;
121
114
  }
122
-
123
115
  let interceptorModule;
124
116
  try {
125
- interceptorModule = await import(pathToFileURL(interceptorPath).href);
126
- } catch (e) {
117
+ interceptorModule = await import(__rewriteRelativeImportExtension(pathToFileURL(interceptorPath).href));
118
+ }
119
+ catch (e) {
127
120
  console.error(`Failed to import interceptor module ${interceptorConfig.interceptor}:`, e.message);
128
121
  continue;
129
122
  }
130
-
131
123
  const interceptorMethods = [];
132
124
  for (const interceptorExport of Object.keys(interceptorModule)) {
133
125
  let type, targetMethod;
134
-
135
- if (interceptorExport.startsWith('before')) {
136
- type = 'before';
126
+ if (interceptorExport.startsWith("before")) {
127
+ type = "before";
137
128
  targetMethod = interceptorExport.substring(6);
138
- } else if (interceptorExport.startsWith('around')) {
139
- type = 'around';
129
+ }
130
+ else if (interceptorExport.startsWith("around")) {
131
+ type = "around";
140
132
  targetMethod = interceptorExport.substring(6);
141
- } else if (interceptorExport.startsWith('after')) {
142
- type = 'after';
133
+ }
134
+ else if (interceptorExport.startsWith("after")) {
135
+ type = "after";
143
136
  targetMethod = interceptorExport.substring(5);
144
- } else {
137
+ }
138
+ else {
145
139
  continue;
146
140
  }
147
-
148
141
  // Check if target method exists in target module
149
- if (!targetExports.includes(targetMethod) && targetMethod !== 'default') {
142
+ if (!targetExports.includes(targetMethod) && targetMethod !== "default") {
150
143
  const lowerFirst = targetMethod.charAt(0).toLowerCase() + targetMethod.slice(1);
151
144
  if (targetExports.includes(lowerFirst)) {
152
145
  targetMethod = lowerFirst;
153
- } else {
146
+ }
147
+ else {
154
148
  // Skip invalid methods but don't crash the whole process?
155
149
  // User requested error if not found.
156
150
  throw new Error(`Interceptor ${interceptorConfig.name} (${interceptorConfig.interceptor}) exports '${interceptorExport}' but target ${target} does not export '${targetMethod}'`);
157
151
  }
158
152
  }
159
-
160
- if (typeof targetModule[targetMethod] !== 'function') {
153
+ if (typeof targetModule[targetMethod] !== "function") {
161
154
  console.warn(`Interceptor ${interceptorConfig.name} (${interceptorConfig.interceptor}) exports '${interceptorExport}' but target ${target} export '${targetMethod}' is not a function.`);
162
155
  continue;
163
156
  }
164
-
165
157
  const methodKey = `${target}::${targetMethod}`;
166
- interceptorManager.addInterceptor(
167
- methodKey,
168
- interceptorConfig.name,
169
- type,
170
- interceptorModule[interceptorExport],
171
- interceptorConfig.sortOrder
172
- );
173
-
158
+ interceptorManager.addInterceptor(methodKey, interceptorConfig.name, type, interceptorModule[interceptorExport], interceptorConfig.sortOrder);
174
159
  methodsToIntercept.add(targetMethod);
175
160
  interceptorMethods.push({
176
161
  exportName: interceptorExport,
177
162
  type,
178
163
  targetMethod,
179
- sortOrder: interceptorConfig.sortOrder
164
+ sortOrder: interceptorConfig.sortOrder,
180
165
  });
181
166
  }
182
-
183
167
  if (interceptorMethods.length > 0) {
184
168
  validInterceptors.push({
185
169
  ...interceptorConfig,
186
170
  path: interceptorPath,
187
- methods: interceptorMethods
171
+ methods: interceptorMethods,
188
172
  });
189
173
  }
190
174
  }
191
-
192
175
  // 4. Create Interceptor Proxy & Source Code
193
176
  if (methodsToIntercept.size > 0) {
194
177
  const wrapper = { ...targetModule };
195
178
  const proxy = interceptorManager.intercept(wrapper, target, true);
196
-
197
179
  const source = generateInterceptorCode(target, targetPath, validInterceptors, targetExports);
198
-
199
180
  interceptors[target] = {
200
181
  proxy,
201
182
  targetPath,
202
183
  targetModule,
203
184
  interceptors: validInterceptors,
204
- source
185
+ source,
205
186
  };
206
187
  }
207
188
  }
208
-
209
189
  generatedInterceptorsCache.set(themeName, interceptors);
210
190
  return interceptors;
211
191
  }
212
-
213
192
  function generateInterceptorCode(target, targetPath, interceptors, targetExports) {
214
193
  const imports = [];
215
194
  const registrations = [];
216
-
217
195
  // Import PluginManager (Assuming it's available via alias or relative path in the build environment)
218
196
  // For Vite, we might need to adjust this path or use a virtual module ID.
219
197
  // Using a relative path from this service file might not work in the generated code context.
220
198
  // We'll assume '@mage-obsidian/plugin-manager' or similar alias is set up,
221
199
  // or use the absolute path which Vite handles.
222
- const resolvedInterceptorManagerPath = configResolver.resolveLibRealPath('mage-obsidian/service/interceptorManager');
223
- imports.push(`import interceptorManager from "${resolvedInterceptorManagerPath}";`);
224
-
200
+ // All string literals go through JSON.stringify so paths or interceptor
201
+ // names containing quotes/backslashes can't break (or inject into) the
202
+ // generated module. Identifiers (export names) come from Object.keys of a
203
+ // real ES module, so they are valid JS and used unquoted.
204
+ const resolvedInterceptorManagerPath = configResolver.resolveLibRealPath("mage-obsidian/runtime/interceptorManager");
205
+ imports.push(`import interceptorManager from ${JSON.stringify(resolvedInterceptorManagerPath)};`);
225
206
  // Import Original Module
226
- imports.push(`import * as originalModule from '/@fs${targetPath}?${KEY_INTERCEPTED}';`);
227
-
207
+ imports.push(`import * as originalModule from ${JSON.stringify(`/@fs${targetPath}?${KEY_INTERCEPTED}`)};`);
228
208
  // Import Interceptors
229
209
  interceptors.forEach((interceptor, index) => {
230
210
  const interceptorVar = `interceptor_${index}`;
231
- imports.push(`import * as ${interceptorVar} from '/@fs${interceptor.path}';`);
232
-
233
- interceptor.methods.forEach(method => {
211
+ imports.push(`import * as ${interceptorVar} from ${JSON.stringify(`/@fs${interceptor.path}`)};`);
212
+ interceptor.methods.forEach((method) => {
234
213
  const methodKey = `${target}::${method.targetMethod}`;
235
- registrations.push(`interceptorManager.addInterceptor('${methodKey}', '${interceptor.name}', '${method.type}', ${interceptorVar}.${method.exportName}, ${method.sortOrder});`);
214
+ const sortOrder = Number.isFinite(method.sortOrder) ? method.sortOrder : 10;
215
+ registrations.push(`interceptorManager.addInterceptor(${JSON.stringify(methodKey)}, ${JSON.stringify(interceptor.name)}, ${JSON.stringify(method.type)}, ${interceptorVar}.${method.exportName}, ${sortOrder});`);
236
216
  });
237
217
  });
238
-
239
218
  // Create Interceptor
240
219
  const interceptorCode = `
241
220
  const targetWrapper = { ...originalModule };
242
- const proxy = interceptorManager.intercept(targetWrapper, '${target}', true);
221
+ const proxy = interceptorManager.intercept(targetWrapper, ${JSON.stringify(target)}, true);
243
222
  `;
244
-
245
223
  // Exports
246
- const exportsCode = targetExports.map(exp => {
247
- if (exp === 'default') {
224
+ const exportsCode = targetExports
225
+ .map((exp) => {
226
+ if (exp === "default") {
248
227
  return `export default proxy.default;`;
249
228
  }
250
229
  return `export const ${exp} = proxy.${exp};`;
251
- }).join('\n');
252
-
230
+ })
231
+ .join("\n");
253
232
  return `
254
- ${imports.join('\n')}
233
+ ${imports.join("\n")}
255
234
 
256
- ${registrations.join('\n')}
235
+ ${registrations.join("\n")}
257
236
 
258
237
  ${interceptorCode}
259
238
 
260
239
  ${exportsCode}
261
240
  `;
262
241
  }
263
-
264
242
  export default {
265
243
  registerInterceptors,
266
244
  generateInterceptors,
267
- KEY_INTERCEPTED
245
+ KEY_INTERCEPTED,
268
246
  };
247
+ //# sourceMappingURL=generateInterceptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateInterceptors.js","sourceRoot":"","sources":["../../src/core/generateInterceptors.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,kBAAkB,MAAM,kCAAkC,CAAC;AAClE,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,6BAA6B,GAAG,IAAI,GAAG,EAAE,CAAC;AAChD,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAErD;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,UAAU,EAAE,OAAO;IAC3C,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1D,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAE9C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,GAAG,UAAU,IAA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C,IAAI,CAAC;;EAExB,eAAe;;EAEf,WAAW;CACZ,CAAC;AACF,CAAC;AAED,eAAe;IACX,oBAAoB;IACpB,oBAAoB;IACpB,eAAe;CAClB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Build the `compilerOptions.paths` map that makes the framework's
3
+ * `Vendor_Module::` import specifiers first-class for the editor: each maps
4
+ * directly to its real source file, so Ctrl+click jumps straight there and a
5
+ * typo surfaces as an unresolved import. Derived from the same inheritance cache
6
+ * the resolver uses, so the declared set matches exactly what the build resolves
7
+ * (`.ts`/`.js`/`.vue` — assets are not in the cache). A `"*"` wildcard adds npm
8
+ * package resolution from the harness node_modules.
9
+ */
10
+ export default function generateJsconfigPaths(themeName: string, options?: {
11
+ remap?: boolean;
12
+ }): Promise<Record<string, string[]>>;
13
+ declare const GENERATED_MARKER = "// Generated by mage-obsidian";
14
+ /**
15
+ * Wrap a `paths` map in the full theme jsconfig the editor consumes. `allowJs`
16
+ * is required or the theme's `.js`/`.vue` sources never join the TS program (so
17
+ * nothing resolves); `baseUrl` is deliberately omitted — it is deprecated and a
18
+ * hard config error in TS 7.0, which makes the editor discard the whole config.
19
+ * The leading marker comment lets the build tell its own output apart from a
20
+ * hand-written jsconfig and refuse to clobber the latter.
21
+ */
22
+ declare function buildThemeJsconfig(paths: Record<string, string[]>): string;
23
+ /**
24
+ * Wrap a `paths` map in the theme's typecheck tsconfig — the CI/build gate run by
25
+ * `vue-tsc --noEmit`. Distinct from the editor `jsconfig.json` (same dir) on
26
+ * purpose: it is NOT named `tsconfig.json`, so the editor's auto-discovery keeps
27
+ * using the jsconfig while this file is consumed only via an explicit `-p`. It is
28
+ * the one context where every `Vendor_Module::` resolves to its real source (the
29
+ * `paths` are the same map the build resolves through), so cross-module type
30
+ * seams are actually verified.
31
+ *
32
+ * `allowImportingTsExtensions` is required because engine imports use explicit
33
+ * `.ts` specifiers; it in turn requires `noEmit`. `allowJs`/`checkJs:false` keep
34
+ * not-yet-migrated `.js` in the graph (resolvable) without type-checking them, so
35
+ * a half-migrated tree still passes. `lib` carries DOM because the storefront
36
+ * code touches `document`/`window`/`fetch`/`localStorage`.
37
+ *
38
+ * `files` is the exact assembled set the build bundles (the inheritance-resolved
39
+ * absolute paths), not a recursive theme-relative glob: module sources live
40
+ * outside the theme dir, so such a glob would silently check nothing. Listing
41
+ * them explicitly is what makes the gate type-check every module/override file.
42
+ */
43
+ declare function buildThemeTsconfig(paths: Record<string, string[]>, files: string[]): string;
44
+ export { buildThemeJsconfig, buildThemeTsconfig, GENERATED_MARKER };
45
+ //# sourceMappingURL=generateJsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateJsconfig.d.ts","sourceRoot":"","sources":["../../src/core/generateJsconfig.ts"],"names":[],"mappings":"AAuDA;;;;;;;;GAQG;AACH,wBAA8B,qBAAqB,CAC/C,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CA+BnC;AAED,QAAA,MAAM,gBAAgB,kCAAkC,CAAC;AAEzD;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAcnE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAoBpF;AAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}