cayo 1.2.0 → 1.2.1

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.
@@ -57,13 +57,16 @@ const Cayo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
57
57
 
58
58
  return value;
59
59
  }
60
- const json = JSON.stringify({ ...$$restProps }, replacer);
60
+
61
+ // const props = toSource({...$$restProps})
62
+ const props = JSON.stringify({ ...$$restProps }, replacer);
63
+
61
64
  const warnings = getWarnings(src, badProps);
62
65
 
63
66
  const cayoInstanceData = {
64
- 'data-cayo-id': '',
65
67
  'data-cayo-src': !warnings.invalidSrc ? `${src}` : '',
66
- 'data-cayo-props': json
68
+ 'data-cayo-id': '', // will get set during prerender process based on the src
69
+
67
70
  };
68
71
 
69
72
  if (warnings) {
@@ -72,7 +75,8 @@ const Cayo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
72
75
 
73
76
  if ($$props.src === void 0 && $$bindings.src && src !== void 0) $$bindings.src(src);
74
77
 
75
- return `<div${add_attribute("data-cayo-id", cayoInstanceData['data-cayo-id'], 0)}${add_attribute("data-cayo-src", cayoInstanceData['data-cayo-src'], 0)}${add_attribute("data-cayo-props", cayoInstanceData['data-cayo-props'], 0)}${add_attribute("data-cayo-warn", cayoInstanceData['data-cayo-warn'], 0)}>
78
+ return `<div${add_attribute("data-cayo-id", cayoInstanceData['data-cayo-id'], 0)}${add_attribute("data-cayo-src", cayoInstanceData['data-cayo-src'], 0)}${add_attribute("data-cayo-warn", cayoInstanceData['data-cayo-warn'], 0)}>
79
+ ${`<script data-cayo-props type="application/json">${props}</script>`}
76
80
  ${slots.default ? slots.default({}) : ``}
77
81
  </div>`;
78
82
  });
@@ -6,7 +6,8 @@ export function generateGetProps() {
6
6
  return (
7
7
  `
8
8
  function getProps(cayoElement) {
9
- const json = cayoElement.dataset.cayoProps;
9
+ const json = cayoElement.querySelector('[data-cayo-props]').innerHTML;
10
+ console.log('json', json);
10
11
  return JSON.parse(json);
11
12
  }
12
13
  `
@@ -57,10 +57,11 @@ export async function processPage(content, page, _cayo, logger) {
57
57
  for (const el of document.querySelectorAll('[data-cayo-src]')) {
58
58
  let src = el.dataset.cayoSrc;
59
59
  if (src !== '') {
60
+ // Generate an ID for the Cayo
60
61
  const { id, name } = generateCayoComponentId(src);
61
62
  cayoIds.push(id);
62
63
  el.dataset.cayoId = id;
63
-
64
+
64
65
  // Get warnings added by the Cayo component during compile time
65
66
  if (el.dataset.cayoWarn && el.dataset.cayoWarn !== '{}') {
66
67
  warnings.cayos[id] = JSON.parse(el.dataset.cayoWarn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cayo",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "start": "node cayo dev --projectRoot test",
@@ -43,7 +43,8 @@
43
43
  "rollup-plugin-import-css": "^3.0.3",
44
44
  "rollup-plugin-svelte": "^7.1.0",
45
45
  "svelte": "^3.49.0",
46
- "vite": "^3.1.2",
46
+ "tosource": "^2.0.0-alpha.3",
47
+ "vite": "^4.3.9",
47
48
  "yargs-parser": "^20.2.9",
48
49
  "zod": "^3.10.3"
49
50
  }
package/src/cayo.svelte CHANGED
@@ -18,23 +18,24 @@
18
18
  return value;
19
19
  };
20
20
 
21
- const json = JSON.stringify({...$$restProps}, replacer);
21
+ // const props = toSource({...$$restProps})
22
+ const props = JSON.stringify({...$$restProps}, replacer);
22
23
  const warnings = getWarnings(src, badProps);
23
24
  const cayoInstanceData = {
24
- 'data-cayo-id': '',
25
25
  'data-cayo-src': !warnings.invalidSrc ? `${src}` : '',
26
- 'data-cayo-props': json,
26
+ 'data-cayo-id': '', // will get set during prerender process based on the src
27
27
  };
28
28
  if (warnings) {
29
29
  cayoInstanceData['data-cayo-warn'] = JSON.stringify(warnings);
30
30
  }
31
31
  </script>
32
+
32
33
  <div
33
34
  data-cayo-id={cayoInstanceData['data-cayo-id']}
34
35
  data-cayo-src={cayoInstanceData['data-cayo-src']}
35
- data-cayo-props={cayoInstanceData['data-cayo-props']}
36
36
  data-cayo-warn={cayoInstanceData['data-cayo-warn']}
37
37
  >
38
+ {@html `<script data-cayo-props type="application/json">${props}</script>`}
38
39
  <slot/>
39
40
  </div>
40
41