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.
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/dist/cli/buildThemes.d.ts +3 -0
- package/dist/cli/buildThemes.d.ts.map +1 -0
- package/dist/cli/buildThemes.js +219 -0
- package/dist/cli/buildThemes.js.map +1 -0
- package/dist/config/default.d.ts +16 -0
- package/dist/config/default.d.ts.map +1 -0
- package/dist/config/default.js +22 -0
- package/dist/config/default.js.map +1 -0
- package/dist/config/eslint.js +60 -0
- package/dist/core/configResolver.d.ts +38 -0
- package/dist/core/configResolver.d.ts.map +1 -0
- package/dist/core/configResolver.js +102 -0
- package/dist/core/configResolver.js.map +1 -0
- package/dist/core/contractValidator.d.ts +16 -0
- package/dist/core/contractValidator.d.ts.map +1 -0
- package/dist/core/contractValidator.js +49 -0
- package/dist/core/contractValidator.js.map +1 -0
- package/dist/core/cssResolver.d.ts +5 -0
- package/dist/core/cssResolver.d.ts.map +1 -0
- package/dist/core/cssResolver.js +126 -0
- package/dist/core/cssResolver.js.map +1 -0
- package/dist/core/generateInterceptors.d.ts +10 -0
- package/dist/core/generateInterceptors.d.ts.map +1 -0
- package/{src/service → dist/core}/generateInterceptors.js +72 -93
- package/dist/core/generateInterceptors.js.map +1 -0
- package/dist/core/generateJsconfig.d.ts +45 -0
- package/dist/core/generateJsconfig.d.ts.map +1 -0
- package/dist/core/generateJsconfig.js +145 -0
- package/dist/core/generateJsconfig.js.map +1 -0
- package/dist/core/moduleResolver.d.ts +22 -0
- package/dist/core/moduleResolver.d.ts.map +1 -0
- package/dist/core/moduleResolver.js +177 -0
- package/dist/core/moduleResolver.js.map +1 -0
- package/dist/core/preCompileFiles.d.ts +6 -0
- package/dist/core/preCompileFiles.d.ts.map +1 -0
- package/dist/core/preCompileFiles.js +79 -0
- package/dist/core/preCompileFiles.js.map +1 -0
- package/dist/core/preCompileMagentoFiles.d.ts +3 -0
- package/dist/core/preCompileMagentoFiles.d.ts.map +1 -0
- package/dist/core/preCompileMagentoFiles.js +28 -0
- package/dist/core/preCompileMagentoFiles.js.map +1 -0
- package/dist/core/themeResolverSync.d.ts +6 -0
- package/dist/core/themeResolverSync.d.ts.map +1 -0
- package/dist/core/themeResolverSync.js +65 -0
- package/dist/core/themeResolverSync.js.map +1 -0
- package/dist/runtime/i18nCore.d.ts +55 -0
- package/dist/runtime/i18nCore.d.ts.map +1 -0
- package/dist/runtime/i18nCore.js +77 -0
- package/dist/runtime/i18nCore.js.map +1 -0
- package/dist/runtime/interceptorManager.d.ts +45 -0
- package/dist/runtime/interceptorManager.d.ts.map +1 -0
- package/{src/service → dist/runtime}/interceptorManager.js +43 -52
- package/dist/runtime/interceptorManager.js.map +1 -0
- package/dist/runtime/islands.d.ts +45 -0
- package/dist/runtime/islands.d.ts.map +1 -0
- package/dist/runtime/islands.js +59 -0
- package/dist/runtime/islands.js.map +1 -0
- package/dist/runtime/sectionStoreCore.d.ts +108 -0
- package/dist/runtime/sectionStoreCore.d.ts.map +1 -0
- package/dist/runtime/sectionStoreCore.js +189 -0
- package/dist/runtime/sectionStoreCore.js.map +1 -0
- package/dist/utils/findComponents.d.ts +17 -0
- package/dist/utils/findComponents.d.ts.map +1 -0
- package/dist/utils/findComponents.js +66 -0
- package/dist/utils/findComponents.js.map +1 -0
- package/dist/utils/runWithConcurrency.d.ts +10 -0
- package/dist/utils/runWithConcurrency.d.ts.map +1 -0
- package/dist/utils/runWithConcurrency.js +29 -0
- package/dist/utils/runWithConcurrency.js.map +1 -0
- package/dist/vite/defaultNodeResolver.d.ts +9 -0
- package/dist/vite/defaultNodeResolver.d.ts.map +1 -0
- package/dist/vite/defaultNodeResolver.js +19 -0
- package/dist/vite/defaultNodeResolver.js.map +1 -0
- package/dist/vite/inheritAssetsModuleResolver.d.ts +8 -0
- package/dist/vite/inheritAssetsModuleResolver.d.ts.map +1 -0
- package/{src/service → dist/vite}/inheritAssetsModuleResolver.js +10 -20
- package/dist/vite/inheritAssetsModuleResolver.js.map +1 -0
- package/dist/vite/inheritModuleResolver.d.ts +8 -0
- package/dist/vite/inheritModuleResolver.d.ts.map +1 -0
- package/{src/service → dist/vite}/inheritModuleResolver.js +8 -17
- package/dist/vite/inheritModuleResolver.js.map +1 -0
- package/dist/vite/interceptorsPlugin.d.ts +10 -0
- package/dist/vite/interceptorsPlugin.d.ts.map +1 -0
- package/{src/service → dist/vite}/interceptorsPlugin.js +17 -28
- package/dist/vite/interceptorsPlugin.js.map +1 -0
- package/dist/vite/magentoHrmRewrite.d.ts +6 -0
- package/dist/vite/magentoHrmRewrite.d.ts.map +1 -0
- package/dist/vite/magentoHrmRewrite.js +45 -0
- package/dist/vite/magentoHrmRewrite.js.map +1 -0
- package/dist/vite/sharedPlugins.d.ts +35 -0
- package/dist/vite/sharedPlugins.d.ts.map +1 -0
- package/dist/vite/sharedPlugins.js +52 -0
- package/dist/vite/sharedPlugins.js.map +1 -0
- package/dist/vite/themeSourceWatcher.d.ts +16 -0
- package/dist/vite/themeSourceWatcher.d.ts.map +1 -0
- package/dist/vite/themeSourceWatcher.js +91 -0
- package/dist/vite/themeSourceWatcher.js.map +1 -0
- package/dist/vite/unresolvedModuleGuard.d.ts +17 -0
- package/dist/vite/unresolvedModuleGuard.d.ts.map +1 -0
- package/dist/vite/unresolvedModuleGuard.js +87 -0
- package/dist/vite/unresolvedModuleGuard.js.map +1 -0
- package/package.json +89 -13
- package/.github/workflows/publish.yml +0 -35
- package/jest.config.js +0 -5
- package/src/__tests__/__mocks__/configResolver.js +0 -35
- package/src/__tests__/fixtures/interceptors/emptyTarget.js +0 -2
- package/src/__tests__/fixtures/interceptors/pluginForNonFunction.js +0 -7
- package/src/__tests__/fixtures/interceptors/pluginModule.js +0 -13
- package/src/__tests__/fixtures/interceptors/targetModule.js +0 -12
- package/src/__tests__/fixtures/interceptors/targetNonFunction.js +0 -7
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/css/module.extend.css +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameA/view/frontend/web/module.config.js +0 -9
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/css/module.extend.css +0 -2
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameB/view/frontend/web/module.config.js +0 -7
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/css/module.extend.css +0 -2
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/code/Vendor/ModuleNameC/view/frontend/web/module.config.js +0 -7
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/css/module.extend.css +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameA/web/module.config.js +0 -2
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/css/module.extend.css +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameB/web/module.config.js +0 -2
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/css/module.extend.css +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/Vendor_ModuleNameNoConfig/web/module.config.js +0 -2
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/css/theme.source.css +0 -6
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-a/web/theme.config.js +0 -5
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-b/web/css/theme.source.css +0 -6
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-b/web/theme.config.js +0 -5
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/components/ComponentA.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/components/ComponentB.vue +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/css/module.extend.css +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/js/main.js +0 -0
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/Vendor_ModuleNameB/web/module.config.js +0 -2
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/web/css/theme.source.css +0 -6
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-c/web/theme.config.js +0 -2
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-d/web/css/theme.source.css +0 -6
- package/src/__tests__/magento_scenarios/app/design/frontend/Vendor/theme-d/web/theme.config.js +0 -3
- package/src/__tests__/magento_scenarios/app/etc/mage_obsidian_frontend_modules_a.json +0 -53
- package/src/__tests__/magento_scenarios/app/etc/mage_obsidian_frontend_modules_b.json +0 -50
- package/src/__tests__/service/generateInterceptors.test.js +0 -196
- package/src/__tests__/service/inheritModuleResolver.test.js +0 -61
- package/src/__tests__/service/interceptorManager_magento_behavior.test.js +0 -137
- package/src/__tests__/service/moduleResolver.test.js +0 -194
- package/src/__tests__/service/themeResolverSync.test.js +0 -97
- package/src/__tests__/vite-plugins/interceptorsPlugin.test.js +0 -121
- package/src/config/default.js +0 -27
- package/src/scripts/buildThemes.js +0 -132
- package/src/service/configResolver.js +0 -63
- package/src/service/cssResolver.js +0 -73
- package/src/service/defaultNodeResolver.js +0 -16
- package/src/service/magentoHrmRewrite.js +0 -43
- package/src/service/moduleResolver.js +0 -178
- package/src/service/preCompileFiles.js +0 -37
- package/src/service/preCompileMagentoFiles.js +0 -16
- package/src/service/setupGlobals.js +0 -19
- package/src/service/themeResolverSync.js +0 -67
- package/src/utils/findComponents.js +0 -70
- /package/{src → dist}/templates/base_main_js_file.js +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import moduleResolver from "./moduleResolver.js";
|
|
3
|
+
// Map of `from=>to[,from2=>to2]` prefixes, read from the environment. It rewrites
|
|
4
|
+
// the absolute paths baked into the generated jsconfig so go-to-definition and
|
|
5
|
+
// npm resolution land on files where the editor actually runs. This matters when
|
|
6
|
+
// the build runs in a container but the editor opens the same files at a
|
|
7
|
+
// different mount (e.g. theme sources served at /var/www/html in the container
|
|
8
|
+
// but edited at the host bind-mount). An empty map is the identity — correct
|
|
9
|
+
// when the build and editor share a filesystem.
|
|
10
|
+
function parsePathMap(raw) {
|
|
11
|
+
if (!raw)
|
|
12
|
+
return [];
|
|
13
|
+
return (raw
|
|
14
|
+
.split(",")
|
|
15
|
+
.map((pair) => pair.split("=>").map((part) => part.trim()))
|
|
16
|
+
.filter((parts) => parts.length === 2 && !!parts[0] && !!parts[1])
|
|
17
|
+
.map(([from, to]) => [from, to])
|
|
18
|
+
// Longest `from` first so a more specific mount (e.g. the vite harness
|
|
19
|
+
// overlaid at /var/www/html/vite) wins over a broader one
|
|
20
|
+
// (/var/www/html) regardless of declaration order.
|
|
21
|
+
.sort((a, b) => b[0].length - a[0].length));
|
|
22
|
+
}
|
|
23
|
+
function remapPath(filePath, map) {
|
|
24
|
+
for (const [from, to] of map) {
|
|
25
|
+
if (filePath.startsWith(from))
|
|
26
|
+
return to + filePath.slice(from.length);
|
|
27
|
+
}
|
|
28
|
+
return filePath;
|
|
29
|
+
}
|
|
30
|
+
// The Vite harness install (the `vite/` dir is the cwd during a build) is where
|
|
31
|
+
// the build resolves bare npm specifiers, so point the editor at the same place.
|
|
32
|
+
// Wildcard so `vue`, `@heroicons/vue/...`, `pinia` and friends all resolve.
|
|
33
|
+
function nodeModulesWildcard(map) {
|
|
34
|
+
return path.join(remapPath(path.resolve(process.cwd(), "node_modules"), map), "*");
|
|
35
|
+
}
|
|
36
|
+
// Engine subpath imports (`mage-obsidian/runtime/*`, `/service/*`, …) route
|
|
37
|
+
// through the package's `exports` (`./runtime/*` → `./dist/runtime/*`), which the
|
|
38
|
+
// bare `"*"` wildcard's literal substitution would miss — it would look under the
|
|
39
|
+
// package root, not `dist/`. A more-specific `mage-obsidian/*` → `dist/*` pattern
|
|
40
|
+
// resolves them (TS prefers the longer match over `"*"`). The published package
|
|
41
|
+
// ships compiled JS plus `.d.ts`, so the editor reads types from `dist/`.
|
|
42
|
+
function engineSrcWildcard(map) {
|
|
43
|
+
return path.join(remapPath(path.resolve(process.cwd(), "node_modules", "mage-obsidian", "dist"), map), "*");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build the `compilerOptions.paths` map that makes the framework's
|
|
47
|
+
* `Vendor_Module::` import specifiers first-class for the editor: each maps
|
|
48
|
+
* directly to its real source file, so Ctrl+click jumps straight there and a
|
|
49
|
+
* typo surfaces as an unresolved import. Derived from the same inheritance cache
|
|
50
|
+
* the resolver uses, so the declared set matches exactly what the build resolves
|
|
51
|
+
* (`.ts`/`.js`/`.vue` — assets are not in the cache). A `"*"` wildcard adds npm
|
|
52
|
+
* package resolution from the harness node_modules.
|
|
53
|
+
*/
|
|
54
|
+
export default async function generateJsconfigPaths(themeName, options = {}) {
|
|
55
|
+
const files = (await moduleResolver.getAllJsVueFilesWithInheritance(themeName));
|
|
56
|
+
// The editor jsconfig remaps container paths to the host mount so go-to-def
|
|
57
|
+
// lands on the files the editor opens. The typecheck gate runs where the build
|
|
58
|
+
// runs (same filesystem as the sources), so it opts out and keeps real paths.
|
|
59
|
+
const map = options.remap === false ? [] : parsePathMap(process.env.MAGE_OBSIDIAN_TYPES_PATH_MAP);
|
|
60
|
+
const paths = {
|
|
61
|
+
"mage-obsidian/*": [engineSrcWildcard(map)],
|
|
62
|
+
"*": [nodeModulesWildcard(map)],
|
|
63
|
+
};
|
|
64
|
+
for (const [key, absolutePath] of Object.entries(files)) {
|
|
65
|
+
const slash = key.indexOf("/");
|
|
66
|
+
if (slash === -1)
|
|
67
|
+
continue;
|
|
68
|
+
const namespace = key.slice(0, slash);
|
|
69
|
+
const rest = key.slice(slash + 1);
|
|
70
|
+
const target = remapPath(absolutePath, map);
|
|
71
|
+
paths[`${namespace}::${rest}`] = [target];
|
|
72
|
+
if (rest.startsWith("components/")) {
|
|
73
|
+
// The resolver accepts the shorthand without the `components/` prefix.
|
|
74
|
+
paths[`${namespace}::${rest.slice("components/".length)}`] = [target];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return paths;
|
|
78
|
+
}
|
|
79
|
+
const GENERATED_MARKER = "// Generated by mage-obsidian";
|
|
80
|
+
/**
|
|
81
|
+
* Wrap a `paths` map in the full theme jsconfig the editor consumes. `allowJs`
|
|
82
|
+
* is required or the theme's `.js`/`.vue` sources never join the TS program (so
|
|
83
|
+
* nothing resolves); `baseUrl` is deliberately omitted — it is deprecated and a
|
|
84
|
+
* hard config error in TS 7.0, which makes the editor discard the whole config.
|
|
85
|
+
* The leading marker comment lets the build tell its own output apart from a
|
|
86
|
+
* hand-written jsconfig and refuse to clobber the latter.
|
|
87
|
+
*/
|
|
88
|
+
function buildThemeJsconfig(paths) {
|
|
89
|
+
const jsconfig = {
|
|
90
|
+
compilerOptions: {
|
|
91
|
+
allowJs: true,
|
|
92
|
+
checkJs: false,
|
|
93
|
+
module: "esnext",
|
|
94
|
+
moduleResolution: "bundler",
|
|
95
|
+
paths,
|
|
96
|
+
},
|
|
97
|
+
include: ["**/*.ts", "**/*.js", "**/*.vue"],
|
|
98
|
+
exclude: ["**/generated/**", "node_modules"],
|
|
99
|
+
};
|
|
100
|
+
const header = `${GENERATED_MARKER} — do not edit. Refreshed on every build and live in dev.\n`;
|
|
101
|
+
return `${header}${JSON.stringify(jsconfig, null, 4)}\n`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Wrap a `paths` map in the theme's typecheck tsconfig — the CI/build gate run by
|
|
105
|
+
* `vue-tsc --noEmit`. Distinct from the editor `jsconfig.json` (same dir) on
|
|
106
|
+
* purpose: it is NOT named `tsconfig.json`, so the editor's auto-discovery keeps
|
|
107
|
+
* using the jsconfig while this file is consumed only via an explicit `-p`. It is
|
|
108
|
+
* the one context where every `Vendor_Module::` resolves to its real source (the
|
|
109
|
+
* `paths` are the same map the build resolves through), so cross-module type
|
|
110
|
+
* seams are actually verified.
|
|
111
|
+
*
|
|
112
|
+
* `allowImportingTsExtensions` is required because engine imports use explicit
|
|
113
|
+
* `.ts` specifiers; it in turn requires `noEmit`. `allowJs`/`checkJs:false` keep
|
|
114
|
+
* not-yet-migrated `.js` in the graph (resolvable) without type-checking them, so
|
|
115
|
+
* a half-migrated tree still passes. `lib` carries DOM because the storefront
|
|
116
|
+
* code touches `document`/`window`/`fetch`/`localStorage`.
|
|
117
|
+
*
|
|
118
|
+
* `files` is the exact assembled set the build bundles (the inheritance-resolved
|
|
119
|
+
* absolute paths), not a recursive theme-relative glob: module sources live
|
|
120
|
+
* outside the theme dir, so such a glob would silently check nothing. Listing
|
|
121
|
+
* them explicitly is what makes the gate type-check every module/override file.
|
|
122
|
+
*/
|
|
123
|
+
function buildThemeTsconfig(paths, files) {
|
|
124
|
+
const tsconfig = {
|
|
125
|
+
compilerOptions: {
|
|
126
|
+
noEmit: true,
|
|
127
|
+
allowImportingTsExtensions: true,
|
|
128
|
+
module: "esnext",
|
|
129
|
+
moduleResolution: "bundler",
|
|
130
|
+
target: "esnext",
|
|
131
|
+
lib: ["ESNext", "DOM", "DOM.Iterable"],
|
|
132
|
+
allowJs: true,
|
|
133
|
+
checkJs: false,
|
|
134
|
+
skipLibCheck: true,
|
|
135
|
+
strict: false,
|
|
136
|
+
paths,
|
|
137
|
+
},
|
|
138
|
+
files,
|
|
139
|
+
exclude: ["**/generated/**", "node_modules"],
|
|
140
|
+
};
|
|
141
|
+
const header = `${GENERATED_MARKER} — typecheck gate (vue-tsc). Build-managed; do not edit.\n`;
|
|
142
|
+
return `${header}${JSON.stringify(tsconfig, null, 4)}\n`;
|
|
143
|
+
}
|
|
144
|
+
export { buildThemeJsconfig, buildThemeTsconfig, GENERATED_MARKER };
|
|
145
|
+
//# sourceMappingURL=generateJsconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateJsconfig.js","sourceRoot":"","sources":["../../src/core/generateJsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,kFAAkF;AAClF,+EAA+E;AAC/E,iFAAiF;AACjF,yEAAyE;AACzE,+EAA+E;AAC/E,6EAA6E;AAC7E,gDAAgD;AAChD,SAAS,YAAY,CAAC,GAAY;IAC9B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CACH,GAAG;SACE,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SAC1D,MAAM,CACH,CAAC,KAAK,EAA6B,EAAE,CACjC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACrD;SACA,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC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C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function getAllJsVueFilesWithInheritanceCached(themeName?: any): any;
|
|
2
|
+
declare function getAllJsVueFilesWithInheritance(themeName?: any): Promise<any>;
|
|
3
|
+
declare function invalidateTheme(themeName?: any): void;
|
|
4
|
+
declare function resolveFileByTheme(themeName: any, moduleName: any, filePath: any): string;
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the Tailwind configuration for a theme synchronously.
|
|
7
|
+
* Uses a cache system to optimize performance.
|
|
8
|
+
* @param {string} themeName - Name of the theme.
|
|
9
|
+
* @param {object} themeConfig
|
|
10
|
+
* @returns {object|null} Tailwind configuration object.
|
|
11
|
+
*/
|
|
12
|
+
declare function getModuleConfigByThemeConfig(themeName: any, themeConfig: any): Promise<any>;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
getAllJsVueFilesWithInheritance: typeof getAllJsVueFilesWithInheritance;
|
|
15
|
+
getAllJsVueFilesWithInheritanceCached: typeof getAllJsVueFilesWithInheritanceCached;
|
|
16
|
+
getModuleConfigByThemeConfig: typeof getModuleConfigByThemeConfig;
|
|
17
|
+
resolveFileByTheme: typeof resolveFileByTheme;
|
|
18
|
+
invalidateTheme: typeof invalidateTheme;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
21
|
+
export { getModuleConfigByThemeConfig, resolveFileByTheme, getAllJsVueFilesWithInheritance, getAllJsVueFilesWithInheritanceCached, invalidateTheme, };
|
|
22
|
+
//# sourceMappingURL=moduleResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.d.ts","sourceRoot":"","sources":["../../src/core/moduleResolver.ts"],"names":[],"mappings":"AA+EA,iBAAS,qCAAqC,CAAC,SAAS,CAAC,KAAA,OAexD;AAED,iBAAe,+BAA+B,CAAC,SAAS,CAAC,KAAA,gBAWxD;AAQD,iBAAS,eAAe,CAAC,SAAS,CAAC,KAAA,QAUlC;AAaD,iBAAS,kBAAkB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA,EAAE,QAAQ,KAAA,UAW1D;AAqBD;;;;;;GAMG;AACH,iBAAe,4BAA4B,CAAC,SAAS,KAAA,EAAE,WAAW,KAAA,gBAiBjE;;;;;;;;AAED,wBAME;AAEF,OAAO,EACH,4BAA4B,EAC5B,kBAAkB,EAClB,+BAA+B,EAC/B,qCAAqC,EACrC,eAAe,GAClB,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
};
|
|
9
|
+
import path from "path";
|
|
10
|
+
import configResolver from "./configResolver.js";
|
|
11
|
+
import { ALL_JS_VUE_FILES_WITH_INHERITANCE_FILE_NAME, MODULE_WEB_PATH, PRECOMPILED_FOLDER, THEME_MODULE_WEB_PATH, } from "../config/default.js";
|
|
12
|
+
import getFilesFromFolders from "../utils/findComponents.js";
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import deepmerge from "deepmerge";
|
|
15
|
+
const defaultFoldersToMap = [
|
|
16
|
+
{
|
|
17
|
+
src: configResolver.getMagentoConfig().VUE_COMPONENTS_PATH,
|
|
18
|
+
ext: ["vue", "ts", "js"],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
src: configResolver.getMagentoConfig().JS_PATH,
|
|
22
|
+
ext: ["ts", "js"],
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
// Keyed by `${theme}\0${contractHash}` so a changed module/theme set (new hash)
|
|
26
|
+
// recomputes instead of returning a result keyed only by theme name.
|
|
27
|
+
const cachedModulesByTheme = new Map();
|
|
28
|
+
// NUL separator: theme names and the hex hash never contain it, so the parts
|
|
29
|
+
// can't collide. Shared with invalidateTheme so its prefix match stays in
|
|
30
|
+
// lock-step with the key format (a plain space here silently broke the match).
|
|
31
|
+
const CACHE_KEY_SEP = "\0";
|
|
32
|
+
const cacheKey = (themeName) => `${themeName}${CACHE_KEY_SEP}${configResolver.getContractHash()}`;
|
|
33
|
+
// Caches the persisted inheritance map keyed by theme, invalidated by the file's
|
|
34
|
+
// mtime so a rebuilt .precompiled JSON (watch mode, regeneration) is picked up
|
|
35
|
+
// instead of serving a stale in-memory copy.
|
|
36
|
+
const precompiledFileCache = new Map();
|
|
37
|
+
async function getAllJsVueFilesFromActiveModules() {
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const entry of configResolver.getModulesConfigArray()) {
|
|
40
|
+
const [moduleName, moduleConfig] = entry;
|
|
41
|
+
const moduleResult = await getFilesFromFolders(moduleName, path.resolve(moduleConfig.src, MODULE_WEB_PATH), defaultFoldersToMap);
|
|
42
|
+
Object.assign(result, moduleResult);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
async function getAllJsVueFilesFromTheme(themeName) {
|
|
47
|
+
let result = {};
|
|
48
|
+
const theme = configResolver.getMagentoConfig().themes[themeName];
|
|
49
|
+
if (!theme) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
if (theme.parent) {
|
|
53
|
+
result = await getAllJsVueFilesFromTheme(theme.parent);
|
|
54
|
+
}
|
|
55
|
+
for (const moduleName of configResolver.getAllMagentoModulesEnabled()) {
|
|
56
|
+
const modulePath = path.resolve(theme.src, moduleName, THEME_MODULE_WEB_PATH);
|
|
57
|
+
const moduleResult = await getFilesFromFolders(moduleName, modulePath, defaultFoldersToMap);
|
|
58
|
+
if (moduleResult) {
|
|
59
|
+
result = deepmerge(result, moduleResult);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const moduleResult = await getFilesFromFolders(configResolver.getMagentoConfig().THEME_FILES_PATH, path.resolve(theme.src, THEME_MODULE_WEB_PATH), defaultFoldersToMap);
|
|
63
|
+
result = deepmerge(result, moduleResult);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function getAllJsVueFilesWithInheritanceCached(themeName) {
|
|
67
|
+
themeName = themeName ?? process.env.CURRENT_THEME;
|
|
68
|
+
const filePath = path.join(PRECOMPILED_FOLDER, themeName, ALL_JS_VUE_FILES_WITH_INHERITANCE_FILE_NAME);
|
|
69
|
+
const { mtimeMs } = fs.statSync(filePath);
|
|
70
|
+
const cached = precompiledFileCache.get(themeName);
|
|
71
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
72
|
+
return cached.data;
|
|
73
|
+
}
|
|
74
|
+
const data = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
75
|
+
precompiledFileCache.set(themeName, { mtimeMs, data });
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
async function getAllJsVueFilesWithInheritance(themeName) {
|
|
79
|
+
themeName = themeName ?? process.env.CURRENT_THEME;
|
|
80
|
+
const key = cacheKey(themeName);
|
|
81
|
+
if (cachedModulesByTheme.has(key)) {
|
|
82
|
+
return cachedModulesByTheme.get(key);
|
|
83
|
+
}
|
|
84
|
+
const allJsVueFilesFromModules = await getAllJsVueFilesFromActiveModules();
|
|
85
|
+
const allJsVueFilesFromThemes = await getAllJsVueFilesFromTheme(themeName);
|
|
86
|
+
const merged = deepmerge(allJsVueFilesFromModules, allJsVueFilesFromThemes);
|
|
87
|
+
cachedModulesByTheme.set(key, merged);
|
|
88
|
+
return merged;
|
|
89
|
+
}
|
|
90
|
+
const moduleConfigByThemeCache = new Map();
|
|
91
|
+
// Drop every cached entry for a theme so the next resolution recomputes from
|
|
92
|
+
// disk. Adding or removing a component/js source changes neither the contract
|
|
93
|
+
// nor its hash, so the (theme, hash)-keyed caches would otherwise serve a stale
|
|
94
|
+
// map; the dev-server watcher calls this before regenerating on a source change.
|
|
95
|
+
function invalidateTheme(themeName) {
|
|
96
|
+
themeName = themeName ?? process.env.CURRENT_THEME;
|
|
97
|
+
const prefix = `${themeName}${CACHE_KEY_SEP}`;
|
|
98
|
+
for (const key of cachedModulesByTheme.keys()) {
|
|
99
|
+
if (key.startsWith(prefix))
|
|
100
|
+
cachedModulesByTheme.delete(key);
|
|
101
|
+
}
|
|
102
|
+
for (const key of moduleConfigByThemeCache.keys()) {
|
|
103
|
+
if (key.startsWith(prefix))
|
|
104
|
+
moduleConfigByThemeCache.delete(key);
|
|
105
|
+
}
|
|
106
|
+
precompiledFileCache.delete(themeName);
|
|
107
|
+
}
|
|
108
|
+
const MODULE_CONFIG_FILE = configResolver.getMagentoConfig().MODULE_CONFIG_FILE;
|
|
109
|
+
/**
|
|
110
|
+
* Gets the theme configuration file path.
|
|
111
|
+
* @param {string} moduleSrc
|
|
112
|
+
* @returns {string} Full path to the configuration file.
|
|
113
|
+
*/
|
|
114
|
+
function getModuleConfigPath(moduleSrc) {
|
|
115
|
+
return path.join(moduleSrc, "view/frontend/web/", MODULE_CONFIG_FILE);
|
|
116
|
+
}
|
|
117
|
+
function resolveFileByTheme(themeName, moduleName, filePath) {
|
|
118
|
+
const theme = configResolver.getMagentoConfig().themes[themeName];
|
|
119
|
+
const fullFilePath = path.join(theme.src, moduleName, "web", filePath);
|
|
120
|
+
if (fs.existsSync(fullFilePath)) {
|
|
121
|
+
return fullFilePath;
|
|
122
|
+
}
|
|
123
|
+
if (theme.parent) {
|
|
124
|
+
return resolveFileByTheme(theme.parent, moduleName, filePath);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
async function resolveModuleConfig(moduleName, themeName) {
|
|
129
|
+
const module = configResolver.getMagentoConfig().modules[moduleName];
|
|
130
|
+
let moduleConfigSourcePath = resolveFileByTheme(themeName, moduleName, MODULE_CONFIG_FILE);
|
|
131
|
+
if (!moduleConfigSourcePath && !module) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (!moduleConfigSourcePath) {
|
|
135
|
+
moduleConfigSourcePath = getModuleConfigPath(module.src);
|
|
136
|
+
}
|
|
137
|
+
if (!fs.existsSync(moduleConfigSourcePath)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
// Importación dinámica común en ESModules
|
|
141
|
+
const moduleConfig = await import(__rewriteRelativeImportExtension(moduleConfigSourcePath));
|
|
142
|
+
return moduleConfig.default ?? moduleConfig;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves the Tailwind configuration for a theme synchronously.
|
|
146
|
+
* Uses a cache system to optimize performance.
|
|
147
|
+
* @param {string} themeName - Name of the theme.
|
|
148
|
+
* @param {object} themeConfig
|
|
149
|
+
* @returns {object|null} Tailwind configuration object.
|
|
150
|
+
*/
|
|
151
|
+
async function getModuleConfigByThemeConfig(themeName, themeConfig) {
|
|
152
|
+
const key = cacheKey(themeName);
|
|
153
|
+
if (moduleConfigByThemeCache.has(key)) {
|
|
154
|
+
return moduleConfigByThemeCache.get(key);
|
|
155
|
+
}
|
|
156
|
+
if (!themeConfig)
|
|
157
|
+
return null;
|
|
158
|
+
const modules = configResolver.getAllMagentoModulesEnabled();
|
|
159
|
+
let modulesConfig = {};
|
|
160
|
+
for (const moduleName of modules) {
|
|
161
|
+
const moduleConfig = await resolveModuleConfig(moduleName, themeName);
|
|
162
|
+
if (!moduleConfig)
|
|
163
|
+
continue;
|
|
164
|
+
modulesConfig = deepmerge(modulesConfig, moduleConfig);
|
|
165
|
+
}
|
|
166
|
+
moduleConfigByThemeCache.set(key, modulesConfig);
|
|
167
|
+
return modulesConfig;
|
|
168
|
+
}
|
|
169
|
+
export default {
|
|
170
|
+
getAllJsVueFilesWithInheritance,
|
|
171
|
+
getAllJsVueFilesWithInheritanceCached,
|
|
172
|
+
getModuleConfigByThemeConfig,
|
|
173
|
+
resolveFileByTheme,
|
|
174
|
+
invalidateTheme,
|
|
175
|
+
};
|
|
176
|
+
export { getModuleConfigByThemeConfig, resolveFileByTheme, getAllJsVueFilesWithInheritance, getAllJsVueFilesWithInheritanceCached, invalidateTheme, };
|
|
177
|
+
//# sourceMappingURL=moduleResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.js","sourceRoot":"","sources":["../../src/core/moduleResolver.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACH,2CAA2C,EAC3C,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,mBAAmB,GAAG;IACxB;QACI,GAAG,EAAE,cAAc,CAAC,gBAAgB,EAAE,CAAC,mBAAmB;QAC1D,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;KAC3B;IACD;QACI,GAAG,EAAE,cAAc,CAAC,gBAAgB,EAAE,CAAC,OAAO;QAC9C,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KACpB;CACJ,CAAC;AAEF,gFAAgF;AAChF,qEAAqE;AACrE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;AAEvC,6EAA6E;AAC7E,0EAA0E;AAC1E,+EAA+E;AAC/E,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC;AAElG,iFAAiF;AACjF,+EAA+E;AAC/E,6CAA6C;AAC7C,MAAM,oBAAoB,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,MAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAChC,IAAI,wBAAwB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO,wBAAwB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,OAAO,GAAG,cAAc,CAAC,2BAA2B,EAAE,CAAC;IAC7D,IAAI,aAAa,GAAG,EAAE,CAAC;IAEvB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QAC/B,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACtE,IAAI,CAAC,YAAY;YAAE,SAAS;QAC5B,aAAa,GAAG,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,wBAAwB,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACjD,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,eAAe;IACX,+BAA+B;IAC/B,qCAAqC;IACrC,4BAA4B;IAC5B,kBAAkB;IAClB,eAAe;CAClB,CAAC;AAEF,OAAO,EACH,4BAA4B,EAC5B,kBAAkB,EAClB,+BAA+B,EAC/B,qCAAqC,EACrC,eAAe,GAClB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function precompileCss(themeName: any): Promise<void>;
|
|
2
|
+
declare function precompileJs(themeName: any): Promise<void>;
|
|
3
|
+
declare function precompileJsconfig(themeName: any): Promise<void>;
|
|
4
|
+
declare function precompileTsconfig(themeName: any): Promise<void>;
|
|
5
|
+
export { precompileCss, precompileJs, precompileJsconfig, precompileTsconfig };
|
|
6
|
+
//# sourceMappingURL=preCompileFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preCompileFiles.d.ts","sourceRoot":"","sources":["../../src/core/preCompileFiles.ts"],"names":[],"mappings":"AAuBA,iBAAe,aAAa,CAAC,SAAS,KAAA,iBAIrC;AAED,iBAAe,YAAY,CAAC,SAAS,KAAA,iBAYpC;AA2BD,iBAAe,kBAAkB,CAAC,SAAS,KAAA,iBAS1C;AAMD,iBAAe,kBAAkB,CAAC,SAAS,KAAA,iBAmB1C;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import moduleResolver from "./moduleResolver.js";
|
|
4
|
+
import { PRECOMPILED_FOLDER, ALL_JS_VUE_FILES_WITH_INHERITANCE_FILE_NAME, } from "../config/default.js";
|
|
5
|
+
import getCssImports from "./cssResolver.js";
|
|
6
|
+
import configResolver from "./configResolver.js";
|
|
7
|
+
import generateJsconfigPaths, { buildThemeJsconfig, buildThemeTsconfig, GENERATED_MARKER, } from "./generateJsconfig.js";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
async function writeToFile(outputPath, content) {
|
|
12
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
13
|
+
await fs.writeFile(outputPath, content, "utf-8");
|
|
14
|
+
}
|
|
15
|
+
async function precompileCss(themeName) {
|
|
16
|
+
const cssContent = await getCssImports(themeName);
|
|
17
|
+
const outputPath = path.resolve(PRECOMPILED_FOLDER, themeName, "precompiled.css");
|
|
18
|
+
await writeToFile(outputPath, cssContent);
|
|
19
|
+
}
|
|
20
|
+
async function precompileJs(themeName) {
|
|
21
|
+
const baseJsPath = path.resolve(__dirname, "../templates/base_main_js_file.js");
|
|
22
|
+
const jsOutputPath = path.resolve(PRECOMPILED_FOLDER, themeName, "precompiled.js");
|
|
23
|
+
await fs.copyFile(baseJsPath, jsOutputPath);
|
|
24
|
+
const vueFilesOutputPath = path.join(PRECOMPILED_FOLDER, themeName, ALL_JS_VUE_FILES_WITH_INHERITANCE_FILE_NAME);
|
|
25
|
+
const vueFiles = await moduleResolver.getAllJsVueFilesWithInheritance(themeName);
|
|
26
|
+
await writeToFile(vueFilesOutputPath, JSON.stringify(vueFiles));
|
|
27
|
+
}
|
|
28
|
+
// Write a build-managed config into the theme src, refusing to clobber a
|
|
29
|
+
// hand-written one: only (re)writes a file carrying our generated marker, or
|
|
30
|
+
// creates one when absent. Write-if-changed so an unchanged file keeps its mtime
|
|
31
|
+
// (no needless TS-server reload).
|
|
32
|
+
async function writeManagedConfig(outputPath, content, manages) {
|
|
33
|
+
let existing;
|
|
34
|
+
try {
|
|
35
|
+
existing = await fs.readFile(outputPath, "utf-8");
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
existing = null;
|
|
39
|
+
}
|
|
40
|
+
if (existing !== null && !existing.startsWith(GENERATED_MARKER)) {
|
|
41
|
+
console.warn(`[mage-obsidian] ${outputPath} is not generated by mage-obsidian; leaving it untouched. ` +
|
|
42
|
+
`Remove it to let the build manage ${manages}.`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (existing === content)
|
|
46
|
+
return;
|
|
47
|
+
await writeToFile(outputPath, content);
|
|
48
|
+
}
|
|
49
|
+
// The theme's jsconfig.json (gitignored) so the author's editor — which opens the
|
|
50
|
+
// theme sources directly — resolves the framework's `Vendor_Module::` specifiers
|
|
51
|
+
// and npm packages via `paths`. Skipped silently if the theme has no src.
|
|
52
|
+
async function precompileJsconfig(themeName) {
|
|
53
|
+
const themeDefinition = configResolver.getThemeDefinition(themeName);
|
|
54
|
+
if (!themeDefinition?.src)
|
|
55
|
+
return;
|
|
56
|
+
const paths = await generateJsconfigPaths(themeName);
|
|
57
|
+
await writeManagedConfig(path.join(themeDefinition.src, "jsconfig.json"), buildThemeJsconfig(paths), "Vendor_Module:: import resolution");
|
|
58
|
+
}
|
|
59
|
+
// The theme's tsconfig.typecheck.json (gitignored) — the assembled `vue-tsc`
|
|
60
|
+
// gate. Same `paths` the build resolves through, so every `Vendor_Module::`
|
|
61
|
+
// resolves and cross-module type seams are actually checked. Not named
|
|
62
|
+
// `tsconfig.json`, so it never shadows the editor jsconfig.
|
|
63
|
+
async function precompileTsconfig(themeName) {
|
|
64
|
+
const themeDefinition = configResolver.getThemeDefinition(themeName);
|
|
65
|
+
if (!themeDefinition?.src)
|
|
66
|
+
return;
|
|
67
|
+
const paths = await generateJsconfigPaths(themeName, { remap: false });
|
|
68
|
+
// The assembled file set to check: every resolved target from the literal
|
|
69
|
+
// `Vendor_Module::` keys, deduped (shorthands point at the same file). Wildcard
|
|
70
|
+
// keys (`*`, `mage-obsidian/*`) are resolution patterns, not source files.
|
|
71
|
+
const files = [
|
|
72
|
+
...new Set(Object.entries(paths)
|
|
73
|
+
.filter(([key]) => !key.includes("*"))
|
|
74
|
+
.flatMap(([, targets]) => targets)),
|
|
75
|
+
];
|
|
76
|
+
await writeManagedConfig(path.join(themeDefinition.src, "tsconfig.typecheck.json"), buildThemeTsconfig(paths, files), "the vue-tsc typecheck gate");
|
|
77
|
+
}
|
|
78
|
+
export { precompileCss, precompileJs, precompileJsconfig, precompileTsconfig };
|
|
79
|
+
//# sourceMappingURL=preCompileFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preCompileFiles.js","sourceRoot":"","sources":["../../src/core/preCompileFiles.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACH,kBAAkB,EAClB,2CAA2C,GAC9C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,qBAAqB,EAAE,EAC1B,kBAAkB,EACl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;IACvC,MAAM,eAAe,GAAG,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACrE,IAAI,CAAC,eAAe,EAAE,GAAG;QAAE,OAAO;IAClC,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,0EAA0E;IAC1E,gFAAgF;IAChF,2EAA2E;IAC3E,MAAM,KAAK,GAAG;QACV,GAAG,IAAI,GAAG,CACN,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aAChB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;aACrC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CACzC;KACJ,CAAC;IACF,MAAM,kBAAkB,CACpB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,yBAAyB,CAAC,EACzD,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,EAChC,4BAA4B,CAC/B,CAAC;AACN,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preCompileMagentoFiles.d.ts","sourceRoot":"","sources":["../../src/core/preCompileMagentoFiles.ts"],"names":[],"mappings":"yBAkBsB,cAAS;AAA/B,wBAeE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { precompileCss, precompileJs, precompileJsconfig, precompileTsconfig, } from "./preCompileFiles.js";
|
|
4
|
+
import configResolver from "./configResolver.js";
|
|
5
|
+
import { PRECOMPILED_FOLDER } from "../config/default.js";
|
|
6
|
+
// Guard per (theme, contract hash): repeated calls within one process (Vite
|
|
7
|
+
// re-invokes the config) skip the work, while a different theme — or the same
|
|
8
|
+
// theme after the contract changed (e.g. a module enabled/disabled mid dev
|
|
9
|
+
// server) — re-precompiles. Keying on the hash, not just the theme name, makes
|
|
10
|
+
// the invalidation dimension explicit instead of relying on process isolation.
|
|
11
|
+
const precompiledByTheme = new Map();
|
|
12
|
+
export default async (themeName) => {
|
|
13
|
+
const contractHash = configResolver.getContractHash();
|
|
14
|
+
if (precompiledByTheme.get(themeName) === contractHash) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const themeDir = path.resolve(PRECOMPILED_FOLDER, themeName);
|
|
18
|
+
// Clean only this theme's output. The old `rm -rf .precompiled/*` wiped
|
|
19
|
+
// every theme, which would corrupt a concurrent or sibling-theme build.
|
|
20
|
+
await fs.rm(themeDir, { recursive: true, force: true });
|
|
21
|
+
await fs.mkdir(themeDir, { recursive: true });
|
|
22
|
+
await precompileJs(themeName);
|
|
23
|
+
await precompileCss(themeName);
|
|
24
|
+
await precompileJsconfig(themeName);
|
|
25
|
+
await precompileTsconfig(themeName);
|
|
26
|
+
precompiledByTheme.set(themeName, contractHash);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=preCompileMagentoFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preCompileMagentoFiles.js","sourceRoot":"","sources":["../../src/core/preCompileMagentoFiles.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EACH,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;AAErC,eAAe,KAAK,EAAE,SAAS,EAAE,EAAE;IAC/B,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,EAAE,CAAC;IACtD,IAAI,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,YAAY,EAAE,CAAC;QACrD,OAAO;IACX,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IAC7D,wEAAwE;IACxE,wEAAwE;IACxE,MAAM,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9B,MAAM,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/B,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACpC,kBAAkB,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeResolverSync.d.ts","sourceRoot":"","sources":["../../src/core/themeResolverSync.ts"],"names":[],"mappings":"AA0CA,wBAAsB,cAAc,CAAC,SAAS,KAAA,gBAkB7C;;;;AAGD,wBAEE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
9
|
+
import path from "path";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import deepmerge from "deepmerge";
|
|
12
|
+
import { THEME_MODULE_WEB_PATH } from "../config/default.js";
|
|
13
|
+
import configResolver from "./configResolver.js";
|
|
14
|
+
const themeConfigCache = new Map();
|
|
15
|
+
const themeConfigPlainCache = new Map();
|
|
16
|
+
function getThemeConfigPath(themeSrc) {
|
|
17
|
+
return path.join(themeSrc, THEME_MODULE_WEB_PATH, configResolver.getMagentoConfig().THEME_CONFIG_FILE);
|
|
18
|
+
}
|
|
19
|
+
async function loadThemeConfig(themeDefinition, themeName) {
|
|
20
|
+
if (!themeDefinition)
|
|
21
|
+
return null;
|
|
22
|
+
if (themeConfigPlainCache.has(themeName))
|
|
23
|
+
return themeConfigPlainCache.get(themeName);
|
|
24
|
+
try {
|
|
25
|
+
const configPath = getThemeConfigPath(themeDefinition.src);
|
|
26
|
+
fs.accessSync(configPath, fs.constants.F_OK);
|
|
27
|
+
let themeConfig = await import(__rewriteRelativeImportExtension(pathToFileUrl(configPath)));
|
|
28
|
+
themeConfig = themeConfig.default ?? themeConfig;
|
|
29
|
+
themeConfigPlainCache.set(themeName, themeConfig);
|
|
30
|
+
return deepmerge({}, themeConfig);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(`Failed to load configuration for theme "${themeName}":`, error.message);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function pathToFileUrl(filePath) {
|
|
38
|
+
const resolvedPath = path.resolve(filePath);
|
|
39
|
+
const fileUrl = new URL(`file://${resolvedPath}`);
|
|
40
|
+
return fileUrl.href;
|
|
41
|
+
}
|
|
42
|
+
export async function getThemeConfig(themeName) {
|
|
43
|
+
if (themeConfigCache.has(themeName))
|
|
44
|
+
return themeConfigCache.get(themeName);
|
|
45
|
+
const themeDefinition = configResolver.getMagentoConfig().themes[themeName];
|
|
46
|
+
if (!themeDefinition)
|
|
47
|
+
return null;
|
|
48
|
+
let themeConfig = await loadThemeConfig(themeDefinition, themeName);
|
|
49
|
+
if (!themeConfig)
|
|
50
|
+
return null;
|
|
51
|
+
themeConfig.includeCssSourceFromParentThemes ??= true;
|
|
52
|
+
themeConfig.ignoredCssFromModules ??= [];
|
|
53
|
+
themeConfig.exposeNpmPackages ??= [];
|
|
54
|
+
if (themeDefinition.parent) {
|
|
55
|
+
const parentConfig = await getThemeConfig(themeDefinition.parent);
|
|
56
|
+
themeConfig = deepmerge(parentConfig || {}, themeConfig);
|
|
57
|
+
}
|
|
58
|
+
themeConfigCache.set(themeName, themeConfig);
|
|
59
|
+
return themeConfig;
|
|
60
|
+
}
|
|
61
|
+
// Export default con todo
|
|
62
|
+
export default {
|
|
63
|
+
getThemeConfig,
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=themeResolverSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeResolverSync.js","sourceRoot":"","sources":["../../src/core/themeResolverSync.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;AACnC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;AAExC,SAAS,kBAAkB,CAAC,QAAQ;IAChC,OAAO,IAAI,CAAC,IAAI,CACZ,QAAQ,EACR,qBAAqB,EACrB,cAAc,CAAC,gBAAgB,EAAE,CAAC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