gardenjs 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.babelrc +3 -0
  2. package/.eslintrc.yml +19 -0
  3. package/.github/workflows/npm-publish.yml +32 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.prettierrc +5 -0
  6. package/LICENSE.md +21 -0
  7. package/README.md +76 -0
  8. package/bin/servegarden.js +172 -0
  9. package/examples/garden_button.svelte +5 -0
  10. package/examples/garden_button.svelte.das.js +16 -0
  11. package/examples/garden_button.svelte.md +3 -0
  12. package/examples/garden_button.vue +9 -0
  13. package/examples/garden_button.vue.das.js +16 -0
  14. package/examples/garden_button.vue.md +3 -0
  15. package/frame.html +21 -0
  16. package/index.html +14 -0
  17. package/index.js +1 -0
  18. package/jsconfig.json +32 -0
  19. package/package.json +55 -0
  20. package/src/client/GardenApp.svelte +173 -0
  21. package/src/client/GardenFrame.svelte +95 -0
  22. package/src/client/assets/icons/logo.svg +1 -0
  23. package/src/client/assets/scss/abstracts/root.css +42 -0
  24. package/src/client/assets/scss/base/buttons.css +5 -0
  25. package/src/client/assets/scss/base/general.css +77 -0
  26. package/src/client/assets/scss/base/navs.css +17 -0
  27. package/src/client/assets/scss/base/typography.css +46 -0
  28. package/src/client/assets/scss/main.scss +5 -0
  29. package/src/client/components/highlight/Highlight.js +12 -0
  30. package/src/client/components/highlight/highlight.css +249 -0
  31. package/src/client/components/sidebar/Sidebar.svelte +310 -0
  32. package/src/client/components/sidebar/SidebarNav.svelte +135 -0
  33. package/src/client/components/sidebar/SidebarNavLinks.svelte +86 -0
  34. package/src/client/components/splitpanes/HorizontalSplitPane.svelte +85 -0
  35. package/src/client/components/splitpanes/VerticalSplitPane.svelte +42 -0
  36. package/src/client/components/stage/Stage.svelte +172 -0
  37. package/src/client/components/stage/panel/PanelCode.svelte +31 -0
  38. package/src/client/components/stage/panel/PanelComponent.svelte +161 -0
  39. package/src/client/components/stage/panel/PanelContent.svelte +5 -0
  40. package/src/client/components/stage/panel/PanelDescription.svelte +26 -0
  41. package/src/client/components/stage/panel/PanelStoriesNav.svelte +67 -0
  42. package/src/client/components/stage/panel/markdown.css +679 -0
  43. package/src/client/components/topbar/Topbar.svelte +526 -0
  44. package/src/client/gardenapp.js +12 -0
  45. package/src/client/gardenframe.js +11 -0
  46. package/src/client/index.js +2 -0
  47. package/src/client/logic/navTree.js +146 -0
  48. package/src/client/logic/routing.js +50 -0
  49. package/src/client/logic/stage.js +89 -0
  50. package/src/client/router.js +82 -0
  51. package/src/codegenerator/base_generator.js +294 -0
  52. package/src/codegenerator/copy_base_classes.js +67 -0
  53. package/src/codegenerator/das_file_finder.js +66 -0
  54. package/src/codegenerator/shapes/Hellogarden.svelte +63 -0
  55. package/src/codegenerator/shapes/assets/favicon.svg +1 -0
  56. package/src/codegenerator/shapes/frame.html +22 -0
  57. package/src/codegenerator/shapes/gardenframe/index.html +22 -0
  58. package/src/codegenerator/shapes/index.html +14 -0
  59. package/src/codegenerator/shapes/lib/gardenapp.js +12 -0
  60. package/src/codegenerator/shapes/screenshottests/disable_animations.css +12 -0
  61. package/src/codegenerator/shapes/screenshottests/screenshottest.base.js +48 -0
  62. package/src/codegenerator/watch.js +36 -0
  63. package/src/codegenerator/watchcl.js +34 -0
  64. package/src/config.js +19 -0
  65. package/src/renderer/SvelteRenderer.js +16 -0
  66. package/src/renderer/SvelteRenderer.svelte +79 -0
  67. package/src/renderer/VueRenderer.js +20 -0
  68. package/src/renderer/VueRenderer.vue +20 -0
  69. package/src/renderer/state.js +10 -0
  70. package/src/server.js +26 -0
  71. package/svelte.config.js +8 -0
  72. package/vite.config.js +26 -0
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M95.986 39.27c1.459 2.678-5.317 15.083-11.068 22.444-3.834 4.907-8.833 9.694-14.998 14.36-5.46 2.617-9.719 1.964-12.778-1.96-4.589-5.885-4.672-8.292-2.546-12.069 2.125-3.776 7.47-8.074 11.855-10.353 4.386-2.28 14.933-10.291 18.416-14.75.98-1.255 3.606-2.915 4.502-2.843 1.343.107 5.16 2.491 6.617 5.17z" fill="#502299"/><path d="M95.44 32.406c1.258-1.296 2.246-2.147 2.963-2.554.87-.494.572.714.436.888-.47.602-1.278 1.41-2.426 2.426 1.411 1.64 1.828 3.343 1.25 5.11-.159.482-1.993 8.016-2.564 7.206-.57-.81.423-5.07-.839-5.513-.496-.173-4.245 1.045-4.895 1.379-.534.274-.439-.527-.386-.672 1.162-3.165 1.314-5.101.897-4.709-1.291 1.217-6.659 1.775-5.803.68.394-.504 3.773-3.048 6.741-4.42 1.275-.59 2.818-.53 4.627.18z" fill="#89c057"/><path d="M41.628 32.396c1.05-1.424 1.69-1.757 3.898-1.911 1.572-.11 4.488-.497 7.63-.073.438.059 2.553-1.25 7.084-.496 4.982.83 7.033 3.657 7.353 8.239.304 4.347-2.334 23.963-3.26 27.311-.482 1.74-3.587 8.476-9.884 7.653-2.978-.389-4.075-.896-3.9-.957-2.509.827-5.128-1.178-5.78-1.884-1.11-1.199-2.356-7.842-1.862-10.736 1.197-7.013-6.28-20.369-1.28-27.146h.001z" fill="#edc427"/><path d="M51.97 34.967l.026.379c-1.613 1.106-2.188 2.938-1.727 5.497.776 4.302 1.4 10.985 1.546 13.076.147 2.09-1.257 8.382-.8 14.91.263 3.762.226 2.465.194 2.785-.106 1.074 1.493 1.168 1.287 1.182-1.49.104-1.746-.265-2.137-.493-.064-.037-.02-.278-.239-3.41-.416-5.953 1.184-13.05 1.063-14.984-.082-1.318-.63-6.08-1.56-13.02-.422-3.14.36-5.114 2.346-5.922zm6.393-2.218c8.91-.623-.012 39.85-.012 39.85a4 4 0 00-.54.196c-.39.161 8.953-40.01-.407-39.356-.144.01.736-.674.959-.69z" fill="#ed9f27"/><path d="M52.422 28.693c.313-.872.949-2.258 1.909-4.159 1.104.2 1.743.408 1.916.621.265.327-2.358 3.242-1.59 4.05.769.81 2.43.36 3.09.447 3.332.436 4.688.933 3.663.836-.413-.04-2.41.238-2.978.941-.646.803.788 1.316.909 1.783.049.19-.5.666-.903.694-1.393.097-1.835-.796-2.548-.76-1.211.062-3.591 2.152-3.867 2.171-1.034.072-.383-1.244-.47-2.49-.087-1.245-.603-.874-2.052-1.506-1.606-.701-3.225-.59-3.142-.691 1.018-1.254 5.593-.63 6.063-1.937z" fill="#090"/><path d="M28.708 51.911c-.587-.764-1.05-.944-2.21-1.427-.925-.386-2.238-.673-2.367-1.071-.144-.441 1.343-.924 1.852-.722.788.314 3.718.565 4.638.266.96-.312.32-3.192.657-3.512.338-.32 2.23-.87 2.428-.79.305.125-.534 1.79-.113 2.945.072.196.793-2.174 2.338-2.798.518-.209 1.468.3 1.468.3s-1.276 1.48-1.536 2.152c-.684 1.77-.689 3.833-.304 5.14.706 2.4 6.038 11.478 5.015 12.135-1.023.657-6.531 2.404-7.025 2.283-.493-.122-1.458-1.528-1.942-4.51-.484-2.98-.002-6.623-2.899-10.39z" fill="#75c267"/><ellipse cx="57.608" cy="35.249" rx="26.795" ry="23.945" fill="#479843" transform="rotate(-36.999 66.07 -2.209) scale(.19644)"/><ellipse cx="31.162" cy="64.171" rx="23.945" ry="19.954" fill="#325631" transform="rotate(-40.999 55.99 6.068) scale(.19644)"/><ellipse cx="38.05" cy="52.486" rx="23.945" ry="21.664" fill="#208b1b" transform="rotate(-36.999 62.228 1.178) scale(.19644)"/><path d="M35.582 41.048c2.55-.495 4.255-2.761 3.808-5.06-.447-2.3-2.151-3.588-5.427-3.266-3.276.322-4.255 2.761-3.808 5.06.447 2.3 2.877 3.762 5.427 3.266z" fill="#458742"/><path d="M27.066 50.871c.212-.466-1.11-.531-.926-1.172.09-.317.123-.663.702-.633.596.03 1.744.436 2.114.14 1.91-1.533.943-4.189-.237-5.755-1.526-2.025-4.575-3.287-7.193-1.314-2.618 1.973-3.737 5.612-1.495 7.662 2.241 2.05 5.706 3.993 7.035 1.072z" fill="#077202"/><path d="M31.636 46.061c.287-.234 1.336-.911 1.82-.59 1.186.785 1.24-1.297 1.557-1.973.86-1.836 1.56-3.496.78-5.247-1.157-2.6-5.29-3.453-8.137-2.185-2.848 1.268-3.333 4.178-2.175 6.777.588 1.32.827 3.19 2.947 3.381 2.12.191 2.266.605 3.208-.163z" fill="#198118"/><path d="M38.34 45.784c2.578.317 4.529-1.906 4.702-4.656.173-2.749-1.964-5.196-3.94-5.314-1.976-.119-5.269.363-5.55 3.952-.139 1.768-.322 3.862.63 4.747.351.327.65.63 1.172.802.183.06.87-.38 1.094-.356.926.101 1.216.742 1.892.825z" fill="#30792c"/><path d="M70.245 36.928c-.86-.909-1.134-2.251.311-.827 1.446 1.424.984 5.121 1.906 5.972.923.85.736 3.52-.438 1.46-1.175-2.059-.92-5.695-1.78-6.604z" fill="#1ba11b"/><path d="M73.685 36.235c.644-1.023.242-2.273-.395-.926s-1.719 7.262-.867 7.322c.852.06 1.243.098 1.295-.65.053-.749-.677-4.722-.033-5.746z" fill="#124f12"/><path d="M77.021 28.253c-.224-1.935-1.135-1.569-.64.209.494 1.777-1.705 4.959-2.684 9.632-.653 3.116-1.39 7.141-2.211 12.078l3.384-.108c-.842-3.295-.939-7.11-.29-11.445.971-6.503 2.666-8.43 2.441-10.366z" fill="#319d31"/><path d="M72.715 29.596c.317-1.804.707.148.31 1.011-.397.864-.632 4.226-.287 8.616.23 2.927.09 6.596-.424 11.007l-2.49-.99c1.177-2.565 1.734-5.867 1.672-9.904-.094-6.058.903-7.937 1.22-9.74z" fill="#0d700d"/><path d="M80.518 30.477c.154-2.197-.212-1.415-.56-.04-.349 1.377-3.74 2.288-4.729 7.096-.329 1.6-1.057 2.396-1.195 5.21-.139 2.815-.872 5.498-.452 7.301.28 1.202.972 1.097 2.077-.316-.53-3.125-.467-6.916.19-11.376.641-4.36 4.555-6.253 4.669-7.875z" fill="#1b5d1b"/><path d="M67.708 53.747c.63-.53 2.04-4.204 2.098-5.018.016-.243.422.245.595.349.477.286 1.128 1.157 2.046-.134.151-.212.314.769.68.691.501-.106.84-1.132 1.355-.822.517.31 1.273.206 1.243.637-.066.932.09 2.562.469 4.89 5.03 7.872 6.062 13.952 3.096 18.242-2.1 3.037-4.155 3.242-5.446 3.759-.106.042-.362-.188-.435.85-.073 1.036.04.835-.06.856-.08.017-.279-.388-.311-.883-.025-.385.12-.89.06-.875-.03.007-.887.23-.577.567.31.338.09 1.144-.078 1.127-.16-.015.288-.28-.525-1.169-.814-.888-.525-.502-.666-.363-.133.132-.065.409-.055.789.005.186.183.813-.045.653-.249-.174-.357-.431-.409-.685-.094-.456-.004-.898-.216-.807-1.188.505-1.123 1.581-1.223 1.363-.24-.525.542-1.448.431-1.418-.397.107-.821.03-1.276.498-.129.134-.488.337-.654.49-.468.435-.342.101.038-.533.227-.38 1.01-.788.953-.813-.849-.37-4.108.66-6.785-4.667-2.677-5.326 2.721-15.071 5.697-17.574z" fill="#c47106"/><path d="M73.497 55.281c-.183-.735-.264 1.659.93 3.423 1.882 2.786 4.082 4.425 4.377 8.633.275 3.944-1.163 7.084-2.037 7.2-.51.07.437.383.75-.019.281-.361 2.025-1.93 1.656-7.207-.314-4.484-3.904-7.705-4.478-8.626-.785-1.256-1.198-3.404-1.198-3.404zm-1.56-.402c.174-.69.239 2.718-.863 4.999-1.807 3.744-2.227 5.317-2.517 6.852-.423 2.239-.098 4.735.976 7.49l-.446.015s-1.804-3.144-.908-7.531c.926-4.537 1.971-5.574 2.522-6.852 1.06-2.456 1.235-4.973 1.235-4.973z" fill="#e3b231"/><path d="M71.829 54.367c-.121-.677.148 3.845.854 6.1 1.158 3.699 1.446 5.244 1.657 6.75.356 2.53.088 5.844-.184 6.555-.275.717-.383.53-.275.717.097.166.433-.728.433-.728s.89-2.258.247-6.56c-.666-4.448-1.305-5.488-1.661-6.75-.686-2.423-1.071-6.084-1.071-6.084zm-2.166.489c.215-.727.426.328-1.59 3.233-2.016 2.906-3.318 4.443-3.61 8.619-.274 3.915 1.578 7.06 2.67 7.192.64.077-.538.372-.935-.033-.358-.364-2.562-1.955-2.196-7.191.311-4.45 2.998-7.708 3.699-8.613.956-1.235 1.962-3.207 1.962-3.207z" fill="#e3b231"/><path d="M13.065 61.09c.067-.172 1.3-1.812 1.136-2.105-.123-.221-1.296-.042-1.286-.222.045-.773.908-1.733.725-2.403-.345-1.259-1.38-1.308-2.196-2.323-.334-.415-1.719-2.161-1.898-1.693 0 0 .817 1.12 1.457 2.398.136.27 1.045.882 1.155 1.157.437 1.093.077 1.904-.633 2.055-.71.15-1.45-1.32-2.437-2.142-.641-.533-.814-.665-1.355-1.157-.53-.481-.903-.548-1.156-.73-.097-.069-.25-1.522-.522-2.137-.266-.603-.148 1.987-.142 2.026.094.645 3.203 3.367 2.85 3.784-.05.06-.816-.22-2.526-1.43-1.71-1.212-2.83-1.526-3.951-1.948-.483-.182-1.27.538-1.283.572-.074.193 1.186-.058 1.946.308.594.286.901.65 1.58 1.024 1.158.638 1.134.86 2.06 1.57.621.477 1.628.869 2.29 1.271.477.29.697.864.79 1.047.077.153-1.05-.178-2.36-.198-.85-.013-1.137.549-1.708.686-.306.073-1.224-.133-2.129-.038-.56.059-2.457-.515-2.339-.449.517.29 1.482 1.284 2.612 1.367 1.834.133 3.099-.04 3.806-.173.708-.133 2.114.715.924 1.226-.442.189-1.604.683-2.531 1.309-.57.386-1.13.956-1.144 1.137-.007.093.793-.352 1.206-.5.921-.327 2.27-.999 2.608-1.184 1.738-.951 2.222-1.285 3.156-2.378.366-.429 1.098.787 1.295.273z" fill="#090"/><path d="M55.777 76.733c1.344-3.482-31.403-19.228-34.884-20.557-3.481-1.33-6.21.867-7.553 4.35-1.344 3.482-.794 6.931 2.688 8.26 3.48 1.33 38.405 11.43 39.749 7.947h0z" fill="#e66835" stroke="#e66835" stroke-width=".295"/><path d="M22.494 65.121c-2.5 5.416-3.353 4.674-3.353 4.674m9.969-9.78c.21.59-.41 2.18-1.866 4.766m.324 7.413c.75-.052 1.664-1.428 2.741-4.127m7.529-3.611c.172.56-.33 1.823-1.507 3.785m15.203 4.152c.116.298-.15.989-.795 2.072m1.11 2.927c.236-.093.525-.585.87-1.473m-14.882-1.096c.59.117 1.33-.95 2.218-3.203m5.257-3.078c.278.277-.189 1.316-1.4 3.116m1.454 4.789c.291-.074.797-.748 1.516-2.02" fill="none" stroke="#952d03" stroke-width=".295" stroke-linecap="round"/></svg>
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow: hidden">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/assets/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Garden Component Library by Rabbit Development</title>
8
+ </head>
9
+ <body
10
+ style="
11
+ margin: 0;
12
+ height: 100%;
13
+ width: 100%;
14
+ top: 0px;
15
+ position: absolute;
16
+ overflow: auto;
17
+ "
18
+ >
19
+ <div id="app"></div>
20
+ <script type="module" src="/gardenframe/gardenframe.js"></script>
21
+ </body>
22
+ </html>
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow: hidden">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/assets/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Garden Component Library by Rabbit Development</title>
8
+ </head>
9
+ <body
10
+ style="
11
+ margin: 0;
12
+ height: 100%;
13
+ width: 100%;
14
+ top: 0px;
15
+ position: absolute;
16
+ overflow: auto;
17
+ "
18
+ >
19
+ <div id="app"></div>
20
+ <script type="module" src="/gardenframe/gardenframe.js"></script>
21
+ </body>
22
+ </html>
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/assets/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Garden UI Component Explorer</title>
8
+ </head>
9
+
10
+ <body>
11
+ <div id="app"></div>
12
+ <script type="module" src="/lib/gardenapp.js"></script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,12 @@
1
+ import { GardenApp } from 'garden'
2
+ import { navTree, routes } from '../base.js'
3
+ import { dasMap } from '../das_import_map.js'
4
+ import config from '../../garden.config.js'
5
+ import 'garden/main.scss'
6
+
7
+ const app = new GardenApp({
8
+ target: document.getElementById('app'),
9
+ props: { navTree, routes, dasMap, config },
10
+ })
11
+
12
+ export default app
@@ -0,0 +1,12 @@
1
+ * {
2
+ -o-transform: none !important;
3
+ -moz-transform: none !important;
4
+ -ms-transform: none !important;
5
+ -webkit-transform: none !important;
6
+ transform: none !important;
7
+ -webkit-animation: none !important;
8
+ -moz-animation: none !important;
9
+ -o-animation: none !important;
10
+ -ms-animation: none !important;
11
+ animation: none !important;
12
+ }
@@ -0,0 +1,48 @@
1
+ import puppeteer from 'puppeteer'
2
+ import { routes } from '../garden/base'
3
+ import { dasmap } from '../garden/importmap'
4
+ import { toMatchImageSnapshot } from 'jest-image-snapshot'
5
+
6
+ expect.extend({ toMatchImageSnapshot })
7
+
8
+ describe('Component Screenshot Test', () => {
9
+ let browser
10
+ let page
11
+ beforeAll(async () => {
12
+ browser = await puppeteer.launch({ headless: true })
13
+
14
+ const url = 'http://localhost:3010/.garden/gardenframe/'
15
+ page = await browser.newPage()
16
+ await page.goto(url, { waitUntil: 'networkidle0', timeout: 60000 })
17
+ await page.setViewport({ width: 600, height: 800 })
18
+ await page.addStyleTag({
19
+ path: 'garden/screenshottests/disable_animations.css',
20
+ })
21
+ })
22
+ afterAll(async () => {
23
+ await page.close()
24
+ await browser.close()
25
+ })
26
+
27
+ for (const [route, { name, fullname: componentName }] of Object.entries(
28
+ routes
29
+ )) {
30
+ const das = dasmap[componentName]
31
+ describe(`Component ${name} at route: ${route}`, () => {
32
+ for (const example of das.examples) {
33
+ const story = example.story
34
+ it(story, async () => {
35
+ await page.evaluate(
36
+ (data) => {
37
+ window.postMessage(data, '*')
38
+ },
39
+ { selectedStory: story, componentName }
40
+ )
41
+ const body = await page.$('body')
42
+ const screenshot = await body.screenshot()
43
+ expect(screenshot).toMatchImageSnapshot()
44
+ })
45
+ }
46
+ })
47
+ }
48
+ })
@@ -0,0 +1,36 @@
1
+ import fswatch from 'node-watch'
2
+
3
+ export function watch(directories, options = {}, onChange) {
4
+ directories.forEach((dir) => doWatch(dir, options, onChange))
5
+ }
6
+
7
+ let waitForUpdate = false
8
+
9
+ function doWatch(dir, options, onChange) {
10
+ fswatch(dir, { recursive: true }, (_evt, filename) => {
11
+ if (waitForUpdate) {
12
+ return
13
+ }
14
+ if (watchFileType(filename, options)) {
15
+ waitForUpdate = true
16
+ onChange()
17
+ setTimeout(() => (waitForUpdate = false), 400)
18
+ }
19
+ })
20
+ }
21
+
22
+ function watchFileType(filename, options) {
23
+ let watchFile = true
24
+ if (options.include) {
25
+ watchFile &= options.include.some((pattern) =>
26
+ filename.match(pattern + '$')
27
+ )
28
+ }
29
+ if (options.exclude) {
30
+ watchFile &= !options.exclude.some((pattern) => filename.match(pattern))
31
+ }
32
+ if (watchFile) {
33
+ console.log('watch file changed:', filename)
34
+ }
35
+ return watchFile
36
+ }
@@ -0,0 +1,34 @@
1
+ import { getConfig } from '../config.js'
2
+ import { watch } from './watch.js'
3
+ import { generateGardenBase } from './base_generator.js'
4
+ import { clearBaseFolder, copyBaseClasses } from './copy_base_classes.js'
5
+
6
+ export async function init() {
7
+ const { watch: watchconfig, serverport } = await getConfig()
8
+ const { directories, include } = watchconfig
9
+ await clearBaseFolder()
10
+ await copyBaseClasses()
11
+ await generate(serverport)
12
+ watch(directories, { include: include }, async () => {
13
+ await generate()
14
+ })
15
+ }
16
+
17
+ async function generate(serverport) {
18
+ console.clear()
19
+ console.log('PROJECT ROOT: ', process.cwd())
20
+ console.log('')
21
+ console.log('generate garden app')
22
+ console.log('======================')
23
+ console.log('')
24
+ await generateGardenBase()
25
+ console.log('')
26
+ console.log('======================')
27
+ console.log('')
28
+ console.log('generate garden app finished')
29
+ console.log('')
30
+ console.log(`Listen at -> http://localhost:${serverport}`)
31
+ console.log('')
32
+ console.log('======================')
33
+ console.log('')
34
+ }
package/src/config.js ADDED
@@ -0,0 +1,19 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+
4
+ let config
5
+ export async function getConfig() {
6
+ if (!config) {
7
+ config = await readConfig()
8
+ }
9
+ return config
10
+ }
11
+
12
+ async function readConfig() {
13
+ if (fs.existsSync(path.resolve('garden.config.js'))) {
14
+ console.log('the path is', path.resolve('garden.config.js'))
15
+ const config = await import(path.resolve('garden.config.js'))
16
+ return config.default
17
+ }
18
+ return { garden: {} }
19
+ }
@@ -0,0 +1,16 @@
1
+ async function create() {
2
+ try {
3
+ const { default: SvelteApp } = await import('./SvelteRenderer.svelte')
4
+ const app = new SvelteApp({
5
+ target: document.getElementById('app'),
6
+ })
7
+ return {
8
+ destroy: () => app.$destroy(),
9
+ updateComponent: (props) => app.$set(props),
10
+ }
11
+ } catch (e) {
12
+ console.log('DEBUG', 'error', e)
13
+ }
14
+ }
15
+
16
+ export default { create }
@@ -0,0 +1,79 @@
1
+ <script>
2
+ import { onDestroy, onMount, beforeUpdate, afterUpdate } from 'svelte'
3
+ export let componentMap
4
+ export let componentName
5
+ export let selectedExample
6
+ export let das
7
+
8
+ let unmountFn
9
+
10
+ $: component = componentMap?.[componentName] || componentMap?.Welcome
11
+
12
+ let redirectData = {}
13
+ $: {
14
+ if (selectedExample) {
15
+ redirectData = {}
16
+ }
17
+ }
18
+
19
+ $: {
20
+ updateState(das, selectedExample)
21
+ }
22
+
23
+ async function updateState(das, selectedExample) {
24
+ console.log('DEBUG', 'update state')
25
+ if (unmountFn) {
26
+ console.log('DEBUG', 'call unmount update state')
27
+ unmountFn()
28
+ unmountFn = undefined
29
+ }
30
+ if (das?.beforeEach) {
31
+ unmountFn = await das.beforeEach()
32
+ }
33
+ }
34
+
35
+ onDestroy(() => {
36
+ console.log('DEBUG', 'on destroy')
37
+ if (unmountFn) {
38
+ console.log('DEBUG', 'call unmount on destroy')
39
+ unmountFn()
40
+ unmountFn = undefined
41
+ }
42
+ })
43
+ onMount(() => {
44
+ console.log('DEBUG', 'on mount')
45
+ })
46
+ beforeUpdate(() => {
47
+ console.log('DEBUG', 'before update')
48
+ if (unmountFn) {
49
+ console.log('DEBUG', 'call unmount before update')
50
+ unmountFn()
51
+ }
52
+ unmountFn = undefined
53
+ })
54
+
55
+ afterUpdate(() => {
56
+ console.log('DEBUG', 'after update')
57
+ })
58
+
59
+ function handleComponentOut(evt) {
60
+ if (das.out) {
61
+ das.out.forEach((out) => {
62
+ if (evt.detail[out.name]) {
63
+ console.log(evt.detail[out.name])
64
+ if (selectedExample.redirect && selectedExample.redirect[out.name]) {
65
+ const input = selectedExample.redirect[out.name]
66
+ redirectData[input] = evt.detail[out.name]
67
+ }
68
+ }
69
+ })
70
+ }
71
+ }
72
+ </script>
73
+
74
+ <svelte:component
75
+ this={component}
76
+ {...selectedExample?.input}
77
+ {...redirectData}
78
+ on:out={handleComponentOut}
79
+ />
@@ -0,0 +1,20 @@
1
+ //import { updateVueState } from './state.js'
2
+ //import { createApp } from 'vue'
3
+ // import VueApp from './VueRenderer.js'
4
+
5
+ async function create() {
6
+ try {
7
+ const { createApp } = await import('vue')
8
+ const { updateVueState } = await import('./state.js')
9
+ const { default: VueApp } = await import('./VueRenderer.vue')
10
+ updateVueState({})
11
+ const app = createApp(VueApp)
12
+ app.mount('#app')
13
+ return {
14
+ destroy: () => app.unmount(),
15
+ updateComponent: updateVueState,
16
+ }
17
+ } catch (e) {}
18
+ }
19
+
20
+ export default { create }
@@ -0,0 +1,20 @@
1
+ <script setup>
2
+ import { componentMap } from '/component_import_map.js'
3
+ import { ref, watch } from 'vue'
4
+ import { state } from './state.js'
5
+
6
+ const component = ref()
7
+
8
+ watch(state, (newState) => {
9
+ component.value = componentMap[newState.componentName]
10
+ })
11
+ </script>
12
+
13
+ <template>
14
+ <component
15
+ v-if="component"
16
+ :is="component"
17
+ v-bind="{ ...state.selectedExample.input }"
18
+ />
19
+ <h1 v-else>Ups</h1>
20
+ </template>
@@ -0,0 +1,10 @@
1
+ import { reactive } from 'vue'
2
+
3
+ export const state = reactive({ selectedExample: 'FOO' })
4
+
5
+ export function updateVueState({ selectedExample, das, componentName }) {
6
+ console.log('DEBUG', 'update vue state', das, componentName)
7
+ state.selectedExample = selectedExample
8
+ state.das = das
9
+ state.componentName = componentName
10
+ }
package/src/server.js ADDED
@@ -0,0 +1,26 @@
1
+ import { getConfig } from './config.js'
2
+ import open from 'open'
3
+ import { createServer as createViteServer } from 'vite'
4
+
5
+ export async function createServer() {
6
+ const { serverport, vite_config, devmodus, no_open_browser } =
7
+ await getConfig()
8
+
9
+ const configFile = vite_config || './vite.config.js'
10
+
11
+ const server = await createViteServer({
12
+ configFile,
13
+ root: '.garden/',
14
+ assetsInclude: ['**/*.md'],
15
+ server: {
16
+ port: serverport,
17
+ },
18
+ })
19
+ server.listen()
20
+
21
+ if (devmodus) {
22
+ console.log('!!!!RUNNING IN DEVELOPMENT-MODUS!!!!')
23
+ }
24
+
25
+ if (!no_open_browser) open(`http://localhost:${serverport}`)
26
+ }
@@ -0,0 +1,8 @@
1
+ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
2
+
3
+ export default {
4
+ // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
5
+ // for more information about preprocessors
6
+ preprocess: vitePreprocess(),
7
+ compilerOptions: { hydratable: true },
8
+ }
package/vite.config.js ADDED
@@ -0,0 +1,26 @@
1
+ import { defineConfig } from 'vite'
2
+ import { svelte } from '@sveltejs/vite-plugin-svelte'
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [svelte()],
7
+ build: {
8
+ rollupOptions: {
9
+ input: ['index.html', 'frame.html'],
10
+ makeAbsoluteExternalsRelative: false,
11
+ external: [
12
+ 'garden',
13
+ '/raw_component_import_map.js',
14
+ '../base.js',
15
+ '../das_import_map.js',
16
+ '../component_import_map.js',
17
+ '../../garden.config.js',
18
+ '../Hellogarden.svelte',
19
+ '/renderer/SvelteRenderer.svelte',
20
+ '/renderer/VueRenderer.vue',
21
+ '/renderer/state.js',
22
+ 'vue',
23
+ ],
24
+ },
25
+ },
26
+ })