saloe 0.0.12 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saloe",
3
- "version": "0.0.12",
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,7 +69,6 @@ const getImportCode = async ({ sources }) => {
69
69
  }
70
70
 
71
71
 
72
- // const getURLPath = ({ path }) => new URL(`${path}`, import.meta.url).pathname
73
72
  const getURLPath = ({ path, metaUrl }) => new URL(`${path}`, metaUrl).pathname
74
73
 
75
74
  const getInputPaths = async ({ sources, metaUrl }) => {