cayo 0.9.11 → 1.1.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ The main purpose of Cayo is to be a tool that lets you use modern front-end tool
11
11
 
12
12
  - **Cayo lets you define where you _do_ want reactivity, with [Cayo Components](#cayo-components)**. If you want Svelte reactivity, you can have it—with Cayo Components (or "cayos" a.k.a. the "islands of reactivity"). These are components that are individually bundled and run as Svelte client-side components.
13
13
 
14
- - **Cayo is built for that person who has constraints on their output**—someone who needs control over their HTML generation workflow, and wants to use tools like [Svelte](https://svelte.dev) and [Vite](https://vitejs.dev). All while not having to buy into the typical use of creating an _entire website_, as frameworks are typically designed to be used.
14
+ - **Cayo is built for that person who has constraints on their output**—someone who needs control over their HTML generation workflow, and wants to use tools like [Svelte](https://svelte.dev) and [Vite](https://vitejs.dev). All while not having to buy into the typical use case of creating an _entire website_, as frameworks are typically designed to be used.
15
15
 
16
16
  - **Cayo is _not_ a feature-rich web app framework** like Astro or SvelteKit. Read more about [how Cayo differs](#cayo--the-rest) from similar tools.
17
17
 
@@ -64,10 +64,12 @@ public/
64
64
  ```
65
65
 
66
66
  ### Source Directory
67
- Most of your projects files should go in `src`. This is where pages, components, styles, etc. should go. These files will be watched while running `cayo dev`, and used to build your project.
67
+ Most of your project files, such as pages, cayos, styles, etc. should go in `src`.
68
68
  - `pages` contains the pages, or "inputs" of your project
69
69
  - `components` contains your Cayo Components, and can contain any other components
70
- - `__template.svelte` is your page template
70
+ - `__template.svelte` is your page template
71
+
72
+ Note: `cayo` watches and builds from the project root, but certain paths are expected as relative to the source directory rather than the root, e.g., cayos and pages. Read the config reference for more information.
71
73
 
72
74
  ### Pages
73
75
  Cayo uses a file-based routing system, meaning the file structure within the pages directory gets used to generate output files. All pages are expected to be valid Svelte components. Since your outputs just become regular old HTML files, there is no real "routing" going on here beyond the expected default of HTML files being served on a web server.
@@ -1,4 +1,4 @@
1
- import { create_ssr_component, compute_rest_props, spread, escape_object } from 'svelte/internal';
1
+ import { create_ssr_component, compute_rest_props, add_attribute } from 'svelte/internal';
2
2
 
3
3
  function getWarnings(src, badProps) {
4
4
  const warnings = {};
@@ -72,7 +72,7 @@ const Cayo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
72
72
 
73
73
  if ($$props.src === void 0 && $$bindings.src && src !== void 0) $$bindings.src(src);
74
74
 
75
- return `<div${spread([escape_object(cayoInstanceData)], {})}>
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)}>
76
76
  ${slots.default ? slots.default({}) : ``}
77
77
  </div>`;
78
78
  });
@@ -37,7 +37,7 @@ Check out [more config examples](#more-examples).
37
37
  - **Type**: `string`
38
38
  - **Default**: `'.'`
39
39
 
40
- The project root directory, where Cayo will look for the required project structure. Can be an absolute path or a directory relative to the current working directory.
40
+ The project root directory, where Cayo will look for the required project structure. Can be an absolute path or a directory relative to the current working directory. This folder will be watched for changes during dev.
41
41
 
42
42
  ---
43
43
 
@@ -45,7 +45,7 @@ The project root directory, where Cayo will look for the required project struct
45
45
  - **Type**: `string`
46
46
  - **Default**: `'src'`
47
47
 
48
- Specify the directory where your source files will be, relative to the [project root](#projectroot). This folder will be watched for changes during dev.
48
+ Specify the directory where your source files will be, relative to the [project root](#projectroot).
49
49
 
50
50
  ---
51
51
 
package/lib/cli/watch.js CHANGED
@@ -10,7 +10,7 @@ import { debugStats } from '#core/utils.js';
10
10
  export function watch(_cayo) {
11
11
  const { config } = _cayo;
12
12
 
13
- const watcher = chokidar.watch(config.src, {
13
+ const watcher = chokidar.watch(config.projectRoot, {
14
14
  // awaitWriteFinish: {
15
15
  // stabilityThreshold: 1,
16
16
  // pollInterval: 250
@@ -61,7 +61,7 @@ export function watch(_cayo) {
61
61
  await handleCayo(filepath, _cayo);
62
62
 
63
63
  // Handle Components
64
- } else if (filepath.startsWith(config.components)) {
64
+ } else if (!filepath.startsWith(config.pages)) {
65
65
  logChange('component', filepath);
66
66
  await handleComponent(filepath, _cayo);
67
67
  }
package/lib/core/utils.js CHANGED
@@ -16,16 +16,20 @@ export function hash(str = '', bytes = 5) {
16
16
  }
17
17
 
18
18
  export function generateSafeName(inputPath) {
19
- return inputPath
19
+ let safeName = inputPath
20
20
  .replace(/^\.\//g, '')
21
+ .replace(/\.\.\//g, '')
21
22
  .replace(/\/+/g, '__')
22
23
  .replace(/\-+/g, '_');
24
+
25
+ // safeName += `_${hash(inputPath)}`;
26
+ return { name: safeName, suffix: hash(inputPath) };
23
27
  }
24
28
 
25
29
  export function generateCayoComponentId(componentPath) {
26
- const name = generateSafeName(componentPath)
27
- .replace('.cayo.svelte', '');
28
-
30
+ let { name, suffix } = generateSafeName(componentPath)
31
+ name = name.replace('.cayo.svelte', '');
32
+ name += `_${suffix}`;
29
33
  const id = `${name}-${hash(name)}`;
30
34
 
31
35
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cayo",
3
- "version": "0.9.11",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "start": "node cayo dev --projectRoot test",
package/src/cayo.svelte CHANGED
@@ -28,9 +28,14 @@
28
28
  if (warnings) {
29
29
  cayoInstanceData['data-cayo-warn'] = JSON.stringify(warnings);
30
30
  }
31
-
32
31
  </script>
33
-
34
- <div {...cayoInstanceData}>
32
+ <div
33
+ data-cayo-id={cayoInstanceData['data-cayo-id']}
34
+ data-cayo-src={cayoInstanceData['data-cayo-src']}
35
+ data-cayo-props={cayoInstanceData['data-cayo-props']}
36
+ data-cayo-warn={cayoInstanceData['data-cayo-warn']}
37
+ >
35
38
  <slot/>
36
39
  </div>
40
+
41
+