@symbo.ls/create 2.11.97 → 2.11.99

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.
@@ -41,6 +41,7 @@ var options_default = {
41
41
  },
42
42
  router: {
43
43
  initRouter: true,
44
+ popState: true,
44
45
  injectRouterInLinkComponent: true
45
46
  },
46
47
  define: import_define.defaultDefine
@@ -33,7 +33,7 @@ const DEFAULT_ROUTING_OPTIONS = {
33
33
  popState: true
34
34
  };
35
35
  const initRouter = (element, options) => {
36
- let routerOptions = (0, import_utils.merge)(options.routerOptions || {}, DEFAULT_ROUTING_OPTIONS);
36
+ let routerOptions = (0, import_utils.merge)(options.router || {}, DEFAULT_ROUTING_OPTIONS);
37
37
  if (routerOptions === false)
38
38
  return;
39
39
  if (routerOptions === true)
@@ -62,14 +62,17 @@ let popStateFired;
62
62
  const popStateRouter = (element, options) => {
63
63
  if (popStateFired)
64
64
  return;
65
- const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS;
65
+ popStateFired = true;
66
+ const routerOptions = options.router || DEFAULT_ROUTING_OPTIONS;
66
67
  if (!routerOptions.popState)
67
68
  return;
68
69
  const router = options.snippets && options.snippets.router ? options.snippets.router : import_router.router;
69
- const { pathname, hash } = import_globals.window.location;
70
- const url = pathname + hash;
71
- import_globals.window.onpopstate = (e) => router(url, element, { pushState: false, level: 0 });
72
- popStateFired = true;
70
+ import_globals.window.onpopstate = (e) => {
71
+ const { pathname, hash } = import_globals.window.location;
72
+ const url = pathname + hash;
73
+ console.log(url);
74
+ router(url, element, {}, { pushState: false, level: 0 });
75
+ };
73
76
  };
74
77
  const injectRouterInLinkComponent = (routerOptions) => {
75
78
  if (routerOptions.injectRouterInLinkComponent) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@symbo.ls/create",
3
- "version": "2.11.97",
3
+ "version": "2.11.99",
4
4
  "license": "MIT",
5
- "gitHead": "d5b73e4c431d30798a999c5077b446472f0a6ac4",
5
+ "gitHead": "ca2b0202aae2d8be7c5cba8b3d419fd1dc39c106",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -20,7 +20,7 @@
20
20
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
21
21
  "build:esm": "npx esbuild ./src/*.js --target=es2020 --format=esm --outdir=dist/esm",
22
22
  "build:cjs": "npx esbuild ./src/*.js --target=node16 --format=cjs --outdir=dist/cjs",
23
- "build:cjs:bundle": "npx esbuild ./src/*.js --target=node16 --format=cjs --outdir=dist/cjs/bundle --bundle",
23
+ "build:cjs:bundle": "npx esbuild ./src/index.js --target=node16 --format=cjs --outdir=dist/cjs/bundle --bundle ",
24
24
  "build:iife": "npx esbuild ./src/index.js --target=es2020 --format=iife --outdir=dist/iife --bundle --minify",
25
25
  "build": "yarn build:cjs; yarn build:cjs:bundle",
26
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
package/src/options.js CHANGED
@@ -21,6 +21,7 @@ export default {
21
21
  },
22
22
  router: {
23
23
  initRouter: true,
24
+ popState: true,
24
25
  injectRouterInLinkComponent: true
25
26
  },
26
27
  define: defaultDefine
package/src/router.js CHANGED
@@ -12,7 +12,7 @@ const DEFAULT_ROUTING_OPTIONS = {
12
12
  }
13
13
 
14
14
  export const initRouter = (element, options) => {
15
- let routerOptions = merge(options.routerOptions || {}, DEFAULT_ROUTING_OPTIONS)
15
+ let routerOptions = merge(options.router || {}, DEFAULT_ROUTING_OPTIONS)
16
16
 
17
17
  if (routerOptions === false) return
18
18
  if (routerOptions === true) routerOptions = DEFAULT_ROUTING_OPTIONS
@@ -44,13 +44,17 @@ export const initRouter = (element, options) => {
44
44
  let popStateFired
45
45
  export const popStateRouter = (element, options) => {
46
46
  if (popStateFired) return
47
- const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS
47
+ popStateFired = true
48
+ const routerOptions = options.router || DEFAULT_ROUTING_OPTIONS
48
49
  if (!routerOptions.popState) return
49
50
  const router = (options.snippets && options.snippets.router) ? options.snippets.router : defaultRouter
50
- const { pathname, hash } = window.location
51
- const url = pathname + hash
52
- window.onpopstate = e => router(url, element, { pushState: false, level: 0 })
53
- popStateFired = true
51
+ window.onpopstate = e => {
52
+ const { pathname, hash } = window.location
53
+ const url = pathname + hash
54
+ console.log(url)
55
+ // console.log(element)
56
+ router(url, element, {}, { pushState: false, level: 0 })
57
+ }
54
58
  }
55
59
 
56
60
  export const injectRouterInLinkComponent = (routerOptions) => {