@rue-js/router 0.0.20 → 0.0.25

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,5 +1,5 @@
1
1
  /**
2
- * @rue-js/router v0.0.20
2
+ * @rue-js/router v0.0.25
3
3
  * (c) 2025-present Xiangmin Liu and Rue contributors
4
4
  * @license MIT
5
5
  **/
@@ -7,13 +7,13 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- var rueJs = require('rue-js');
10
+ var rue = require('@rue-js/rue');
11
11
  var shared = require('@rue-js/shared');
12
12
 
13
13
  const __routerByContainer = /* @__PURE__ */ new WeakMap();
14
14
  let __activeRouter = null;
15
15
  const attachRouter = (router) => {
16
- const c = rueJs.getCurrentContainer();
16
+ const c = rue.getCurrentContainer();
17
17
  if (c) __routerByContainer.set(c, router);
18
18
  __activeRouter = router;
19
19
  };
@@ -59,7 +59,7 @@ const createWebHashHistory = () => {
59
59
  };
60
60
  };
61
61
  const createRouter = (options) => {
62
- const currentPath = rueJs.signal(options.history.location(), {}, true);
62
+ const currentPath = rue.signal(options.history.location(), {}, true);
63
63
  const compilePath = (path) => {
64
64
  const keys = [];
65
65
  const reStr = "^" + path.replace(/\/:([^/()]+)(?:\(([^)]+)\))?/g, (_m, name, pattern) => {
@@ -92,7 +92,7 @@ const createRouter = (options) => {
92
92
  if (null === matchRoute) {
93
93
  throw new Error("No route matched path " + currentPath.get());
94
94
  }
95
- const route = rueJs.signal(matchRoute, {}, true);
95
+ const route = rue.signal(matchRoute, {}, true);
96
96
  options.history.listen(() => {
97
97
  const p = options.history.location();
98
98
  if (p === currentPath.get()) {
@@ -125,13 +125,13 @@ const createRouter = (options) => {
125
125
  return router;
126
126
  };
127
127
  const useRouter = () => {
128
- const c = rueJs.getCurrentContainer();
128
+ const c = rue.getCurrentContainer();
129
129
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
130
130
  if (!r) throw new Error("Router not installed for current application/container");
131
131
  return r;
132
132
  };
133
133
  const RouterView = () => {
134
- const { container } = rueJs.useSetup(() => {
134
+ const { container } = rue.useSetup(() => {
135
135
  const r = useRouter();
136
136
  const container2 = document.createDocumentFragment();
137
137
  const startEl = document.createComment("rue-router-view-start");
@@ -139,12 +139,12 @@ const RouterView = () => {
139
139
  container2.appendChild(startEl);
140
140
  container2.appendChild(endEl);
141
141
  const clearRange = () => {
142
- const vnodeLike = rueJs.vapor(() => ({ vaporElement: document.createDocumentFragment() }));
142
+ const vnodeLike = rue.vapor(() => ({ vaporElement: document.createDocumentFragment() }));
143
143
  const parent = startEl.parentNode || container2;
144
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
144
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
145
145
  };
146
146
  let lastComponent = null;
147
- rueJs.watchEffect(() => {
147
+ rue.watchEffect(() => {
148
148
  const data = r.route.get();
149
149
  if (!data) {
150
150
  clearRange();
@@ -155,18 +155,18 @@ const RouterView = () => {
155
155
  return;
156
156
  }
157
157
  lastComponent = comp;
158
- const vnodeLike = rueJs.h(comp, { params: data.params });
158
+ const vnodeLike = rue.h(comp, { params: data.params });
159
159
  const parent = startEl.parentNode || container2;
160
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
160
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
161
161
  }
162
162
  });
163
163
  return { container: container2 };
164
164
  });
165
- return rueJs.vapor(() => ({ vaporElement: container }));
165
+ return rue.vapor(() => ({ vaporElement: container }));
166
166
  };
167
167
  const RouterLink = (props) => {
168
- const { container } = rueJs.useSetup(() => {
169
- const c = rueJs.getCurrentContainer();
168
+ const { container } = rue.useSetup(() => {
169
+ const c = rue.getCurrentContainer();
170
170
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
171
171
  if (!r) throw new Error("Router not installed for current application/container");
172
172
  const container2 = document.createDocumentFragment();
@@ -174,7 +174,7 @@ const RouterLink = (props) => {
174
174
  const endEl = document.createComment("rue-router-link-end");
175
175
  container2.appendChild(startEl);
176
176
  container2.appendChild(endEl);
177
- rueJs.watchEffect(() => {
177
+ rue.watchEffect(() => {
178
178
  const to = String(props.to || "");
179
179
  const replace = !!props.replace;
180
180
  const { children, to: _to, replace: _replace, ...rest } = props;
@@ -187,16 +187,16 @@ const RouterLink = (props) => {
187
187
  nav(to);
188
188
  };
189
189
  const childList = Array.isArray(children) ? children : children != null ? [children] : [];
190
- const vnodeLike = rueJs.h("a", { href: "#" + to, onClick: click, ...rest }, ...childList);
190
+ const vnodeLike = rue.h("a", { href: "#" + to, onClick: click, ...rest }, ...childList);
191
191
  const parent = startEl.parentNode || container2;
192
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
192
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
193
193
  });
194
194
  return { container: container2 };
195
195
  });
196
- return rueJs.vapor(() => ({ vaporElement: container }));
196
+ return rue.vapor(() => ({ vaporElement: container }));
197
197
  };
198
198
  const useRoute = () => {
199
- const c = rueJs.getCurrentContainer();
199
+ const c = rue.getCurrentContainer();
200
200
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
201
201
  if (!r) throw new Error("Router not installed for current application/container");
202
202
  return r.route;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @rue-js/router v0.0.20
2
+ * @rue-js/router v0.0.25
3
3
  * (c) 2025-present Xiangmin Liu and Rue contributors
4
4
  * @license MIT
5
5
  **/
@@ -7,13 +7,13 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- var rueJs = require('rue-js');
10
+ var rue = require('@rue-js/rue');
11
11
  var shared = require('@rue-js/shared');
12
12
 
13
13
  const __routerByContainer = /* @__PURE__ */ new WeakMap();
14
14
  let __activeRouter = null;
15
15
  const attachRouter = (router) => {
16
- const c = rueJs.getCurrentContainer();
16
+ const c = rue.getCurrentContainer();
17
17
  if (c) __routerByContainer.set(c, router);
18
18
  __activeRouter = router;
19
19
  };
@@ -59,7 +59,7 @@ const createWebHashHistory = () => {
59
59
  };
60
60
  };
61
61
  const createRouter = (options) => {
62
- const currentPath = rueJs.signal(options.history.location(), {}, true);
62
+ const currentPath = rue.signal(options.history.location(), {}, true);
63
63
  const compilePath = (path) => {
64
64
  const keys = [];
65
65
  const reStr = "^" + path.replace(/\/:([^/()]+)(?:\(([^)]+)\))?/g, (_m, name, pattern) => {
@@ -92,7 +92,7 @@ const createRouter = (options) => {
92
92
  if (null === matchRoute) {
93
93
  throw new Error("No route matched path " + currentPath.get());
94
94
  }
95
- const route = rueJs.signal(matchRoute, {}, true);
95
+ const route = rue.signal(matchRoute, {}, true);
96
96
  options.history.listen(() => {
97
97
  const p = options.history.location();
98
98
  if (p === currentPath.get()) {
@@ -125,13 +125,13 @@ const createRouter = (options) => {
125
125
  return router;
126
126
  };
127
127
  const useRouter = () => {
128
- const c = rueJs.getCurrentContainer();
128
+ const c = rue.getCurrentContainer();
129
129
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
130
130
  if (!r) throw new Error("Router not installed for current application/container");
131
131
  return r;
132
132
  };
133
133
  const RouterView = () => {
134
- const { container } = rueJs.useSetup(() => {
134
+ const { container } = rue.useSetup(() => {
135
135
  const r = useRouter();
136
136
  const container2 = document.createDocumentFragment();
137
137
  const startEl = document.createComment("rue-router-view-start");
@@ -139,12 +139,12 @@ const RouterView = () => {
139
139
  container2.appendChild(startEl);
140
140
  container2.appendChild(endEl);
141
141
  const clearRange = () => {
142
- const vnodeLike = rueJs.vapor(() => ({ vaporElement: document.createDocumentFragment() }));
142
+ const vnodeLike = rue.vapor(() => ({ vaporElement: document.createDocumentFragment() }));
143
143
  const parent = startEl.parentNode || container2;
144
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
144
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
145
145
  };
146
146
  let lastComponent = null;
147
- rueJs.watchEffect(() => {
147
+ rue.watchEffect(() => {
148
148
  const data = r.route.get();
149
149
  if (!data) {
150
150
  clearRange();
@@ -155,18 +155,18 @@ const RouterView = () => {
155
155
  return;
156
156
  }
157
157
  lastComponent = comp;
158
- const vnodeLike = rueJs.h(comp, { params: data.params });
158
+ const vnodeLike = rue.h(comp, { params: data.params });
159
159
  const parent = startEl.parentNode || container2;
160
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
160
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
161
161
  }
162
162
  });
163
163
  return { container: container2 };
164
164
  });
165
- return rueJs.vapor(() => ({ vaporElement: container }));
165
+ return rue.vapor(() => ({ vaporElement: container }));
166
166
  };
167
167
  const RouterLink = (props) => {
168
- const { container } = rueJs.useSetup(() => {
169
- const c = rueJs.getCurrentContainer();
168
+ const { container } = rue.useSetup(() => {
169
+ const c = rue.getCurrentContainer();
170
170
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
171
171
  if (!r) throw new Error("Router not installed for current application/container");
172
172
  const container2 = document.createDocumentFragment();
@@ -174,7 +174,7 @@ const RouterLink = (props) => {
174
174
  const endEl = document.createComment("rue-router-link-end");
175
175
  container2.appendChild(startEl);
176
176
  container2.appendChild(endEl);
177
- rueJs.watchEffect(() => {
177
+ rue.watchEffect(() => {
178
178
  const to = String(props.to || "");
179
179
  const replace = !!props.replace;
180
180
  const { children, to: _to, replace: _replace, ...rest } = props;
@@ -187,16 +187,16 @@ const RouterLink = (props) => {
187
187
  nav(to);
188
188
  };
189
189
  const childList = Array.isArray(children) ? children : children != null ? [children] : [];
190
- const vnodeLike = rueJs.h("a", { href: "#" + to, onClick: click, ...rest }, ...childList);
190
+ const vnodeLike = rue.h("a", { href: "#" + to, onClick: click, ...rest }, ...childList);
191
191
  const parent = startEl.parentNode || container2;
192
- rueJs.renderBetween(vnodeLike, parent, startEl, endEl);
192
+ rue.renderBetween(vnodeLike, parent, startEl, endEl);
193
193
  });
194
194
  return { container: container2 };
195
195
  });
196
- return rueJs.vapor(() => ({ vaporElement: container }));
196
+ return rue.vapor(() => ({ vaporElement: container }));
197
197
  };
198
198
  const useRoute = () => {
199
- const c = rueJs.getCurrentContainer();
199
+ const c = rue.getCurrentContainer();
200
200
  const r = (c ? __routerByContainer.get(c) || null : null) || __activeRouter;
201
201
  if (!r) throw new Error("Router not installed for current application/container");
202
202
  return r.route;
package/dist/router.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FC, SignalHandle } from 'rue-js';
1
+ import { FC, SignalHandle } from '@rue-js/rue';
2
2
 
3
3
  /** 路由静态记录:
4
4
  * - path:形如 '/users/:id(\\d+)' 的匹配模式(支持命名参数与可选正则)
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @rue-js/router v0.0.20
2
+ * @rue-js/router v0.0.25
3
3
  * (c) 2025-present Xiangmin Liu and Rue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { getCurrentContainer, signal, useSetup, watchEffect, h, renderBetween, vapor } from 'rue-js';
6
+ import { getCurrentContainer, signal, useSetup, watchEffect, h, renderBetween, vapor } from '@rue-js/rue';
7
7
  import { extend } from '@rue-js/shared';
8
8
 
9
9
  const __routerByContainer = /* @__PURE__ */ new WeakMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rue-js/router",
3
- "version": "0.0.20",
3
+ "version": "0.0.25",
4
4
  "description": "@rue-js/router",
5
5
  "keywords": [
6
6
  "rue"
@@ -40,7 +40,7 @@
40
40
  "./*": "./*"
41
41
  },
42
42
  "dependencies": {
43
- "rue-js": "0.0.20"
43
+ "@rue-js/rue": "0.0.25"
44
44
  },
45
45
  "buildOptions": {
46
46
  "name": "RueRouterCore",