cayo 1.2.2 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { create_ssr_component, compute_rest_props, add_attribute } from 'svelte/internal';
1
+ import { create_ssr_component, compute_rest_props, spread, escape_object, escape_attribute_value } from 'svelte/internal';
2
2
 
3
3
  function getWarnings(src, badProps) {
4
4
  const warnings = {};
@@ -38,11 +38,12 @@ function checkBadProps(warnings, src, keys) {
38
38
  }
39
39
  }
40
40
 
41
- /* src/cayo.svelte generated by Svelte v3.49.0 */
41
+ /* src/cayo.svelte generated by Svelte v3.59.2 */
42
42
 
43
43
  const Cayo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
44
- let $$restProps = compute_rest_props($$props, ["src"]);
44
+ let $$restProps = compute_rest_props($$props, ["src","attributes"]);
45
45
  let { src } = $$props;
46
+ let { attributes } = $$props;
46
47
 
47
48
  // Save unserializable prop keys (during stringification)
48
49
  // so we can report them later
@@ -74,8 +75,23 @@ const Cayo = create_ssr_component(($$result, $$props, $$bindings, slots) => {
74
75
  }
75
76
 
76
77
  if ($$props.src === void 0 && $$bindings.src && src !== void 0) $$bindings.src(src);
77
-
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)}>
78
+ if ($$props.attributes === void 0 && $$bindings.attributes && attributes !== void 0) $$bindings.attributes(attributes);
79
+
80
+ return `<div${spread(
81
+ [
82
+ escape_object(attributes),
83
+ {
84
+ "data-cayo-id": escape_attribute_value(cayoInstanceData['data-cayo-id'])
85
+ },
86
+ {
87
+ "data-cayo-src": escape_attribute_value(cayoInstanceData['data-cayo-src'])
88
+ },
89
+ {
90
+ "data-cayo-warn": escape_attribute_value(cayoInstanceData['data-cayo-warn'])
91
+ }
92
+ ],
93
+ {}
94
+ )}>
79
95
  ${`<script data-cayo-props type="application/json">${props}</script>`}
80
96
  ${slots.default ? slots.default({}) : ``}
81
97
  </div>`;
@@ -1,6 +1,6 @@
1
1
  import { create_ssr_component, add_attribute } from 'svelte/internal';
2
2
 
3
- /* src/entry.svelte generated by Svelte v3.49.0 */
3
+ /* src/entry.svelte generated by Svelte v3.59.2 */
4
4
 
5
5
  const Entry = create_ssr_component(($$result, $$props, $$bindings, slots) => {
6
6
  let { src } = $$props;
@@ -1,6 +1,7 @@
1
1
  import fs, { pathExists } from 'fs-extra';
2
2
  import { rollup } from 'rollup';
3
3
  import svelte from 'rollup-plugin-svelte';
4
+ import resolve from '@rollup/plugin-node-resolve';
4
5
  import css from 'rollup-plugin-import-css';
5
6
  import json from '@rollup/plugin-json';
6
7
 
@@ -36,9 +37,14 @@ export async function getDeps(input, config) {
36
37
  ...preprocessors,
37
38
  ],
38
39
  }),
40
+ resolve({
41
+ browser: true,
42
+ exportConditions: ['svelte'],
43
+ extensions: ['.svelte']
44
+ }),
39
45
  ...defaultRollupPlugins(),
40
46
  ...userRollupPlugins(config),
41
- ]
47
+ ],
42
48
  }
43
49
  try {
44
50
  // Create a bundle
@@ -127,7 +133,7 @@ export async function build(input, config, type = 'page') {
127
133
  } catch (err) {
128
134
  let absoluteBase = type !== 'cayo'
129
135
  ? config[`${type}s`]
130
- : pathExists.join(config.components);
136
+ : config.projectRoot;
131
137
 
132
138
  let relativeFilePath = input.replace(absoluteBase, '');
133
139
  let errorMessage = `Could not compile ${type}: '${relativeFilePath}'`;
@@ -74,12 +74,19 @@ export function generateComponentInstance(cayoId, componentName) {
74
74
  return (
75
75
  `
76
76
  cayos['${cayoId}'] = {};
77
+ cayos['${cayoId}'].id = '${cayoId}';
77
78
  cayos['${cayoId}'].target = document.querySelector('[data-cayo-id="${cayoId}"]');
78
79
  cayos['${cayoId}'].instance = new ${componentName}({
79
80
  target: target(cayos['${cayoId}'].target),
80
81
  hydrate: true,
81
82
  props: getProps(cayos['${cayoId}'].target),
82
83
  });
84
+ cayos['${cayoId}'].event = new CustomEvent('cayo:init', {
85
+ detail: {
86
+ cayo: cayos['${cayoId}'],
87
+ },
88
+ });
89
+ document.dispatchEvent(cayos['${cayoId}'].event);
83
90
  `
84
91
  );
85
92
  }
@@ -248,12 +248,12 @@ export async function processPage(content, page, _cayo, logger) {
248
248
  }
249
249
 
250
250
  function tagsExist(source) {
251
- const doctype = source.match(/<!DOCTYPE[\s\S]*>/);
251
+ const doctype = source.match(/(?<doctype><!DOCTYPE[\s\S]*?>)/);
252
252
  const head = source.match(/<head[\s\S]*>(?<innerHTML>[\s\S]*)<\/head>/);
253
253
  const body = source.match(/<body[\s\S]*>(?<innerHTML>[\s\S]*)<\/body>/);
254
254
  const html = source.match(/<html[\s\S]*>(?<innerHTML>[\s\S]*)<\/html>/);
255
255
  return {
256
- doctype: doctype === null ? false : doctype,
256
+ doctype: doctype === null ? false : doctype.groups.doctype,
257
257
  html: html === null ? false : html.groups,
258
258
  head: head === null ? false : head.groups,
259
259
  body: body === null ? false : body.groups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cayo",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "start": "node cayo dev --projectRoot test",
@@ -31,6 +31,7 @@
31
31
  "homepage": "https://github.com/matthew-ia/cayo#readme",
32
32
  "dependencies": {
33
33
  "@rollup/plugin-json": "^4.1.0",
34
+ "@rollup/plugin-node-resolve": "^16.0.0",
34
35
  "chalk": "^2.4.2",
35
36
  "chokidar": "^3.5.2",
36
37
  "deepmerge": "^4.2.2",
package/src/cayo.svelte CHANGED
@@ -1,6 +1,7 @@
1
1
  <script>
2
- export let src;
3
2
  import { getWarnings } from './cayo-warnings.js';
3
+ export let src;
4
+ export let attributes;
4
5
 
5
6
  // Save unserializable prop keys (during stringification)
6
7
  // so we can report them later
@@ -31,6 +32,7 @@
31
32
  </script>
32
33
 
33
34
  <div
35
+ {...attributes}
34
36
  data-cayo-id={cayoInstanceData['data-cayo-id']}
35
37
  data-cayo-src={cayoInstanceData['data-cayo-src']}
36
38
  data-cayo-warn={cayoInstanceData['data-cayo-warn']}
@@ -5,6 +5,6 @@
5
5
  "build": "cayo build"
6
6
  },
7
7
  "devDependencies": {
8
- "cayo": "^1.2.1"
8
+ "cayo": "^1.3.0"
9
9
  }
10
10
  }
@@ -1,4 +1,3 @@
1
- <!DOCTYPE html>
2
1
  <html lang="en">
3
2
  <head>
4
3
  <meta charset="UTF-8" />