@skaldapp/shared 1.2.47 → 1.2.49

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
@@ -22,9 +22,10 @@ export type TPage = FromSchema<typeof Page> & {
22
22
  to?: string;
23
23
  };
24
24
  export declare const sharedStore: {
25
+ $nodes: TPage[];
26
+ isRedirect: ({ $parent, $prev }: TPage) => unknown;
25
27
  kvNodes: Record<string, TPage>;
26
28
  nodes: TPage[];
27
- removeHiddens: (pages: TPage[], redirects?: boolean) => TPage[];
28
29
  add: (pId: string) => string | undefined;
29
30
  addChild: (pId: string) => string | undefined;
30
31
  down: (pId: string) => string | undefined;
package/dist/index.js CHANGED
@@ -2,19 +2,12 @@ import useFlatJsonTree from "@skaldapp/flat-json-tree";
2
2
  import AJV from "ajv";
3
3
  import dynamicDefaults from "ajv-keywords/dist/definitions/dynamicDefaults.js";
4
4
  import { generateSlug } from "random-word-slugs";
5
- import { reactive, ref, toRef, watch } from "vue";
5
+ import { computed, reactive, ref, toRef, watch } from "vue";
6
6
  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, redirects) => pages.filter(({ branch, frontmatter: { hidden }, id, path, siblings }) => path !== undefined &&
11
- !hidden &&
12
- (!redirects ||
13
- !branch
14
- .slice(0, -1)
15
- .reverse()
16
- .find(({ frontmatter: { hidden } }) => !hidden)?.frontmatter["template"] ||
17
- siblings.find(({ frontmatter: { hidden } }) => !hidden)?.id !== id));
10
+ const isRedirect = ({ $parent, $prev }) => $parent?.frontmatter["template"] && !$prev, removeHiddens = (pages) => pages.filter(({ frontmatter: { hidden }, path }) => path !== undefined && !hidden);
18
11
  const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefaults()], removeAdditional = true, schemas = [Nodes, Page], useDefaults = true, ajv = new AJV({
19
12
  code,
20
13
  coerceTypes,
@@ -25,12 +18,12 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
25
18
  }), immediate = true, properties = {
26
19
  $branch: {
27
20
  get() {
28
- return removeHiddens(this.branch, true);
21
+ return removeHiddens(this.branch);
29
22
  },
30
23
  },
31
24
  $children: {
32
25
  get() {
33
- return removeHiddens(this.children, true);
26
+ return removeHiddens(this.children);
34
27
  },
35
28
  },
36
29
  $index: {
@@ -55,7 +48,7 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
55
48
  },
56
49
  $siblings: {
57
50
  get() {
58
- return removeHiddens(this.siblings, true);
51
+ return removeHiddens(this.siblings);
59
52
  },
60
53
  },
61
54
  path: {
@@ -75,12 +68,14 @@ const esm = true, code = { esm }, coerceTypes = true, keywords = [dynamicDefault
75
68
  },
76
69
  },
77
70
  }, tree = ref([]), validate = Object.fromEntries(schemas.map(({ $id }) => [$id, ajv.getSchema($id)])), { kvNodes, nodes, ...flatJsonTree } = useFlatJsonTree(tree);
71
+ const $nodes = computed(() => removeHiddens(nodes.value));
78
72
  export const sharedStore = reactive({
79
73
  tree,
80
74
  ...flatJsonTree,
75
+ $nodes,
76
+ isRedirect,
81
77
  kvNodes: kvNodes,
82
78
  nodes: nodes,
83
- removeHiddens,
84
79
  });
85
80
  watch(toRef(sharedStore, "nodes"), async (value) => {
86
81
  if (!(await validate["nodes"]?.(value)))
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.47",
4
+ "version": "1.2.49",
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",
@@ -34,7 +34,7 @@
34
34
  "prettier": "@skaldapp/configs/prettierrc",
35
35
  "dependencies": {
36
36
  "@skaldapp/flat-json-tree": "^2.2.32",
37
- "ajv": "^8.17.1",
37
+ "ajv": "^8.18.0",
38
38
  "ajv-keywords": "^5.1.0",
39
39
  "json-schema-to-ts": "^3.1.1",
40
40
  "random-word-slugs": "^0.1.7",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@skaldapp/configs": "^1.2.59",
45
- "@types/node": "^25.2.3",
45
+ "@types/node": "^25.3.0",
46
46
  "eslint": "^9.39.2"
47
47
  }
48
48
  }