@jskit-ai/ui-generator 0.1.6 → 0.1.7

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,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  packageVersion: 1,
3
3
  packageId: "@jskit-ai/ui-generator",
4
- version: "0.1.6",
4
+ version: "0.1.7",
5
5
  kind: "generator",
6
6
  description: "Generate app-local non-CRUD UI pages and outlet elements.",
7
7
  options: {
@@ -149,7 +149,7 @@ export default Object.freeze({
149
149
  mutations: {
150
150
  dependencies: {
151
151
  runtime: {
152
- "@jskit-ai/users-web": "0.1.37"
152
+ "@jskit-ai/users-web": "0.1.38"
153
153
  },
154
154
  dev: {}
155
155
  },
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@jskit-ai/ui-generator",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
7
7
  },
8
8
  "dependencies": {
9
- "@jskit-ai/kernel": "0.1.23"
9
+ "@jskit-ai/kernel": "0.1.24"
10
10
  },
11
11
  "exports": {
12
12
  "./server/buildTemplateContext": "./src/server/buildTemplateContext.js"
@@ -331,7 +331,10 @@ function renderTabLinkItemSource() {
331
331
  import { computed } from "vue";
332
332
  import { useRoute } from "vue-router";
333
333
  import { usePaths } from "@jskit-ai/users-web/client/composables/usePaths";
334
- import { useWorkspaceRouteContext } from "@jskit-ai/users-web/client/composables/useWorkspaceRouteContext";
334
+ import {
335
+ normalizeMenuLinkPathname,
336
+ resolveMenuLinkTarget
337
+ } from "@jskit-ai/users-web/client/support/menuLinkTarget";
335
338
 
336
339
  const props = defineProps({
337
340
  label: {
@@ -362,78 +365,25 @@ const props = defineProps({
362
365
 
363
366
  const route = useRoute();
364
367
  const paths = usePaths();
365
- const { currentSurfaceId, workspaceSlugFromRoute } = useWorkspaceRouteContext();
366
-
367
- function normalizePathname(pathname = "") {
368
- const source = String(pathname || "").trim();
369
- if (!source) {
370
- return "";
371
- }
372
-
373
- const queryIndex = source.indexOf("?");
374
- const hashIndex = source.indexOf("#");
375
- const cutoff =
376
- queryIndex < 0
377
- ? hashIndex
378
- : hashIndex < 0
379
- ? queryIndex
380
- : Math.min(queryIndex, hashIndex);
381
- return cutoff < 0 ? source : source.slice(0, cutoff);
382
- }
383
-
384
- function interpolateBracketParams(pathTemplate = "", params = {}) {
385
- const source = String(pathTemplate || "").trim();
386
- if (!source) {
387
- return "";
388
- }
389
-
390
- return source.replace(/\\[([^\\]]+)\\]/g, (_match, rawKey) => {
391
- const key = String(rawKey || "").trim();
392
- if (!key) {
393
- return "";
394
- }
395
- const value = params?.[key];
396
- return value == null ? "[" + key + "]" : encodeURIComponent(String(value));
397
- });
398
- }
399
-
400
- const targetSurfaceId = computed(() => {
401
- const explicitSurface = String(props.surface || "").trim().toLowerCase();
402
- if (explicitSurface && explicitSurface !== "*") {
403
- return explicitSurface;
404
- }
405
- return String(currentSurfaceId.value || paths.currentSurfaceId.value || "").trim().toLowerCase();
406
- });
407
368
 
408
369
  const resolvedTo = computed(() => {
409
- const explicitTo = String(props.to || "").trim();
410
- if (explicitTo) {
411
- if (explicitTo.startsWith("./")) {
412
- const workspaceSlug = String(workspaceSlugFromRoute.value || "").trim();
413
- const suffixTemplate = workspaceSlug ? props.workspaceSuffix : props.nonWorkspaceSuffix;
414
- const interpolatedSuffix = interpolateBracketParams(suffixTemplate, route.params || {});
415
- if (interpolatedSuffix && !interpolatedSuffix.includes("[")) {
416
- return paths.page(interpolatedSuffix, {
417
- surface: targetSurfaceId.value,
418
- mode: "auto"
419
- });
420
- }
370
+ return resolveMenuLinkTarget({
371
+ to: props.to,
372
+ surface: props.surface,
373
+ currentSurfaceId: paths.currentSurfaceId.value,
374
+ placementContext: paths.placementContext.value,
375
+ workspaceSuffix: props.workspaceSuffix,
376
+ nonWorkspaceSuffix: props.nonWorkspaceSuffix,
377
+ routeParams: route.params || {},
378
+ resolvePagePath(relativePath, options = {}) {
379
+ return paths.page(relativePath, options);
421
380
  }
422
- return explicitTo;
423
- }
424
-
425
- const workspaceSlug = String(workspaceSlugFromRoute.value || "").trim();
426
- const suffix = workspaceSlug ? props.workspaceSuffix : props.nonWorkspaceSuffix;
427
- const normalizedSuffix = String(suffix || "/").trim() || "/";
428
- return paths.page(normalizedSuffix, {
429
- surface: targetSurfaceId.value,
430
- mode: "auto"
431
381
  });
432
382
  });
433
383
 
434
384
  const isActive = computed(() => {
435
- const targetPathname = normalizePathname(resolvedTo.value);
436
- const currentPathname = normalizePathname(route.fullPath || route.path);
385
+ const targetPathname = normalizeMenuLinkPathname(resolvedTo.value);
386
+ const currentPathname = normalizeMenuLinkPathname(route.fullPath || route.path);
437
387
  if (!targetPathname || !currentPathname) {
438
388
  return false;
439
389
  }
@@ -115,10 +115,10 @@ test("ui-generator container subcommand creates parent route container with Shel
115
115
  assert.match(sectionShellSource, /<ShellOutlet :host="props\.host" :position="props\.position" \/>/);
116
116
 
117
117
  const tabLinkSource = await readFile(path.join(appRoot, "src", "components", "TabLinkItem.vue"), "utf8");
118
- assert.match(tabLinkSource, /useWorkspaceRouteContext/);
118
+ assert.match(tabLinkSource, /@jskit-ai\/users-web\/client\/support\/menuLinkTarget/);
119
+ assert.match(tabLinkSource, /resolveMenuLinkTarget/);
120
+ assert.match(tabLinkSource, /normalizeMenuLinkPathname/);
119
121
  assert.match(tabLinkSource, /class="tab-link-item text-none"/);
120
- assert.equal(tabLinkSource.includes("source.replace(/\\[([^\\]]+)\\]/g"), true);
121
- assert.equal(tabLinkSource.includes("source.replace(/[([^]]+)]/g"), false);
122
122
 
123
123
  const providerSource = await readFile(
124
124
  path.join(appRoot, "packages", "main", "src", "client", "providers", "MainClientProvider.js"),