soinproduction-gutenberg 0.1.3 → 0.1.5

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 (96) hide show
  1. package/README.md +12 -0
  2. package/adapters/next/runtime.php +25 -0
  3. package/adapters/wordpress/blueprint.ts +2 -2
  4. package/adapters/wordpress/renderer.php +12 -0
  5. package/bootstrap.php +7 -3
  6. package/components/social-links/index.tsx +29 -0
  7. package/components/social-links/manifest.json +4 -0
  8. package/dist/adapters/next/runtime.php +25 -0
  9. package/dist/adapters/wordpress/blueprint.d.ts +2 -0
  10. package/dist/adapters/wordpress/blueprint.js +3 -2
  11. package/dist/adapters/wordpress/blueprint.js.map +2 -2
  12. package/dist/adapters/wordpress/renderer.php +12 -0
  13. package/dist/bootstrap.php +7 -3
  14. package/dist/components/social-links/index.d.ts +6 -0
  15. package/dist/components/social-links/index.js +25 -0
  16. package/dist/components/social-links/index.js.map +7 -0
  17. package/dist/components/social-links/manifest.json +4 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +2 -2
  21. package/dist/tooling/build-editor.mjs +1 -1
  22. package/dist/tooling/build-package.mjs +1 -1
  23. package/dist/tooling/cli.mjs +94 -29
  24. package/dist/tooling/create-module.mjs +3 -4
  25. package/dist/tooling/create-post-type.mjs +116 -0
  26. package/dist/tooling/create-section.mjs +16 -23
  27. package/dist/tooling/dev.mjs +59 -0
  28. package/dist/tooling/init-theme.mjs +183 -0
  29. package/dist/tooling/next-runtime.mjs +61 -0
  30. package/dist/tooling/prepare-project.mjs +28 -0
  31. package/dist/tooling/render-module.mjs +7 -7
  32. package/dist/tooling/smoke-package.mjs +5 -3
  33. package/dist/tooling/sync-blocks.mjs +6 -2
  34. package/dist/tooling/watch-editor.mjs +122 -0
  35. package/dist/wordpress/admin/appearance.php +24 -0
  36. package/dist/wordpress/api/content.php +122 -0
  37. package/dist/wordpress/api/modals.php +6 -0
  38. package/dist/wordpress/blocks.php +23 -0
  39. package/dist/wordpress/bootstrap.php +26 -0
  40. package/dist/wordpress/breakpoints.php +37 -0
  41. package/dist/wordpress/documents.php +142 -0
  42. package/dist/wordpress/editor.php +69 -0
  43. package/dist/wordpress/examples/post-type.example.php +65 -0
  44. package/dist/wordpress/frontend.php +7 -0
  45. package/dist/wordpress/integrations.php +60 -0
  46. package/dist/wordpress/options/archives.php +40 -0
  47. package/dist/wordpress/patterns.php +19 -0
  48. package/dist/wordpress/post-types/collections.php +77 -0
  49. package/dist/wordpress/post-types/modals.php +91 -0
  50. package/dist/wordpress/post-types/site-parts.php +25 -0
  51. package/dist/wordpress/rendering/bootstrap.php +95 -0
  52. package/dist/wordpress/rendering/performance.php +67 -0
  53. package/dist/wordpress/routing/archives.php +120 -0
  54. package/dist/wordpress/routing/headless.php +18 -0
  55. package/dist/wordpress/seo.php +110 -0
  56. package/dist/wordpress/setup.php +11 -0
  57. package/dist/wordpress/svg.php +36 -0
  58. package/index.tsx +1 -0
  59. package/package.json +2 -1
  60. package/tooling/build-editor.mjs +1 -1
  61. package/tooling/build-package.mjs +1 -1
  62. package/tooling/cli.mjs +94 -29
  63. package/tooling/create-module.mjs +3 -4
  64. package/tooling/create-post-type.mjs +116 -0
  65. package/tooling/create-section.mjs +16 -23
  66. package/tooling/dev.mjs +59 -0
  67. package/tooling/init-theme.mjs +183 -0
  68. package/tooling/next-runtime.mjs +61 -0
  69. package/tooling/prepare-project.mjs +28 -0
  70. package/tooling/render-module.mjs +7 -7
  71. package/tooling/smoke-package.mjs +5 -3
  72. package/tooling/sync-blocks.mjs +6 -2
  73. package/tooling/watch-editor.mjs +122 -0
  74. package/wordpress/admin/appearance.php +24 -0
  75. package/wordpress/api/content.php +122 -0
  76. package/wordpress/api/modals.php +6 -0
  77. package/wordpress/blocks.php +23 -0
  78. package/wordpress/bootstrap.php +26 -0
  79. package/wordpress/breakpoints.php +37 -0
  80. package/wordpress/documents.php +142 -0
  81. package/wordpress/editor.php +69 -0
  82. package/wordpress/examples/post-type.example.php +65 -0
  83. package/wordpress/frontend.php +7 -0
  84. package/wordpress/integrations.php +60 -0
  85. package/wordpress/options/archives.php +40 -0
  86. package/wordpress/patterns.php +19 -0
  87. package/wordpress/post-types/collections.php +77 -0
  88. package/wordpress/post-types/modals.php +91 -0
  89. package/wordpress/post-types/site-parts.php +25 -0
  90. package/wordpress/rendering/bootstrap.php +95 -0
  91. package/wordpress/rendering/performance.php +67 -0
  92. package/wordpress/routing/archives.php +120 -0
  93. package/wordpress/routing/headless.php +18 -0
  94. package/wordpress/seo.php +110 -0
  95. package/wordpress/setup.php +11 -0
  96. package/wordpress/svg.php +36 -0
package/README.md CHANGED
@@ -74,3 +74,15 @@ npm pack --dry-run
74
74
  CI checks types, isolated component-connection tests, package exports, PHP syntax and packaging. Push a matching `vX.Y.Z` tag to publish version `X.Y.Z` automatically. See [RELEASING.md](RELEASING.md) for one-time npm trusted-publisher setup.
75
75
 
76
76
  Source is published without an open-source license grant (`UNLICENSED`).
77
+
78
+ ## Project commands
79
+
80
+ Use the installed `soinproduction-kit` binary in npm scripts:
81
+
82
+ ```json
83
+ {"scripts":{"dev":"soinproduction-kit dev","start":"soinproduction-kit start","create:component":"soinproduction-kit create component","create:section":"soinproduction-kit create section","create:layout":"soinproduction-kit create layout","new:section":"soinproduction-kit new section","render:module":"soinproduction-kit render"}}
84
+ ```
85
+
86
+ `dev` and `start` select a free port automatically. Explicit `--port`/`-p` or `PORT` take precedence. Development propagates the actual origin to site/forms configuration and writes `build/next-server.json`; the Next PHP adapter loaded by `bootstrap.php` reads it for local frontend URLs. Public deployment URLs stay configured. Override the project-relative runtime path with `runtime.file` in `kit.config.json`.
87
+
88
+ Generators prepare the installed kit automatically, then create the component schema, renderer, editor, PHP registration, styles and preview in the project. `new section` creates a declarative section. Use `--no-build` to generate without an editor build. `render` regenerates module markup from its schema. All commands accept `--project PATH`. The project owns component/section selection and optional `adapters.contentRenderer` / `adapters.editorAdapter` objects (`from`, `export`); portable defaults are provided. Preparation reuses unchanged package sources and refreshes generated connections without disturbing a running Next watcher.
@@ -0,0 +1,25 @@
1
+ <?php
2
+ namespace SiteTheme\Kit;
3
+ defined('ABSPATH') || exit;
4
+
5
+ /** A local Next process advertises its actual port; public deployments use the configured URL. */
6
+ function frontend_origin(?string $configured = null, ?string $runtime_file = null): string {
7
+ $configured = rtrim($configured ?? (defined('SITE_FRONTEND_URL') ? SITE_FRONTEND_URL : ''), '/');
8
+ $local = ['127.0.0.1', 'localhost', '[::1]', '::1'];
9
+ if (!in_array(parse_url($configured, PHP_URL_HOST), $local, true)) return $configured;
10
+ $root = dirname(__DIR__, 3);
11
+ $config_file = $root . '/kit.config.json';
12
+ $config = is_readable($config_file) ? json_decode((string)file_get_contents($config_file), true) : [];
13
+ $relative = $config['runtime']['file'] ?? 'build/next-server.json';
14
+ if ($runtime_file === null && (!is_string($relative) || str_starts_with($relative, '/') || in_array('..', explode('/', str_replace('\\', '/', $relative)), true))) return $configured;
15
+ $file = $runtime_file ?? $root . '/' . $relative;
16
+ $runtime = is_readable($file) ? json_decode((string)file_get_contents($file), true) : null;
17
+ if (!is_array($runtime) || !is_string($runtime['origin'] ?? null) || !is_int($runtime['pid'] ?? null) || $runtime['pid'] < 1) return $configured;
18
+ $url = parse_url($runtime['origin']);
19
+ if (!is_array($url) || !in_array($url['scheme'] ?? '', ['http', 'https'], true)
20
+ || !in_array($url['host'] ?? '', $local, true) || empty($url['port'])
21
+ || $url['port'] < 1 || $url['port'] > 65535 || isset($url['user']) || isset($url['pass'])
22
+ || isset($url['query']) || isset($url['fragment']) || !empty($url['path'])) return $configured;
23
+ if (function_exists('posix_kill') && !@posix_kill((int)$runtime['pid'], 0) && posix_get_last_error() === 3) return $configured;
24
+ return rtrim($runtime['origin'], '/');
25
+ }
@@ -3,7 +3,7 @@ import {Children, Fragment, isValidElement, type ReactNode} from 'react';
3
3
  const marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});
4
4
  export const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),
5
5
  Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),
6
- Background = marker('Background'), Buttons = marker('Buttons'), Button = marker('Button'), List = marker('List'),
6
+ Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),
7
7
  PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),
8
8
  RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),
9
9
  RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),
@@ -26,7 +26,7 @@ function describe(node: ReactNode): any[] {
26
26
 
27
27
  export function section(meta: any, View: () => ReactNode) {
28
28
  const template = describe(View());
29
- const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','Button','Show','Toggle','Choice']);
29
+ const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);
30
30
  const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
31
31
  return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};
32
32
  }
@@ -43,6 +43,17 @@ function button(array $value,?string $fallback=null,array $site=[]): string {
43
43
  }
44
44
  return tag('a',['href'=>esc_url($url),'class'=>$class,'data-modal-plan'=>$value['plan']??null],$label);
45
45
  }
46
+ function social_links(array $links, string $class = '', string $style = 'text'): string {
47
+ $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
48
+ $html = '';
49
+ foreach ($labels as $network => $label) {
50
+ $url = $links[$network] ?? '';
51
+ if (is_string($url) && preg_match('~^https?://[^/]+~i', $url)) {
52
+ $html .= button(['text'=>$label, 'url'=>$url], $style);
53
+ }
54
+ }
55
+ return $html === '' ? '' : tag('div', ['class'=>$class], $html);
56
+ }
46
57
  /** Mirrors `flowPlacement` in frontend/kit/flow-layout.ts. */
47
58
  function flow_placement(int $grid,array $column,array $palette,int $max_col): array {
48
59
  $span=min($grid,max(1,(int)($column['span']??0)?:(int)($palette['span']??0)?:(int)round($grid/max(1,$max_col))));
@@ -161,6 +172,7 @@ function node(array $node,array $context): string {
161
172
  case 'Show':
162
173
  $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?nodes($children,$context):'';
163
174
  case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
175
+ case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
164
176
  case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>$class],$html);
165
177
  case 'Background':case 'Media':
166
178
  if(!$value)return '';if(is_string($value)||($value['type']??'image')==='image')return image(is_string($value)?$value:['url'=>$value['image']??$value['url']??'','alt'=>$value['alt']??''],$class?:'absolute inset-0 h-full w-full object-cover');
package/bootstrap.php CHANGED
@@ -2,7 +2,11 @@
2
2
  namespace SiteTheme\Kit;
3
3
  defined('ABSPATH') || exit;
4
4
  /** One host connection; generated entries belong to components and modules. */
5
- require_once __DIR__.'/admin-ui/bootstrap.php';
6
- foreach (require __DIR__.'/generated/modules.php' as $entry) {
7
- require_once __DIR__.'/'.$entry;
5
+ require_once __DIR__.'/adapters/next/runtime.php';
6
+ if (function_exists('add_action')) {
7
+ require_once __DIR__.'/admin-ui/bootstrap.php';
8
+ foreach (require __DIR__.'/generated/modules.php' as $entry) {
9
+ require_once __DIR__.'/'.$entry;
10
+ }
8
11
  }
12
+ require_once __DIR__.'/wordpress/bootstrap.php';
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+
3
+ import { useSite } from '../../core/content/context.js';
4
+ import { buttonClasses } from '../../core/ui/button-appearance.js';
5
+
6
+ const networks = {
7
+ instagram: 'Instagram',
8
+ facebook: 'Facebook',
9
+ telegram: 'Telegram',
10
+ youtube: 'YouTube',
11
+ tiktok: 'TikTok',
12
+ linkedin: 'LinkedIn',
13
+ };
14
+
15
+ type SocialLinksProps = {
16
+ className?: string;
17
+ buttonStyle?: string;
18
+ };
19
+
20
+ export function SocialLinks({ className, buttonStyle = 'text' }: SocialLinksProps) {
21
+ const links = useSite().settings?.socialLinks ?? {};
22
+ const buttons = Object.entries(networks).flatMap(([network, label]) => {
23
+ const url = links[network];
24
+ if (typeof url !== 'string' || !/^https?:\/\/[^/]+/i.test(url)) return [];
25
+ return <a key={network} href={url} className={buttonClasses("is-style-studio-" + buttonStyle)}>{label}</a>;
26
+ });
27
+
28
+ return buttons.length ? <div className={className}>{buttons}</div> : null;
29
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "social-links",
3
+ "dependencies": []
4
+ }
@@ -0,0 +1,25 @@
1
+ <?php
2
+ namespace SiteTheme\Kit;
3
+ defined('ABSPATH') || exit;
4
+
5
+ /** A local Next process advertises its actual port; public deployments use the configured URL. */
6
+ function frontend_origin(?string $configured = null, ?string $runtime_file = null): string {
7
+ $configured = rtrim($configured ?? (defined('SITE_FRONTEND_URL') ? SITE_FRONTEND_URL : ''), '/');
8
+ $local = ['127.0.0.1', 'localhost', '[::1]', '::1'];
9
+ if (!in_array(parse_url($configured, PHP_URL_HOST), $local, true)) return $configured;
10
+ $root = dirname(__DIR__, 3);
11
+ $config_file = $root . '/kit.config.json';
12
+ $config = is_readable($config_file) ? json_decode((string)file_get_contents($config_file), true) : [];
13
+ $relative = $config['runtime']['file'] ?? 'build/next-server.json';
14
+ if ($runtime_file === null && (!is_string($relative) || str_starts_with($relative, '/') || in_array('..', explode('/', str_replace('\\', '/', $relative)), true))) return $configured;
15
+ $file = $runtime_file ?? $root . '/' . $relative;
16
+ $runtime = is_readable($file) ? json_decode((string)file_get_contents($file), true) : null;
17
+ if (!is_array($runtime) || !is_string($runtime['origin'] ?? null) || !is_int($runtime['pid'] ?? null) || $runtime['pid'] < 1) return $configured;
18
+ $url = parse_url($runtime['origin']);
19
+ if (!is_array($url) || !in_array($url['scheme'] ?? '', ['http', 'https'], true)
20
+ || !in_array($url['host'] ?? '', $local, true) || empty($url['port'])
21
+ || $url['port'] < 1 || $url['port'] > 65535 || isset($url['user']) || isset($url['pass'])
22
+ || isset($url['query']) || isset($url['fragment']) || !empty($url['path'])) return $configured;
23
+ if (function_exists('posix_kill') && !@posix_kill((int)$runtime['pid'], 0) && posix_get_last_error() === 3) return $configured;
24
+ return rtrim($runtime['origin'], '/');
25
+ }
@@ -15,6 +15,8 @@ export declare const Section: ((_props: any) => null) & {
15
15
  kitName: string;
16
16
  }, Buttons: ((_props: any) => null) & {
17
17
  kitName: string;
18
+ }, SocialLinks: ((_props: any) => null) & {
19
+ kitName: string;
18
20
  }, Button: ((_props: any) => null) & {
19
21
  kitName: string;
20
22
  }, List: ((_props: any) => null) & {
@@ -1,6 +1,6 @@
1
1
  import { Children, Fragment, isValidElement } from "react";
2
2
  const marker = (name) => Object.assign((_props) => null, { kitName: name });
3
- const Section = marker("Section"), Text = marker("Text"), Heading = marker("Heading"), Paragraphs = marker("Paragraphs"), Image = marker("Image"), Icon = marker("Icon"), Background = marker("Background"), Buttons = marker("Buttons"), Button = marker("Button"), List = marker("List"), PricingPlans = marker("PricingPlans"), ReviewsCarousel = marker("ReviewsCarousel"), Form = marker("Form"), Records = marker("Records"), RecordEdit = marker("RecordEdit"), RecordImage = marker("RecordImage"), RecordDate = marker("RecordDate"), RecordTitle = marker("RecordTitle"), RecordExcerpt = marker("RecordExcerpt"), RecordLink = marker("RecordLink"), RecordIndex = marker("RecordIndex"), Drag = marker("Drag"), Cols = marker("Cols"), Toggle = marker("Toggle"), Choice = marker("Choice"), Show = marker("Show"), Area = marker("Area"), Gallery = marker("Gallery"), Accordion = marker("Accordion"), AccordionItem = marker("AccordionItem"), AccordionTrigger = marker("AccordionTrigger"), AccordionContent = marker("AccordionContent"), Slider = marker("Slider"), SliderButton = marker("SliderButton"), SliderPagination = marker("SliderPagination"), RecordText = marker("RecordText"), RecordContent = marker("RecordContent"), Media = marker("Media");
3
+ const Section = marker("Section"), Text = marker("Text"), Heading = marker("Heading"), Paragraphs = marker("Paragraphs"), Image = marker("Image"), Icon = marker("Icon"), Background = marker("Background"), Buttons = marker("Buttons"), SocialLinks = marker("SocialLinks"), Button = marker("Button"), List = marker("List"), PricingPlans = marker("PricingPlans"), ReviewsCarousel = marker("ReviewsCarousel"), Form = marker("Form"), Records = marker("Records"), RecordEdit = marker("RecordEdit"), RecordImage = marker("RecordImage"), RecordDate = marker("RecordDate"), RecordTitle = marker("RecordTitle"), RecordExcerpt = marker("RecordExcerpt"), RecordLink = marker("RecordLink"), RecordIndex = marker("RecordIndex"), Drag = marker("Drag"), Cols = marker("Cols"), Toggle = marker("Toggle"), Choice = marker("Choice"), Show = marker("Show"), Area = marker("Area"), Gallery = marker("Gallery"), Accordion = marker("Accordion"), AccordionItem = marker("AccordionItem"), AccordionTrigger = marker("AccordionTrigger"), AccordionContent = marker("AccordionContent"), Slider = marker("Slider"), SliderButton = marker("SliderButton"), SliderPagination = marker("SliderPagination"), RecordText = marker("RecordText"), RecordContent = marker("RecordContent"), Media = marker("Media");
4
4
  function describe(node) {
5
5
  return Children.toArray(node).flatMap((child) => {
6
6
  if (!isValidElement(child)) return [{ type: "#text", value: String(child) }];
@@ -15,7 +15,7 @@ function describe(node) {
15
15
  }
16
16
  function section(meta, View) {
17
17
  const template = describe(View());
18
- const staticTypes = /* @__PURE__ */ new Set(["#text", "Section", "Text", "Heading", "Paragraphs", "Image", "Icon", "Background", "Buttons", "Button", "Show", "Toggle", "Choice"]);
18
+ const staticTypes = /* @__PURE__ */ new Set(["#text", "Section", "Text", "Heading", "Paragraphs", "Image", "Icon", "Background", "Buttons", "SocialLinks", "Button", "Show", "Toggle", "Choice"]);
19
19
  const isStatic = (nodes) => nodes.every((node) => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
20
20
  return { name: "site/" + meta.slug, title: meta.title, template, static: isStatic(template) };
21
21
  }
@@ -56,6 +56,7 @@ export {
56
56
  Slider,
57
57
  SliderButton,
58
58
  SliderPagination,
59
+ SocialLinks,
59
60
  Text,
60
61
  Toggle,
61
62
  section
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../adapters/wordpress/blueprint.ts"],
4
- "sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const props = {...child.props as any};\n delete props.children;\n const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;\n if (!type) throw new Error('WordPress compiler: unsupported React component. Supply an adapter before using it in a portable section.');\n for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);\n return [{type, props, children: describe((child.props as any).children)}];\n });\n}\n\nexport function section(meta: any, View: () => ReactNode) {\n const template = describe(View());\n const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','Button','Show','Toggle','Choice']);\n const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));\n return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};\n}\n"],
5
- "mappings": "AAAA,SAAQ,UAAU,UAAU,sBAAqC;AAEjE,MAAM,SAAS,CAAC,SAAiB,OAAO,OAAO,CAAC,WAAgB,MAAM,EAAC,SAAS,KAAI,CAAC;AAC9E,MAAM,UAAU,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACvF,aAAa,OAAO,YAAY,GAAG,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,MAAM,GAChF,aAAa,OAAO,YAAY,GAAG,UAAU,OAAO,SAAS,GAAG,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAC/G,eAAe,OAAO,cAAc,GAAG,kBAAkB,OAAO,iBAAiB,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GAAG,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAC7M,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAAG,gBAAgB,OAAO,eAAe,GAAG,aAAa,OAAO,YAAY,GACjJ,cAAc,OAAO,aAAa,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,OAAO,QAAQ,GAC3G,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACnG,YAAY,OAAO,WAAW,GAAG,gBAAgB,OAAO,eAAe,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,mBAAmB,OAAO,kBAAkB,GACrK,SAAS,OAAO,QAAQ,GAAG,eAAe,OAAO,cAAc,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,aAAa,OAAO,YAAY,GAAG,gBAAgB,OAAO,eAAe,GAAG,QAAQ,OAAO,OAAO;AAEvN,SAAS,SAAS,MAAwB;AACtC,SAAO,SAAS,QAAQ,IAAI,EAAE,QAAQ,WAAS;AAC3C,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO,CAAC,EAAC,MAAM,SAAS,OAAO,OAAO,KAAK,EAAC,CAAC;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,SAAU,MAAM,MAAc,QAAQ;AAC1E,UAAM,QAAQ,EAAC,GAAG,MAAM,MAAY;AACpC,WAAO,MAAM;AACb,UAAM,OAAO,OAAO,MAAM,SAAS,WAAW,MAAM,OAAQ,MAAM,KAAa;AAC/E,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2GAA2G;AACtI,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,OAAO,UAAU,WAAY,OAAM,IAAI,MAAM,gCAAgC,GAAG,uBAAuB;AAC7J,WAAO,CAAC,EAAC,MAAM,OAAO,UAAU,SAAU,MAAM,MAAc,QAAQ,EAAC,CAAC;AAAA,EAC5E,CAAC;AACL;AAEO,SAAS,QAAQ,MAAW,MAAuB;AACtD,QAAM,WAAW,SAAS,KAAK,CAAC;AAChC,QAAM,cAAc,oBAAI,IAAI,CAAC,SAAQ,WAAU,QAAO,WAAU,cAAa,SAAQ,QAAO,cAAa,WAAU,UAAS,QAAO,UAAS,QAAQ,CAAC;AACrJ,QAAM,WAAW,CAAC,UAAwB,MAAM,MAAM,WAAS,YAAY,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;AACvJ,SAAO,EAAC,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,SAAS,QAAQ,EAAC;AAC9F;",
4
+ "sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const props = {...child.props as any};\n delete props.children;\n const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;\n if (!type) throw new Error('WordPress compiler: unsupported React component. Supply an adapter before using it in a portable section.');\n for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);\n return [{type, props, children: describe((child.props as any).children)}];\n });\n}\n\nexport function section(meta: any, View: () => ReactNode) {\n const template = describe(View());\n const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);\n const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));\n return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};\n}\n"],
5
+ "mappings": "AAAA,SAAQ,UAAU,UAAU,sBAAqC;AAEjE,MAAM,SAAS,CAAC,SAAiB,OAAO,OAAO,CAAC,WAAgB,MAAM,EAAC,SAAS,KAAI,CAAC;AAC9E,MAAM,UAAU,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACvF,aAAa,OAAO,YAAY,GAAG,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,MAAM,GAChF,aAAa,OAAO,YAAY,GAAG,UAAU,OAAO,SAAS,GAAG,cAAc,OAAO,aAAa,GAAG,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GACpJ,eAAe,OAAO,cAAc,GAAG,kBAAkB,OAAO,iBAAiB,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GAAG,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAC7M,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAAG,gBAAgB,OAAO,eAAe,GAAG,aAAa,OAAO,YAAY,GACjJ,cAAc,OAAO,aAAa,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,OAAO,QAAQ,GAC3G,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACnG,YAAY,OAAO,WAAW,GAAG,gBAAgB,OAAO,eAAe,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,mBAAmB,OAAO,kBAAkB,GACrK,SAAS,OAAO,QAAQ,GAAG,eAAe,OAAO,cAAc,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,aAAa,OAAO,YAAY,GAAG,gBAAgB,OAAO,eAAe,GAAG,QAAQ,OAAO,OAAO;AAEvN,SAAS,SAAS,MAAwB;AACtC,SAAO,SAAS,QAAQ,IAAI,EAAE,QAAQ,WAAS;AAC3C,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO,CAAC,EAAC,MAAM,SAAS,OAAO,OAAO,KAAK,EAAC,CAAC;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,SAAU,MAAM,MAAc,QAAQ;AAC1E,UAAM,QAAQ,EAAC,GAAG,MAAM,MAAY;AACpC,WAAO,MAAM;AACb,UAAM,OAAO,OAAO,MAAM,SAAS,WAAW,MAAM,OAAQ,MAAM,KAAa;AAC/E,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2GAA2G;AACtI,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,OAAO,UAAU,WAAY,OAAM,IAAI,MAAM,gCAAgC,GAAG,uBAAuB;AAC7J,WAAO,CAAC,EAAC,MAAM,OAAO,UAAU,SAAU,MAAM,MAAc,QAAQ,EAAC,CAAC;AAAA,EAC5E,CAAC;AACL;AAEO,SAAS,QAAQ,MAAW,MAAuB;AACtD,QAAM,WAAW,SAAS,KAAK,CAAC;AAChC,QAAM,cAAc,oBAAI,IAAI,CAAC,SAAQ,WAAU,QAAO,WAAU,cAAa,SAAQ,QAAO,cAAa,WAAU,eAAc,UAAS,QAAO,UAAS,QAAQ,CAAC;AACnK,QAAM,WAAW,CAAC,UAAwB,MAAM,MAAM,WAAS,YAAY,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;AACvJ,SAAO,EAAC,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,SAAS,QAAQ,EAAC;AAC9F;",
6
6
  "names": []
7
7
  }
@@ -43,6 +43,17 @@ function button(array $value,?string $fallback=null,array $site=[]): string {
43
43
  }
44
44
  return tag('a',['href'=>esc_url($url),'class'=>$class,'data-modal-plan'=>$value['plan']??null],$label);
45
45
  }
46
+ function social_links(array $links, string $class = '', string $style = 'text'): string {
47
+ $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
48
+ $html = '';
49
+ foreach ($labels as $network => $label) {
50
+ $url = $links[$network] ?? '';
51
+ if (is_string($url) && preg_match('~^https?://[^/]+~i', $url)) {
52
+ $html .= button(['text'=>$label, 'url'=>$url], $style);
53
+ }
54
+ }
55
+ return $html === '' ? '' : tag('div', ['class'=>$class], $html);
56
+ }
46
57
  /** Mirrors `flowPlacement` in frontend/kit/flow-layout.ts. */
47
58
  function flow_placement(int $grid,array $column,array $palette,int $max_col): array {
48
59
  $span=min($grid,max(1,(int)($column['span']??0)?:(int)($palette['span']??0)?:(int)round($grid/max(1,$max_col))));
@@ -161,6 +172,7 @@ function node(array $node,array $context): string {
161
172
  case 'Show':
162
173
  $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?nodes($children,$context):'';
163
174
  case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
175
+ case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
164
176
  case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>$class],$html);
165
177
  case 'Background':case 'Media':
166
178
  if(!$value)return '';if(is_string($value)||($value['type']??'image')==='image')return image(is_string($value)?$value:['url'=>$value['image']??$value['url']??'','alt'=>$value['alt']??''],$class?:'absolute inset-0 h-full w-full object-cover');
@@ -2,7 +2,11 @@
2
2
  namespace SiteTheme\Kit;
3
3
  defined('ABSPATH') || exit;
4
4
  /** One host connection; generated entries belong to components and modules. */
5
- require_once __DIR__.'/admin-ui/bootstrap.php';
6
- foreach (require __DIR__.'/generated/modules.php' as $entry) {
7
- require_once __DIR__.'/'.$entry;
5
+ require_once __DIR__.'/adapters/next/runtime.php';
6
+ if (function_exists('add_action')) {
7
+ require_once __DIR__.'/admin-ui/bootstrap.php';
8
+ foreach (require __DIR__.'/generated/modules.php' as $entry) {
9
+ require_once __DIR__.'/'.$entry;
10
+ }
8
11
  }
12
+ require_once __DIR__.'/wordpress/bootstrap.php';
@@ -0,0 +1,6 @@
1
+ type SocialLinksProps = {
2
+ className?: string;
3
+ buttonStyle?: string;
4
+ };
5
+ export declare function SocialLinks({ className, buttonStyle }: SocialLinksProps): import("react").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useSite } from "../../core/content/context.js";
4
+ import { buttonClasses } from "../../core/ui/button-appearance.js";
5
+ const networks = {
6
+ instagram: "Instagram",
7
+ facebook: "Facebook",
8
+ telegram: "Telegram",
9
+ youtube: "YouTube",
10
+ tiktok: "TikTok",
11
+ linkedin: "LinkedIn"
12
+ };
13
+ function SocialLinks({ className, buttonStyle = "text" }) {
14
+ const links = useSite().settings?.socialLinks ?? {};
15
+ const buttons = Object.entries(networks).flatMap(([network, label]) => {
16
+ const url = links[network];
17
+ if (typeof url !== "string" || !/^https?:\/\/[^/]+/i.test(url)) return [];
18
+ return /* @__PURE__ */ jsx("a", { href: url, className: buttonClasses("is-style-studio-" + buttonStyle), children: label }, network);
19
+ });
20
+ return buttons.length ? /* @__PURE__ */ jsx("div", { className, children: buttons }) : null;
21
+ }
22
+ export {
23
+ SocialLinks
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../components/social-links/index.tsx"],
4
+ "sourcesContent": ["'use client';\n\nimport { useSite } from '../../core/content/context.js';\nimport { buttonClasses } from '../../core/ui/button-appearance.js';\n\nconst networks = {\n instagram: 'Instagram',\n facebook: 'Facebook',\n telegram: 'Telegram',\n youtube: 'YouTube',\n tiktok: 'TikTok',\n linkedin: 'LinkedIn',\n};\n\ntype SocialLinksProps = {\n className?: string;\n buttonStyle?: string;\n};\n\nexport function SocialLinks({ className, buttonStyle = 'text' }: SocialLinksProps) {\n const links = useSite().settings?.socialLinks ?? {};\n const buttons = Object.entries(networks).flatMap(([network, label]) => {\n const url = links[network];\n if (typeof url !== 'string' || !/^https?:\\/\\/[^/]+/i.test(url)) return [];\n return <a key={network} href={url} className={buttonClasses(\"is-style-studio-\" + buttonStyle)}>{label}</a>;\n });\n\n return buttons.length ? <div className={className}>{buttons}</div> : null;\n}\n"],
5
+ "mappings": ";AAwBW;AAtBX,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAE9B,MAAM,WAAW;AAAA,EACf,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AACZ;AAOO,SAAS,YAAY,EAAE,WAAW,cAAc,OAAO,GAAqB;AACjF,QAAM,QAAQ,QAAQ,EAAE,UAAU,eAAe,CAAC;AAClD,QAAM,UAAU,OAAO,QAAQ,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,KAAK,MAAM;AACrE,UAAM,MAAM,MAAM,OAAO;AACzB,QAAI,OAAO,QAAQ,YAAY,CAAC,qBAAqB,KAAK,GAAG,EAAG,QAAO,CAAC;AACxE,WAAO,oBAAC,OAAgB,MAAM,KAAK,WAAW,cAAc,qBAAqB,WAAW,GAAI,mBAAjF,OAAuF;AAAA,EACxG,CAAC;AAED,SAAO,QAAQ,SAAS,oBAAC,SAAI,WAAuB,mBAAQ,IAAS;AACvE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "social-links",
3
+ "dependencies": []
4
+ }
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { Media } from './components/media/index.js';
11
11
  export { Icon } from './components/icon/index.js';
12
12
  export { Button } from './components/button/index.js';
13
13
  export { Buttons } from './components/buttons/index.js';
14
+ export { SocialLinks } from './components/social-links/index.js';
14
15
  export { Background } from './components/background/index.js';
15
16
  export { Slider } from './components/slider/index.js';
16
17
  export { List } from './components/list/index.js';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import { Media } from "./components/media/index.js";
12
12
  import { Icon } from "./components/icon/index.js";
13
13
  import { Button } from "./components/button/index.js";
14
14
  import { Buttons } from "./components/buttons/index.js";
15
+ import { SocialLinks } from "./components/social-links/index.js";
15
16
  import { Background } from "./components/background/index.js";
16
17
  import { Slider } from "./components/slider/index.js";
17
18
  import { List } from "./components/list/index.js";
@@ -65,6 +66,7 @@ export {
65
66
  Slider,
66
67
  SliderButton,
67
68
  SliderPagination,
69
+ SocialLinks,
68
70
  Text,
69
71
  Toggle,
70
72
  collectFields,
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.tsx"],
4
- "sourcesContent": ["'use client';\nexport {AccordionItem,AccordionTrigger,AccordionContent} from './core/ui/disclosure.js';\nexport { SliderButton, SliderPagination } from './core/ui/slider.js';\nexport { RecordDate, RecordContent, RecordText, RecordEdit, RecordExcerpt, RecordImage, RecordIndex, RecordLink, RecordTitle } from './core/fields/render.js';\nexport { Section } from './components/section/index.js';\nexport { Heading } from './components/heading/index.js';\nexport { Text } from './components/text/index.js';\nexport { Paragraphs } from './components/paragraphs/index.js';\nexport { Image } from './components/image/index.js';\nexport { Gallery } from './components/gallery/index.js';\nexport { Media } from './components/media/index.js';\nexport { Icon } from './components/icon/index.js';\nexport { Button } from './components/button/index.js';\nexport { Buttons } from './components/buttons/index.js';\nexport { Background } from './components/background/index.js';\nexport { Slider } from './components/slider/index.js';\nexport { List } from './components/list/index.js';\nexport { Records } from './components/records/index.js';\nexport { Toggle } from './components/toggle/index.js';\nexport { Choice } from './components/choice/index.js';\nexport { Show } from './components/show/index.js';\nexport { Area } from './components/area/index.js';\nexport { Cols } from './components/cols/index.js';\nexport { Drag } from './components/drag/index.js';\nexport { Accordion } from './components/accordion/index.js';\nexport { collectFields } from './schema/index.js';\nexport type { SectionMeta } from './schema/index.js';\nexport { section } from './schema/index.js';\nexport { PricingPlans } from './components/pricing-plans/index.js';\nexport { ReviewsCarousel } from './components/reviews-carousel/index.js';\nexport { Form } from './components/forms/index.js';\n"],
5
- "mappings": ";AACA,SAAQ,eAAc,kBAAiB,wBAAuB;AAC9D,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,eAAe,YAAY,YAAY,eAAe,aAAa,aAAa,YAAY,mBAAmB;AACpI,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,YAAY;",
4
+ "sourcesContent": ["'use client';\nexport {AccordionItem,AccordionTrigger,AccordionContent} from './core/ui/disclosure.js';\nexport { SliderButton, SliderPagination } from './core/ui/slider.js';\nexport { RecordDate, RecordContent, RecordText, RecordEdit, RecordExcerpt, RecordImage, RecordIndex, RecordLink, RecordTitle } from './core/fields/render.js';\nexport { Section } from './components/section/index.js';\nexport { Heading } from './components/heading/index.js';\nexport { Text } from './components/text/index.js';\nexport { Paragraphs } from './components/paragraphs/index.js';\nexport { Image } from './components/image/index.js';\nexport { Gallery } from './components/gallery/index.js';\nexport { Media } from './components/media/index.js';\nexport { Icon } from './components/icon/index.js';\nexport { Button } from './components/button/index.js';\nexport { Buttons } from './components/buttons/index.js';\nexport { SocialLinks } from './components/social-links/index.js';\nexport { Background } from './components/background/index.js';\nexport { Slider } from './components/slider/index.js';\nexport { List } from './components/list/index.js';\nexport { Records } from './components/records/index.js';\nexport { Toggle } from './components/toggle/index.js';\nexport { Choice } from './components/choice/index.js';\nexport { Show } from './components/show/index.js';\nexport { Area } from './components/area/index.js';\nexport { Cols } from './components/cols/index.js';\nexport { Drag } from './components/drag/index.js';\nexport { Accordion } from './components/accordion/index.js';\nexport { collectFields } from './schema/index.js';\nexport type { SectionMeta } from './schema/index.js';\nexport { section } from './schema/index.js';\nexport { PricingPlans } from './components/pricing-plans/index.js';\nexport { ReviewsCarousel } from './components/reviews-carousel/index.js';\nexport { Form } from './components/forms/index.js';\n"],
5
+ "mappings": ";AACA,SAAQ,eAAc,kBAAiB,wBAAuB;AAC9D,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,eAAe,YAAY,YAAY,eAAe,aAAa,aAAa,YAAY,mBAAmB;AACpI,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,YAAY;",
6
6
  "names": []
7
7
  }
@@ -106,7 +106,7 @@ for (const name of ['tokens.css', 'admin.css']) {
106
106
  fs.copyFileSync('kit/admin-ui/' + name, output + '/admin-ui/' + name);
107
107
  }
108
108
  publishKitAssets(process.cwd(),path.resolve(output));
109
- fs.cpSync('public/assets', '../assets', { recursive: true });
109
+ if (fs.existsSync('public/assets')) fs.cpSync('public/assets', output + '/assets', { recursive: true });
110
110
  console.log('Gutenberg bundle and scoped Tailwind styles built.');
111
111
 
112
112
  // Preview images are authored beside sections; no CMS instance is required to display them.
@@ -13,7 +13,7 @@ const emitted=program.emit();
13
13
  const diagnostics=[...ts.getPreEmitDiagnostics(program),...emitted.diagnostics];
14
14
  if(diagnostics.length){console.error(ts.formatDiagnosticsWithColorAndContext(diagnostics,{getCanonicalFileName:f=>f,getCurrentDirectory:()=>root,getNewLine:()=> '\n'}));process.exit(1);}
15
15
  await build({entryPoints:config.fileNames.filter(file=>!file.endsWith('.d.ts')),outbase:root,outdir:output,format:'esm',platform:'neutral',target:'es2020',jsx:'automatic',bundle:false,sourcemap:true});
16
- const folders=['components','editor','core','ui','admin-ui','modules','adapters','hooks','styles','schema','shared','tooling'];
16
+ const folders=['components','editor','core','ui','admin-ui','modules','adapters','wordpress','hooks','styles','schema','shared','tooling'];
17
17
  for(const folder of folders){const source=path.join(root,folder);if(!fs.existsSync(source))continue;fs.cpSync(source,path.join(output,folder),{recursive:true,filter:file=>!(/\.tsx?$/.test(file))});}
18
18
  fs.copyFileSync(path.join(root,'bootstrap.php'),path.join(output,'bootstrap.php'));
19
19
  console.log(`Built ${config.fileNames.length} independent modules with declarations and server/assets sources.`);
@@ -1,31 +1,96 @@
1
1
  #!/usr/bin/env node
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import {fileURLToPath} from 'node:url';
5
- import {syncSections} from './sync-sections.mjs';
6
- import {syncKit} from './sync-kit.mjs';
7
- import {normalizeSourceImports} from './materialize-source.mjs';
8
- const source=path.resolve(fileURLToPath(new URL('..',import.meta.url)));
9
- const command=process.argv[2]??'help';
10
- const args=process.argv.slice(3);
11
- const project=path.resolve(args.includes('--project')?args[args.indexOf('--project')+1]:process.cwd());
12
- if(command==='prepare'){
13
- const destination=path.join(project,'kit');
14
- const marker=path.join(destination,'.kit-package.json');
15
- if(destination!==source){
16
- if(fs.existsSync(destination)&&!fs.existsSync(marker))throw new Error('kit/ is authored source. Move it aside before preparing the npm-managed kit copy.');
17
- const folders=['components','editor','core','ui','admin-ui','modules','adapters','hooks','styles','schema','shared','tooling'];
18
- fs.mkdirSync(destination,{recursive:true});
19
- for(const folder of folders){fs.rmSync(path.join(destination,folder),{recursive:true,force:true});fs.cpSync(path.join(source,folder),path.join(destination,folder),{recursive:true});}
20
- for(const file of ['index.tsx','bootstrap.php'])fs.copyFileSync(path.join(source,file),path.join(destination,file));
21
- const meta=JSON.parse(fs.readFileSync(path.join(source,'package.json'),'utf8'));
22
- fs.writeFileSync(marker,JSON.stringify({name:meta.name,version:meta.version},null,2)+'\n');
23
- }
24
- normalizeSourceImports(destination);
25
- syncSections(project);
26
- syncKit(project,{directory:destination});
27
- console.log('Prepared component/editor/PHP/style connections in '+destination);
28
- }else{
29
- console.log('Usage: soinproduction-kit prepare [--project PATH]\nCreates an npm-managed local kit source copy and regenerates host connections. See README.md for the host configuration.');
30
- if(command!=='help')process.exitCode=1;
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { prepareProject } from "./prepare-project.mjs";
5
+
6
+ const command = process.argv[2] ?? "help";
7
+ const input = process.argv.slice(3);
8
+ const args = [];
9
+ let root = process.cwd();
10
+ let blockOpt = "";
11
+
12
+ for (let i = 0; i < input.length; i++) {
13
+ if (input[i] === "--project") {
14
+ if (!input[i + 1]) throw new Error("--project needs a path");
15
+ root = input[++i];
16
+ } else if (input[i].startsWith("--project=")) {
17
+ root = input[i].slice(10);
18
+ } else if (input[i] === "--block") {
19
+ blockOpt = input[++i] ?? "";
20
+ } else if (input[i].startsWith("--block=")) {
21
+ blockOpt = input[i].slice(8);
22
+ } else {
23
+ args.push(input[i]);
24
+ }
25
+ }
26
+
27
+ root = path.resolve(root);
28
+ const noBuild = args.includes("--no-build");
29
+ const positional = args.filter((value) => !value.startsWith("--"));
30
+
31
+ if (command === "init") {
32
+ const { initTheme } = await import("./init-theme.mjs");
33
+ const result = initTheme(root, { force: args.includes("--force") });
34
+ console.log(`Initialized theme in ${result.themeRoot} (kit ${result.prepared.version})`);
35
+ if (result.created.length) {
36
+ console.log("Created:\n " + result.created.join("\n "));
37
+ }
38
+ } else if (command === "prepare") {
39
+ const result = prepareProject(root, { force: args.includes("--force") });
40
+ console.log(`Prepared kit ${result.version} in ${result.directory}`);
41
+ } else if (command === "dev" || command === "start") {
42
+ const { runDev, runStart } = await import("./dev.mjs");
43
+ await (command === "dev" ? runDev : runStart)({ root, args });
44
+ } else if (["build:editor", "build:wordpress", "build:booking"].includes(command)) {
45
+ prepareProject(root);
46
+ process.chdir(root);
47
+ await import(pathToFileURL(path.join(root, "kit/tooling/" + command.replace(":", "-") + ".mjs")).href);
48
+ } else if (
49
+ command === "create:post-type" ||
50
+ (command === "create" && (positional[0] === "post-type" || positional[0] === "cpt"))
51
+ ) {
52
+ const slug = command === "create" ? positional[1] : positional[0];
53
+ const { createPostType } = await import("./create-post-type.mjs");
54
+ const result = createPostType(root, slug, {
55
+ collection: args.includes("--collection"),
56
+ force: args.includes("--force"),
57
+ block: blockOpt
58
+ });
59
+ console.log(`Created post type "${result.slug}" in ${result.file}`);
60
+ } else if (command === "create" || ["create:component", "create:section", "create:layout"].includes(command)) {
61
+ prepareProject(root);
62
+ const kind = command === "create" ? positional[0] : command.split(":")[1];
63
+ const slug = command === "create" ? positional[1] : positional[0];
64
+ const { createModule } = await import("./create-module.mjs");
65
+ const result = createModule(root, kind, slug, { build: !noBuild });
66
+ console.log(`Created ${result.name}\n${result.directory}`);
67
+ } else if (command === "new:section" || (command === "new" && positional[0] === "section")) {
68
+ prepareProject(root);
69
+ const { createSection } = await import("./create-section.mjs");
70
+ const result = createSection(root, command === "new" ? positional[1] : positional[0]);
71
+ console.log(`Created ${result.name}\n${result.directory}`);
72
+ } else if (command === "render" || command === "render:module") {
73
+ prepareProject(root);
74
+ const { renderModule } = await import("./render-module.mjs");
75
+ const output = renderModule(root, positional[0], {
76
+ build: !noBuild,
77
+ force: args.includes("--force"),
78
+ stdout: args.includes("--stdout")
79
+ });
80
+ console.log(output);
81
+ } else {
82
+ console.log(`Usage: soinproduction-kit COMMAND [--project PATH]
83
+
84
+ init [--force] Scaffold a new WordPress theme + kit config
85
+ prepare [--force] Sync kit runtime into frontend/kit
86
+ dev [Next options] Dynamic port and optional editor watcher
87
+ start [Next options] Dynamic production port
88
+ create post-type SLUG [--collection] [--block NAME] Generate CPT in inc/post-types/ + wire kit.config.json
89
+ create component NAME [--no-build]
90
+ create section NAME [--no-build] Schema-based block
91
+ create layout NAME [--no-build]
92
+ new section NAME Declarative kit section
93
+ render NAME [--stdout|--force] [--no-build]
94
+ build:editor | build:wordpress | build:booking`);
95
+ if (command !== "help") process.exitCode = 1;
31
96
  }
@@ -61,10 +61,9 @@ return ['id'=>'${slug}','group'=>'custom','name'=>'${name}','title'=>'${title}',
61
61
 
62
62
  const registry = path.join(root, 'src/blocks/registry.ts'),
63
63
  editor = path.join(root, 'src/blocks/editor-registry.ts'),
64
- php = path.resolve(root, '../inc/blocks/registry.php'),
65
64
  css = path.join(root, 'app/globals.css');
66
65
  const original = new Map(
67
- [registry, editor, php, css].map((f) => [f, fs.readFileSync(f, 'utf8')])
66
+ [registry, editor, css].map((f) => [f, fs.existsSync(f)?fs.readFileSync(f, 'utf8'):null])
68
67
  );
69
68
  try {
70
69
  fs.mkdirSync(directory, { recursive: true });
@@ -72,9 +71,9 @@ return ['id'=>'${slug}','group'=>'custom','name'=>'${name}','title'=>'${title}',
72
71
  fs.writeFileSync(path.join(directory, file), text);
73
72
  renderModule(root, slug, { build: false });
74
73
  syncSections(root);
75
- if (build) execFileSync('npm', ['run', 'build:editor'], { cwd: root, stdio: 'inherit' });
74
+ if (build) execFileSync(process.execPath, [path.join(root,'kit/tooling/build-editor.mjs')], { cwd: root, stdio: 'inherit' });
76
75
  } catch (error) {
77
- for (const [file, text] of original) fs.writeFileSync(file, text);
76
+ for (const [file, text] of original) {if(text===null)fs.rmSync(file,{force:true});else fs.writeFileSync(file,text);}
78
77
  fs.rmSync(directory, { recursive: true, force: true });
79
78
  throw error;
80
79
  }