cayo 0.9.2 → 0.9.6

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/lib/codegen.js CHANGED
@@ -45,7 +45,9 @@ export function generateCayoRuntime(components, config) {
45
45
  function generateRender(contents) {
46
46
  return (
47
47
  `
48
- export default function render() {
48
+ export default function render(cb) {
49
+ var target = function (node) { return node; }
50
+ if (cb) target = cb;
49
51
  ${contents}
50
52
  }
51
53
  `
@@ -68,7 +70,7 @@ export function generateComponentInstance(cayoId, componentName) {
68
70
  return (
69
71
  `
70
72
  new ${componentName}({
71
- target: document.querySelector('[data-cayo-id="${cayoId}"]'),
73
+ target: target(document.querySelector('[data-cayo-id="${cayoId}"]')),
72
74
  hydrate: true,
73
75
  props: getProps('${cayoId}'),
74
76
  });
@@ -19,6 +19,6 @@
19
19
  const json = JSON.stringify($$restProps);
20
20
  </script>
21
21
 
22
- <div data-cayo-id={name ? `${name}-${hash()}` : ''} data-cayo-props={json}>Cayo loading...<slot/></div>
22
+ <div data-cayo-id={name ? `${name}-${hash()}` : ''} data-cayo-props={json}><slot/></div>
23
23
  <slot/>
24
24
 
package/lib/utils.js CHANGED
@@ -61,7 +61,7 @@ export async function getComponentModulePaths(srcPath) {
61
61
 
62
62
  export async function createPageManifest(pagesPath, outDir, srcPath) {
63
63
  const pagePaths = await getPageModulePaths(pagesPath);
64
- const nonCayoComponentPaths = await fg([path.resolve(srcPath, './components/**/*[!(.cayo)].svelte')]);
64
+ const nonCayoComponentPaths = await fg([path.resolve(srcPath, './components/**/*!([.cayo]).svelte')]);
65
65
  let importPages = `import { createRequire } from 'module';\n`
66
66
  importPages += `const require = createRequire(import.meta.url);\n`
67
67
  importPages += `require('svelte/register');\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cayo",
3
- "version": "0.9.2",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "start": "node cayo dev --projectRoot test"
package/test/src/index.js CHANGED
@@ -1,5 +1,11 @@
1
1
  // console.log("I'm main");
2
+
3
+ const cb = (node) => {
4
+ console.log('im side effecting');
5
+ console.log(node);
6
+ return node;
7
+ }
2
8
  import { default as renderComponents } from './cayo-runtime.js';
3
9
  document.addEventListener('DOMContentLoaded', () => {
4
- renderComponents();
10
+ renderComponents(cb);
5
11
  });
@@ -16,7 +16,7 @@ I'm index howdy ok<br>
16
16
  <a href="/hey/" class="red">Hey</a>
17
17
  <a href="/some/page/" class="red">Some</a>
18
18
 
19
- <Cayo name="Cool" beans='ayo'></Cayo>
19
+ <Cayo name="Cool" beans='ayo'>Whaaat</Cayo>
20
20
  <Cayo name="Cool" beans='beeeeaaaaasnnss' />
21
21
  <Cayo name="Cool" beans='NOT BEANS' />
22
22