foldkit 0.9.0-canary.0 → 0.9.0-canary.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.
@@ -8,17 +8,7 @@ export const addNavigationEventListeners = (messageQueue, browserConfig) => {
8
8
  };
9
9
  const addPopStateListener = (messageQueue, browserConfig) => {
10
10
  const onPopState = () => {
11
- const search = StringExt.stripPrefixNonEmpty('?')(window.location.search);
12
- const hash = StringExt.stripPrefixNonEmpty('#')(window.location.hash);
13
- const newUrl = {
14
- protocol: window.location.protocol,
15
- host: window.location.host,
16
- port: OptionExt.fromString(window.location.port),
17
- pathname: window.location.pathname,
18
- search,
19
- hash,
20
- };
21
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(newUrl));
11
+ Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(locationToUrl()));
22
12
  };
23
13
  window.addEventListener('popstate', onPopState);
24
14
  };
@@ -44,33 +34,25 @@ const addLinkClickListener = (messageQueue, browserConfig) => {
44
34
  Queue.unsafeOffer(messageQueue, browserConfig.onUrlRequest(External.make({ href })));
45
35
  return;
46
36
  }
47
- const { protocol, host, port, pathname, search, hash } = linkUrl;
48
- const url = {
49
- protocol,
50
- host,
51
- port: OptionExt.fromString(port),
52
- pathname,
53
- search: StringExt.stripPrefixNonEmpty('?')(search),
54
- hash: StringExt.stripPrefixNonEmpty('#')(hash),
55
- };
56
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlRequest(Internal.make({ url })));
37
+ Queue.unsafeOffer(messageQueue, browserConfig.onUrlRequest(Internal.make({ url: urlToFoldkitUrl(linkUrl) })));
57
38
  };
58
39
  document.addEventListener('click', onLinkClick);
59
40
  };
60
41
  const addProgrammaticNavigationListener = (messageQueue, browserConfig) => {
61
42
  const onProgrammaticNavigation = () => {
62
- const search = StringExt.stripPrefixNonEmpty('?')(window.location.search);
63
- const hash = StringExt.stripPrefixNonEmpty('#')(window.location.hash);
64
- const { location: { protocol, host, port, pathname }, } = window;
65
- const newUrl = {
66
- protocol,
67
- host,
68
- port: OptionExt.fromString(port),
69
- pathname,
70
- search,
71
- hash,
72
- };
73
- Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(newUrl));
43
+ Queue.unsafeOffer(messageQueue, browserConfig.onUrlChange(locationToUrl()));
74
44
  };
75
45
  window.addEventListener('foldkit:urlchange', onProgrammaticNavigation);
76
46
  };
47
+ const urlToFoldkitUrl = (url) => {
48
+ const { protocol, hostname, port, pathname, search, hash } = url;
49
+ return {
50
+ protocol,
51
+ host: hostname,
52
+ port: OptionExt.fromString(port),
53
+ pathname,
54
+ search: StringExt.stripPrefixNonEmpty('?')(search),
55
+ hash: StringExt.stripPrefixNonEmpty('#')(hash),
56
+ };
57
+ };
58
+ const locationToUrl = () => urlToFoldkitUrl(new URL(window.location.href));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit",
3
- "version": "0.9.0-canary.0",
3
+ "version": "0.9.0-canary.1",
4
4
  "description": "Elm-inspired UI framework powered by Effect",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",