saloe 0.0.11 → 0.0.13

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.
@@ -0,0 +1,5 @@
1
+ const input = ({ e, srcElement }) => {
2
+ console.log('--- value =', srcElement?.value)
3
+ }
4
+
5
+ export { input }
@@ -0,0 +1,14 @@
1
+ // import { setCookie, getCookie } from 'saloe/cookie'
2
+
3
+
4
+ const load = ({ e, srcElement }) => {
5
+ console.log('--- load')
6
+
7
+ // const key = 'test'
8
+ // setCookie({ key, value: '1234' })
9
+
10
+ // const value = getCookie({ key })
11
+ // console.log('--- value =', value)
12
+ }
13
+
14
+ export { load }
@@ -0,0 +1,6 @@
1
+ const submit = ({ e, srcElement }) => {
2
+ e.preventDefault()
3
+ console.log('--- submit 2')
4
+ }
5
+
6
+ export { submit }
@@ -23,7 +23,7 @@
23
23
  "license": "ISC",
24
24
  "devDependencies": {
25
25
  "@cloudflare/kv-asset-handler": "^0.3.4",
26
- "saloe": "^0.0.8",
26
+ "saloe": "^0.0.12",
27
27
  "vite": "^5.4.3"
28
28
  }
29
29
  }
@@ -0,0 +1,7 @@
1
+ const click = ({ e, srcElement }) => {
2
+ console.log('--- clicked!')
3
+ }
4
+
5
+ export {
6
+ click,
7
+ }
@@ -1,6 +1,6 @@
1
1
  const submit = ({ e, srcElement }) => {
2
2
  e.preventDefault()
3
- console.log('--- submit 2')
3
+ console.log('--- srcElement =', srcElement)
4
4
  }
5
5
 
6
6
  export { submit }
@@ -7,7 +7,9 @@ import { getScriptListener } from 'saloe/listener'
7
7
  import manifestJSON from '__STATIC_CONTENT_MANIFEST'
8
8
 
9
9
 
10
- const isRedirectableCallback = ({ pathname }) => {
10
+ const isRedirectableCallback = ({ request }) => {
11
+ const url = new URL(request?.url)
12
+ const { pathname } = url
11
13
  return pathname !== '/' && pathname.endsWith('/')
12
14
  }
13
15
 
@@ -48,6 +50,8 @@ const isServerOnlyCallback = ({ request }) => {
48
50
  />
49
51
  <button type="submit">Submit!</button>
50
52
  </form>
53
+ <br/>
54
+ <button on-click="click">Click</button>
51
55
  `,
52
56
  scripts: () => html`
53
57
  ${getScriptListener()}
@@ -65,10 +69,14 @@ const isServerOnlyCallback = ({ request }) => {
65
69
  const handleFetch = async ({ request, env, ctx }) => {
66
70
  const url = new URL(request.url)
67
71
  const { origin, pathname } = url
72
+ console.log('--- origin =', origin)
73
+ console.log('--- pathname =', pathname)
68
74
 
69
75
  const pattern = findPatternFromUrl({ url })
76
+ console.log('--- pattern =', pattern)
70
77
 
71
- const redirectResult = getRedirectResponse({ origin, pathname, isRedirectableCallback })
78
+ const redirectResult = getRedirectResponse({ origin, request, isRedirectableCallback })
79
+ console.log('--- redirectResult =', redirectResult)
72
80
  if (redirectResult?.response) return redirectResult.response
73
81
 
74
82
  const forbiddenResult = getForbiddenResponse({ origin, request, isForbiddenCallback })
@@ -14,7 +14,8 @@ const listener = () => {
14
14
  "blur",
15
15
  "change",
16
16
  "focus",
17
- "invalid"
17
+ "invalid",
18
+ ...EVENTS_FIRE_DOCUMENT_BODY_LISTENERS
18
19
  ];
19
20
  const addListener = ({ srcElement, event, listeners }) => {
20
21
  srcElement == null ? void 0 : srcElement.addEventListener(event, (e) => {
@@ -12,7 +12,8 @@ const listener = () => {
12
12
  "blur",
13
13
  "change",
14
14
  "focus",
15
- "invalid"
15
+ "invalid",
16
+ ...EVENTS_FIRE_DOCUMENT_BODY_LISTENERS
16
17
  ];
17
18
  const addListener = ({ srcElement, event, listeners }) => {
18
19
  srcElement == null ? void 0 : srcElement.addEventListener(event, (e) => {
package/dist/vite.cjs.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
- var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
6
5
  const listFiles = async ({ path: path$1 }) => {
7
6
  let allFiles = [];
8
7
  try {
@@ -52,8 +51,8 @@ console.log(A${acumIndex})
52
51
  })
53
52
  );
54
53
  };
55
- const getURLPath = ({ path: path2 }) => new URL(`${path2}`, typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("vite.cjs.js", document.baseURI).href).pathname;
56
- const getInputPaths = async ({ sources }) => {
54
+ const getURLPath = ({ path: path2, metaUrl }) => new URL(`${path2}`, metaUrl).pathname;
55
+ const getInputPaths = async ({ sources, metaUrl }) => {
57
56
  var _a;
58
57
  try {
59
58
  const componentsInfos = await getImportCode({ sources });
@@ -70,14 +69,14 @@ const getInputPaths = async ({ sources }) => {
70
69
  if ((componentFilePath == null ? void 0 : componentFilePath.endsWith(".js")) && !(componentFilePath == null ? void 0 : componentFilePath.includes("/actions/"))) return acc;
71
70
  const fileName = (_a3 = componentFilePath == null ? void 0 : componentFilePath.split("/")) == null ? void 0 : _a3.pop();
72
71
  const componentName = fileName == null ? void 0 : fileName.replace(/\.[^.]+$/, "");
73
- acc[componentName] = getURLPath({ path: componentFilePath });
72
+ acc[componentName] = getURLPath({ path: componentFilePath, metaUrl });
74
73
  return acc;
75
74
  }, {})
76
75
  };
77
76
  return acc1;
78
77
  }, {}),
79
- actionsFilePath: getURLPath({ path: actionsFilePath })
80
- // 'sw.worker': getURLPath({ path: '/src/sw.worker.js' }),
78
+ actionsFilePath: getURLPath({ path: actionsFilePath, metaUrl })
79
+ // 'sw.worker': getURLPath({ path: '/src/sw.worker.js', metaUrl }),
81
80
  };
82
81
  return paths;
83
82
  } catch (err) {
package/dist/vite.es.js CHANGED
@@ -49,8 +49,8 @@ console.log(A${acumIndex})
49
49
  })
50
50
  );
51
51
  };
52
- const getURLPath = ({ path }) => new URL(`${path}`, import.meta.url).pathname;
53
- const getInputPaths = async ({ sources }) => {
52
+ const getURLPath = ({ path, metaUrl }) => new URL(`${path}`, metaUrl).pathname;
53
+ const getInputPaths = async ({ sources, metaUrl }) => {
54
54
  var _a;
55
55
  try {
56
56
  const componentsInfos = await getImportCode({ sources });
@@ -67,14 +67,14 @@ const getInputPaths = async ({ sources }) => {
67
67
  if ((componentFilePath == null ? void 0 : componentFilePath.endsWith(".js")) && !(componentFilePath == null ? void 0 : componentFilePath.includes("/actions/"))) return acc;
68
68
  const fileName = (_a3 = componentFilePath == null ? void 0 : componentFilePath.split("/")) == null ? void 0 : _a3.pop();
69
69
  const componentName = fileName == null ? void 0 : fileName.replace(/\.[^.]+$/, "");
70
- acc[componentName] = getURLPath({ path: componentFilePath });
70
+ acc[componentName] = getURLPath({ path: componentFilePath, metaUrl });
71
71
  return acc;
72
72
  }, {})
73
73
  };
74
74
  return acc1;
75
75
  }, {}),
76
- actionsFilePath: getURLPath({ path: actionsFilePath })
77
- // 'sw.worker': getURLPath({ path: '/src/sw.worker.js' }),
76
+ actionsFilePath: getURLPath({ path: actionsFilePath, metaUrl })
77
+ // 'sw.worker': getURLPath({ path: '/src/sw.worker.js', metaUrl }),
78
78
  };
79
79
  return paths;
80
80
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saloe",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Tools for making web development easy and efficient",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/listener.js CHANGED
@@ -15,6 +15,7 @@ const listener = () => {
15
15
  'change',
16
16
  'focus',
17
17
  'invalid',
18
+ ...EVENTS_FIRE_DOCUMENT_BODY_LISTENERS,
18
19
  ]
19
20
 
20
21
  const addListener = ({ srcElement, event, listeners }) => {
package/src/vite.js CHANGED
@@ -69,9 +69,9 @@ const getImportCode = async ({ sources }) => {
69
69
  }
70
70
 
71
71
 
72
- const getURLPath = ({ path }) => new URL(`${path}`, import.meta.url).pathname
72
+ const getURLPath = ({ path, metaUrl }) => new URL(`${path}`, metaUrl).pathname
73
73
 
74
- const getInputPaths = async ({ sources }) => {
74
+ const getInputPaths = async ({ sources, metaUrl }) => {
75
75
  try {
76
76
  const componentsInfos = await getImportCode({ sources })
77
77
 
@@ -88,14 +88,14 @@ const getInputPaths = async ({ sources }) => {
88
88
  if (componentFilePath?.endsWith('.js') && !componentFilePath?.includes('/actions/')) return acc
89
89
  const fileName = componentFilePath?.split('/')?.pop()
90
90
  const componentName = fileName?.replace(/\.[^.]+$/, '')
91
- acc[componentName] = getURLPath({ path: componentFilePath })
91
+ acc[componentName] = getURLPath({ path: componentFilePath, metaUrl })
92
92
  return acc
93
93
  }, {})
94
94
  }
95
95
  return acc1
96
96
  }, {}),
97
- actionsFilePath: getURLPath({ path: actionsFilePath }),
98
- // 'sw.worker': getURLPath({ path: '/src/sw.worker.js' }),
97
+ actionsFilePath: getURLPath({ path: actionsFilePath, metaUrl }),
98
+ // 'sw.worker': getURLPath({ path: '/src/sw.worker.js', metaUrl }),
99
99
  }
100
100
 
101
101
  return paths