@skaldapp/shared 1.2.59 → 1.2.61

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.
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export type TPage = FromSchema<typeof Page> & {
23
23
  };
24
24
  export declare const sharedStore: {
25
25
  $nodes: TPage[];
26
- isRedirect: ({ $parent, $prev }: TPage) => unknown;
26
+ isRedirect: (branch: TPage[]) => unknown;
27
27
  kvNodes: Record<string, TPage>;
28
28
  LEAD_TRAIL_SLASH_RE: RegExp;
29
29
  nodes: TPage[];
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import Credential from "./schemas/credential.js";
7
7
  import Nodes from "./schemas/nodes.js";
8
8
  import Page from "./schemas/page.js";
9
9
  dynamicDefaults.DEFAULTS["uuid"] = () => generateSlug;
10
- const removeHiddens = (pages) => pages.filter(({ frontmatter: { hidden }, path }) => path !== undefined && !hidden);
10
+ const isVisible = ({ frontmatter: { hidden }, path }) => path !== undefined && !hidden;
11
11
  const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefaults()], removeAdditional = true, schemas = [Nodes, Page], useDefaults = true, ajv = new AJV({
12
12
  code,
13
13
  coerceTypes,
@@ -15,15 +15,18 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
15
15
  removeAdditional,
16
16
  schemas,
17
17
  useDefaults,
18
- }), immediate = true, isRedirect = ({ $parent, $prev }) => $parent?.frontmatter["template"] && !$prev, LEAD_TRAIL_SLASH_RE = /^\/?|\/?$/g, properties = {
18
+ }), immediate = true, isRedirect = (branch) => ((reversedBranch) => ((i) => reversedBranch[i]?.frontmatter["template"] &&
19
+ !reversedBranch
20
+ .slice(0, i)
21
+ .some(({ index, siblings }) => siblings.slice(0, index).some(isVisible)))(reversedBranch.findIndex((value, index) => index && isVisible(value))))([...branch].reverse()), LEAD_TRAIL_SLASH_RE = /^\/?|\/?$/g, properties = {
19
22
  $branch: {
20
23
  get() {
21
- return removeHiddens(this.branch);
24
+ return this.branch.filter(isVisible);
22
25
  },
23
26
  },
24
27
  $children: {
25
28
  get() {
26
- return removeHiddens(this.children);
29
+ return this.children.filter(isVisible);
27
30
  },
28
31
  },
29
32
  $index: {
@@ -48,7 +51,7 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
48
51
  },
49
52
  $siblings: {
50
53
  get() {
51
- return removeHiddens(this.siblings);
54
+ return this.siblings.filter(isVisible);
52
55
  },
53
56
  },
54
57
  path: {
@@ -64,12 +67,14 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
64
67
  },
65
68
  to: {
66
69
  get() {
67
- const { path } = [...this.$branch].reverse().find((node) => !isRedirect(node)) ?? this;
70
+ const { path } = [...this.$branch]
71
+ .reverse()
72
+ .find(({ branch }) => !isRedirect(branch)) ?? this;
68
73
  return path?.replace(LEAD_TRAIL_SLASH_RE, "/");
69
74
  },
70
75
  },
71
76
  }, tree = ref([]), validate = Object.fromEntries(schemas.map(({ $id }) => [$id, ajv.getSchema($id)])), { kvNodes, nodes, ...flatJsonTree } = useFlatJsonTree(tree);
72
- const $nodes = computed(() => removeHiddens(nodes.value));
77
+ const $nodes = computed(() => nodes.value.filter(isVisible));
73
78
  export const sharedStore = reactive({
74
79
  tree,
75
80
  ...flatJsonTree,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package",
3
3
  "name": "@skaldapp/shared",
4
- "version": "1.2.59",
4
+ "version": "1.2.61",
5
5
  "description": "A TypeScript library providing reactive data structures, JSON schema validation, and tree utilities for Vue-based applications in the skald ecosystem.",
6
6
  "keywords": [
7
7
  "vue",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "prettier": "@skaldapp/configs/prettierrc",
39
39
  "dependencies": {
40
- "@skaldapp/flat-json-tree": "^2.2.43",
40
+ "@skaldapp/flat-json-tree": "^2.2.48",
41
41
  "ajv": "^8.18.0",
42
42
  "ajv-keywords": "^5.1.0",
43
43
  "json-schema-to-ts": "^3.1.1",
@@ -45,8 +45,8 @@
45
45
  "vue": "^3.5.30"
46
46
  },
47
47
  "devDependencies": {
48
- "@skaldapp/configs": "^1.2.72",
48
+ "@skaldapp/configs": "^1.2.78",
49
49
  "@types/node": "^25.5.0",
50
- "eslint": "^10.0.3"
50
+ "eslint": "^10.1.0"
51
51
  }
52
52
  }