@forgewp/compiler 0.4.3 → 0.4.4
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/README.md +59 -0
- package/bin/add.js +20 -14
- package/bin/cli.js +145 -70
- package/bin/doctor.js +21 -12
- package/bin/export.js +69 -20
- package/bin/fresh.js +5 -0
- package/bin/i18n-extract.js +3 -10
- package/bin/i18n-translate.js +15 -24
- package/bin/make-block.js +13 -0
- package/bin/make-editable.js +166 -0
- package/bin/make-form.js +131 -0
- package/bin/make-loop.js +40 -43
- package/bin/make-mail.js +27 -0
- package/bin/make-post-type.js +57 -29
- package/bin/make-sandbox.js +62 -11
- package/bin/make-section.js +221 -0
- package/bin/make-shell.js +375 -0
- package/bin/repair.js +14 -26
- package/bin/seed.js +119 -0
- package/bin/sync-routes.js +107 -85
- package/lib/adapters/html-adapter.js +5 -0
- package/lib/adapters/stub-adapter.js +4 -0
- package/lib/add-component.js +153 -92
- package/lib/asset-loader.js +313 -3
- package/lib/assets/asset-graph.js +432 -0
- package/lib/assets/asset-pipeline.js +125 -0
- package/lib/assets/diagnostics-report.js +345 -0
- package/lib/assets/external-fetcher.js +173 -0
- package/lib/assets/font-orchestrator.js +348 -0
- package/lib/assets/font-usage-scanner.js +242 -0
- package/lib/assets/image-optimizer.js +229 -0
- package/lib/assets/index.js +51 -0
- package/lib/assets/preload-generator.js +70 -0
- package/lib/assets/public-url.js +153 -0
- package/lib/block-authoring-help.js +11 -0
- package/lib/blocks/ast-parser.js +67 -0
- package/lib/blocks/discover-blocks.js +146 -0
- package/lib/blocks/editor-scope.js +733 -0
- package/lib/blocks/editor-transpiler.js +1229 -0
- package/lib/blocks/index.js +2838 -0
- package/lib/blocks/php-transpiler.js +4928 -0
- package/lib/blocks/scanner.js +1487 -0
- package/lib/blocks/shared-utils.js +290 -0
- package/lib/blocks/source-sanitize.js +1449 -0
- package/lib/blueprints.js +31 -91
- package/lib/build-assets.js +38 -33
- package/lib/collect-page-template-routes.js +102 -0
- package/lib/collect-static-routes.js +175 -0
- package/lib/diagnostics.js +58 -33
- package/lib/export-theme.js +84 -5
- package/lib/extract-template-content.js +90 -0
- package/lib/forms-preview.js +42 -0
- package/lib/functions/cpt-routing.js +69 -0
- package/lib/functions/forms.js +2461 -0
- package/lib/functions/hydration-enqueuer.js +400 -0
- package/lib/functions/index.js +1623 -0
- package/lib/functions/load-menus.js +112 -0
- package/lib/functions/load-translations.js +148 -0
- package/lib/functions/rest-endpoints.js +2923 -0
- package/lib/functions/routing.js +765 -0
- package/lib/functions/seed-mock-data.js +392 -0
- package/lib/functions/seed-products.js +481 -0
- package/lib/functions/settings-page.js +273 -0
- package/lib/functions/theme-setup.js +494 -0
- package/lib/generate-theme.js +1916 -339
- package/lib/hydration/editable-schemas.js +332 -0
- package/lib/hydration/enter-hidden-initial.js +65 -0
- package/lib/hydration/form-schemas.js +227 -0
- package/lib/hydration/index.js +12 -0
- package/lib/hydration/is-interactive.js +951 -0
- package/lib/hydration/island-split.js +1231 -0
- package/lib/hydration/islands-scanner.js +599 -0
- package/lib/hydration/resolve-island-chunk.js +103 -0
- package/lib/hydration/resolve-island-component.js +52 -0
- package/lib/hydration/rollup-inputs.js +81 -0
- package/lib/hydration/root-class-extractor.js +220 -0
- package/lib/hydration/scan-app-providers.js +154 -0
- package/lib/hydration/static-lint.js +382 -0
- package/lib/hydration/transform.js +257 -0
- package/lib/hydration/uses-block-area.js +49 -0
- package/lib/hydration/utils.js +119 -0
- package/lib/i18n/translation-cache.js +141 -0
- package/lib/icon-registry.js +72 -0
- package/lib/index.d.ts +287 -8
- package/lib/index.js +2 -1
- package/lib/load-config.js +338 -242
- package/lib/mail-templates.js +37 -0
- package/lib/markup-processor.js +388 -102
- package/lib/node-runtime.js +7 -0
- package/lib/page-config-plugin.js +64 -20
- package/lib/php-builders.js +383 -44
- package/lib/react-adapter.js +983 -235
- package/lib/registration-metadata.js +11 -0
- package/lib/render-theme.mts +1410 -616
- package/lib/route-layout.js +76 -0
- package/lib/template-discovery.js +58 -0
- package/lib/theme-compatibility.js +32 -0
- package/lib/validate-export.js +2 -2
- package/lib/validate.js +27 -5
- package/lib/virtual-plugin.js +319 -0
- package/lib/walkthrough.md +26 -0
- package/package.json +16 -5
- package/templates/auth/cms/email-logs.json +9 -0
- package/templates/auth/cms/menus.json +11 -0
- package/templates/auth/cms/mock-data.json +123 -0
- package/templates/auth/cms/roles.json +7 -0
- package/templates/auth/cms/sessions.json +1 -0
- package/templates/auth/cms/site-settings.json +28 -0
- package/templates/auth/cms/translations.json +4 -0
- package/templates/auth/cms/users.json +46 -0
- package/templates/auth/components/forgot-password-form-wrapper.tsx +10 -2
- package/templates/auth/components/login-form-wrapper.tsx +118 -21
- package/templates/auth/components/reset-password-form-wrapper.tsx +10 -2
- package/templates/auth/components/signup-form-wrapper.tsx +2 -2
- package/templates/auth/components/verify-email-view-wrapper.tsx +5 -5
- package/templates/auth/pages/DashboardPage.tsx +1 -4
- package/templates/auth/pages/ForgotPasswordPage.tsx +1 -4
- package/templates/auth/pages/LoginPage.tsx +1 -4
- package/templates/auth/pages/ResetPasswordPage.tsx +1 -4
- package/templates/auth/pages/SignUpPage.tsx +1 -4
- package/templates/auth/pages/VerifyEmailPage.tsx +1 -4
- package/templates/auth/ui/button.tsx +57 -0
- package/templates/auth/ui/card.tsx +76 -0
- package/templates/auth/ui/field.tsx +242 -0
- package/templates/auth/ui/input.tsx +22 -0
- package/templates/auth/ui/label.tsx +24 -0
- package/templates/auth/ui/separator.tsx +31 -0
- package/templates/menus.json +12 -10
- package/templates/users.json +8 -4
- package/templates/wordpress.tsx +690 -245
- package/lib/block-compiler.js +0 -552
- package/lib/functions-builder.js +0 -2970
- package/lib/hydration-scanner.js +0 -833
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const SUPPORTED_NODE_RANGE = '^22.18.0 || >=24.11.0';
|
|
2
|
+
|
|
3
|
+
export function isSupportedNode(version = process.versions.node) {
|
|
4
|
+
if (!/^\d+\.\d+\.\d+$/.test(version)) return false;
|
|
5
|
+
const [major, minor] = version.split('.').map(Number);
|
|
6
|
+
return (major === 22 && minor >= 18) || (major === 24 && minor >= 11) || major > 24;
|
|
7
|
+
}
|
|
@@ -1,40 +1,84 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { transformThemeFile } from './hydration/index.js';
|
|
2
|
+
import { scanAndGenerateBlocks } from './blocks/index.js';
|
|
3
|
+
import { splitInteractiveIslands } from './hydration/island-split.js';
|
|
4
|
+
import { hasContentOverride, readComponentSource } from './hydration/is-interactive.js';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
|
-
* Custom Vite Plugin to statically parse "export const
|
|
5
|
-
* and dynamically inject useWpPageProtect(
|
|
7
|
+
* Custom Vite Plugin to statically parse "export const pageConfig = { ... }" configs in pages,
|
|
8
|
+
* and dynamically inject useWpPageProtect(pageConfig) hook call at component startup.
|
|
9
|
+
*
|
|
10
|
+
* It also automatically detects interactive components inside static parents and wraps them in
|
|
11
|
+
* <Hydrate> (automatic island detection) and wraps them in <WpAuthProvider> if they use auth hooks.
|
|
6
12
|
*/
|
|
7
13
|
export function forgewpPageConfigPlugin() {
|
|
14
|
+
let themeRoot = process.cwd();
|
|
8
15
|
return {
|
|
9
16
|
name: 'forgewp-page-config',
|
|
17
|
+
configResolved(config) {
|
|
18
|
+
themeRoot = config.root;
|
|
19
|
+
},
|
|
20
|
+
buildStart() {
|
|
21
|
+
// Must run BEFORE scanAndGenerateBlocks and before Rollup resolves its
|
|
22
|
+
// entry inputs (getHydrationRollupInputs / islands-scanner.js's Smart
|
|
23
|
+
// Discovery scan the filesystem) — any auto-split island file needs to
|
|
24
|
+
// exist on disk by then to be picked up as its own build entry.
|
|
25
|
+
try {
|
|
26
|
+
splitInteractiveIslands(themeRoot);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.error('[ForgeWP Compiler] Error running splitInteractiveIslands at build start:', err.message);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
scanAndGenerateBlocks(themeRoot);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error('[ForgeWP Compiler] Error running scanAndGenerateBlocks at build start:', err.message);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
10
36
|
transform(code, id) {
|
|
11
|
-
// Check if it's a page component inside src/app/pages/
|
|
12
37
|
const normalizedPath = id.replace(/\\/g, '/');
|
|
13
|
-
if (
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (!code.includes('export const pageConfig')) {
|
|
38
|
+
if (normalizedPath.includes('node_modules')) {
|
|
17
39
|
return null;
|
|
18
40
|
}
|
|
19
41
|
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
const fileThemeRoot = normalizedPath.includes('/src/')
|
|
43
|
+
? id.substring(0, normalizedPath.indexOf('/src/'))
|
|
44
|
+
: themeRoot;
|
|
22
45
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
// If this file was auto-split, substitute the static shell for the raw
|
|
47
|
+
// code Vite just read from disk BEFORE anything below runs — every
|
|
48
|
+
// downstream step (the @forgewp-block re-scan, transformThemeFile's
|
|
49
|
+
// Hydrate auto-wrap, and the final returned module code) must see the
|
|
50
|
+
// shell, not the dev's original, still-fully-interactive file content.
|
|
51
|
+
// Only substitute when THIS path has an actual registered override —
|
|
52
|
+
// never infer one from "a fresh disk read differs from what Vite gave
|
|
53
|
+
// us," since Vite's own code may already be preprocessed by an earlier
|
|
54
|
+
// plugin (that alone would look like a difference for every file, not
|
|
55
|
+
// just split ones, and reverting it breaks Rollup's import analysis).
|
|
56
|
+
let effectiveCode = code;
|
|
57
|
+
if (hasContentOverride(id)) {
|
|
58
|
+
try {
|
|
59
|
+
effectiveCode = readComponentSource(id);
|
|
60
|
+
} catch {}
|
|
28
61
|
}
|
|
29
62
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
63
|
+
// Trigger real-time block generation if the edited file defines a block
|
|
64
|
+
if (effectiveCode.includes('@forgewp-block')) {
|
|
65
|
+
try {
|
|
66
|
+
scanAndGenerateBlocks(fileThemeRoot);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error('[ForgeWP Compiler] Error running scanAndGenerateBlocks during transform:', err.message);
|
|
69
|
+
}
|
|
35
70
|
}
|
|
36
71
|
|
|
72
|
+
try {
|
|
73
|
+
const transformed = transformThemeFile(effectiveCode, id, fileThemeRoot);
|
|
74
|
+
if (transformed !== code) {
|
|
75
|
+
return { code: transformed, map: null };
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error(`[ForgeWP Compiler] Error transforming ${id}:`, err);
|
|
79
|
+
}
|
|
37
80
|
return null;
|
|
38
81
|
}
|
|
39
82
|
};
|
|
40
83
|
}
|
|
84
|
+
|