@septkit/ui 0.0.24 → 0.0.26

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.
@@ -0,0 +1,2 @@
1
+ import "./use-live-data.js";
2
+ import "./use-live-state.js";
@@ -1,10 +1,15 @@
1
- import { useDebounceFn as e } from "../external/.pnpm/@vueuse_shared@14.2.1_vue@3.5.32_typescript@5.8.3_/node_modules/@vueuse/shared/dist/index.js";
2
- import { useAsyncState as t } from "../external/.pnpm/@vueuse_core@14.2.1_vue@3.5.32_typescript@5.8.3_/node_modules/@vueuse/core/dist/index.js";
1
+ import { useDebounceFn as e } from "../../external/.pnpm/@vueuse_shared@14.2.1_vue@3.5.32_typescript@5.8.3_/node_modules/@vueuse/shared/dist/index.js";
2
+ import { useAsyncState as t } from "../../external/.pnpm/@vueuse_core@14.2.1_vue@3.5.32_typescript@5.8.3_/node_modules/@vueuse/core/dist/index.js";
3
3
  import { isRef as n, watch as r } from "vue";
4
- //#region lib/composables/use-live-data.ts
4
+ //#region lib/dialecte/composables/use-live-data.ts
5
5
  function i(i) {
6
6
  let { document: a, fetcher: o, initial: s } = i, { state: c, isLoading: l, error: u, execute: d } = t(o, s), f = e(d, 50);
7
- return r(() => (n(a) ? a.value : a).state.lastUpdate, () => f()), {
7
+ return r(() => {
8
+ let e = n(a) ? a.value : a;
9
+ return `${e.documentId}:${e.state.lastUpdate}`;
10
+ }, (e, t) => {
11
+ e.split(":")[0] !== t?.split(":")[0] && (c.value = s), f();
12
+ }), {
8
13
  state: c,
9
14
  isLoading: l,
10
15
  error: u,
@@ -1,5 +1,5 @@
1
1
  import { computed as e, isRef as t, reactive as n } from "vue";
2
- //#region lib/composables/use-live-state.ts
2
+ //#region lib/dialecte/composables/use-live-state.ts
3
3
  function r(r) {
4
4
  return t(r) ? e(() => n(r.value.state)) : n(r.state);
5
5
  }
@@ -0,0 +1,5 @@
1
+ import e from "./document-gate.vue_vue_type_script_setup_true_lang.js";
2
+ //#region lib/dialecte/document-gate.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
@@ -0,0 +1,18 @@
1
+ import { useDocumentStore as e } from "./use-document-store.js";
2
+ import { defineComponent as t, onUnmounted as n, renderSlot as r, unref as i, watch as a } from "vue";
3
+ //#region lib/dialecte/document-gate.vue?vue&type=script&setup=true&lang.ts
4
+ var o = /* @__PURE__ */ t({
5
+ __name: "document-gate",
6
+ props: {
7
+ project: {},
8
+ documentId: {}
9
+ },
10
+ setup(t) {
11
+ let o = t, s = e();
12
+ return a(() => o.documentId, (e) => {
13
+ e ? s.hydrate(o.project.openDocument(e)) : s.clear();
14
+ }, { immediate: !0 }), n(() => s.clear()), (e, t) => i(s).isHydrated ? r(e.$slots, "default", { key: 0 }) : r(e.$slots, "loading", { key: 1 });
15
+ }
16
+ });
17
+ //#endregion
18
+ export { o as default };
@@ -0,0 +1,5 @@
1
+ import "./use-document-store.js";
2
+ import "./document-gate.js";
3
+ import "./composables/use-live-data.js";
4
+ import "./composables/use-live-state.js";
5
+ import "./composables/index.js";
@@ -0,0 +1,21 @@
1
+ import { D as e } from "../external/.pnpm/@dialecte_core@0.2.11/node_modules/@dialecte/core/dist/index-DWV6tSGF.js";
2
+ import { computed as t, shallowRef as n } from "vue";
3
+ //#region lib/dialecte/use-document-store.ts
4
+ var r = n(null);
5
+ function i() {
6
+ let n = t(() => (e(r.value, { detail: "useDocumentStore: document accessed outside <DocumentGate>. Wrap the consuming subtree in <DocumentGate> or check isHydrated before reading." }), r.value)), i = t(() => r.value !== null);
7
+ function a(e) {
8
+ r.value = e;
9
+ }
10
+ function o() {
11
+ r.value = null;
12
+ }
13
+ return {
14
+ document: n,
15
+ isHydrated: i,
16
+ hydrate: a,
17
+ clear: o
18
+ };
19
+ }
20
+ //#endregion
21
+ export { i as useDocumentStore };
@@ -0,0 +1,138 @@
1
+ //#region node_modules/.pnpm/@dialecte+core@0.2.11/node_modules/@dialecte/core/dist/index-DWV6tSGF.js
2
+ var e = {
3
+ UNKNOWN: {
4
+ code: "D0001",
5
+ message: "An unknown error occurred"
6
+ },
7
+ ASSERTION_FAILED: {
8
+ code: "D0002",
9
+ message: "Assertion failed"
10
+ },
11
+ STORE_CONNECTION_FAILED: {
12
+ code: "D1001",
13
+ message: "Failed to open database"
14
+ },
15
+ STORE_COMMIT_FAILED: {
16
+ code: "D1002",
17
+ message: "Failed to commit changes"
18
+ },
19
+ STORE_RECORD_NOT_FOUND: {
20
+ code: "D1003",
21
+ message: "Record not found in database"
22
+ },
23
+ STORE_BULK_ADD_FAILED: {
24
+ code: "D1004",
25
+ message: "Failed to add records to database"
26
+ },
27
+ STORE_BULK_UPDATE_FAILED: {
28
+ code: "D1005",
29
+ message: "Failed to update records in database"
30
+ },
31
+ STORE_DELETE_FAILED: {
32
+ code: "D1006",
33
+ message: "Failed to delete records from database"
34
+ },
35
+ ELEMENT_NOT_FOUND: {
36
+ code: "D2001",
37
+ message: "Element not found"
38
+ },
39
+ ROOT_NOT_FOUND: {
40
+ code: "D2002",
41
+ message: "Root element not found"
42
+ },
43
+ DUPLICATE_ID: {
44
+ code: "D2003",
45
+ message: "Duplicate element ID"
46
+ },
47
+ ELEMENT_TAGNAME_MISMATCH: {
48
+ code: "D2004",
49
+ message: "Element tagName does not match the expected type"
50
+ },
51
+ INVALID_PARENT_CHILD: {
52
+ code: "D3001",
53
+ message: "Invalid parent-child relationship"
54
+ },
55
+ INVALID_ATTRIBUTE: {
56
+ code: "D3002",
57
+ message: "Invalid attribute for element"
58
+ },
59
+ PROTECTED_ROOT: {
60
+ code: "D3003",
61
+ message: "Root element cannot be deleted"
62
+ },
63
+ REQUIRED_ATTRIBUTE_MISSING: {
64
+ code: "D3004",
65
+ message: "Required attribute is missing"
66
+ },
67
+ ALREADY_COMMITTED: {
68
+ code: "D4001",
69
+ message: "Transaction already committed"
70
+ },
71
+ ALREADY_FAILED: {
72
+ code: "D4002",
73
+ message: "Transaction already failed"
74
+ },
75
+ DATABASE_COMMIT_ERROR: {
76
+ code: "D4003",
77
+ message: "An error occurred while committing changes to the database"
78
+ },
79
+ CONCURRENT_TRANSACTION: {
80
+ code: "D4004",
81
+ message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue."
82
+ },
83
+ EXPORT_ROOT_NOT_FOUND: {
84
+ code: "D5001",
85
+ message: "Root element not found in records during export"
86
+ },
87
+ EXPORT_ORPHAN_CHILD_REF: {
88
+ code: "D5002",
89
+ message: "Parent references non-existent child record"
90
+ },
91
+ EXTENSION_METHOD_COLLISION: {
92
+ code: "D6001",
93
+ message: "Extension method name collision detected"
94
+ },
95
+ UNKNOWN_CONFIG_KEY: {
96
+ code: "D7001",
97
+ message: "Unknown config key"
98
+ },
99
+ DOCUMENT_NOT_REGISTERED: {
100
+ code: "D7002",
101
+ message: "Document not registered in project"
102
+ },
103
+ PROJECT_NOT_OPENED: {
104
+ code: "D7003",
105
+ message: "Project not opened"
106
+ }
107
+ };
108
+ function t(t, r) {
109
+ let i = e[t], a = {
110
+ code: i.code,
111
+ key: t,
112
+ message: r.message ?? i.message,
113
+ detail: r.detail,
114
+ method: n((/* @__PURE__ */ Error()).stack),
115
+ ref: r.ref,
116
+ cause: r.cause
117
+ }, o = Error(r.detail);
118
+ throw o.cause = a, o;
119
+ }
120
+ function n(e) {
121
+ if (!e) return "unknown";
122
+ let t = e.split("\n").slice(1).find((e) => !/\b(throwDialecteError|assert)\b/.test(e));
123
+ if (!t) return "unknown";
124
+ let n = t.match(/\bat\s+(\S+)\s+\(([^)]+)\)/), r = n?.[1], i = n?.[2];
125
+ if (!i || !r) return r ?? "unknown";
126
+ let a = i.match(/(\w[\w-]*\/src\/[^?:]+)/);
127
+ return a ? `${a[1].replace(/\.[^/.]+$/, "")}::${r}` : r;
128
+ }
129
+ function r(e, n) {
130
+ if (e) return;
131
+ let { detail: r, key: i = "ASSERTION_FAILED", ref: a } = n;
132
+ t(i, {
133
+ detail: r,
134
+ ref: a
135
+ });
136
+ }
137
+ //#endregion
138
+ export { r as D };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { AcceptableValue } from 'reka-ui';
2
+ import { AllowedComponentProps } from 'vue';
2
3
  import { AnyDialecteConfig } from '@dialecte/core';
3
4
  import { Component } from 'vue';
5
+ import { ComponentCustomProps } from 'vue';
4
6
  import { ComponentOptionsMixin } from 'vue';
5
7
  import { ComponentProvideOptions } from 'vue';
6
8
  import { ComputedRef } from 'vue';
@@ -11,6 +13,9 @@ import { Project } from '@dialecte/core';
11
13
  import { ProjectState } from '@dialecte/core';
12
14
  import { PublicProps } from 'vue';
13
15
  import { Ref } from 'vue';
16
+ import { ShallowUnwrapRef } from 'vue';
17
+ import { VNode } from 'vue';
18
+ import { VNodeProps } from 'vue';
14
19
 
15
20
  declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLButtonElement>;
16
21
 
@@ -44,6 +49,10 @@ size: "xs" | "sm" | "md" | "lg" | "xl";
44
49
  color: "neutral" | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "error";
45
50
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
46
51
 
52
+ declare type __VLS_PrettifyLocal<T> = {
53
+ [K in keyof T]: T[K];
54
+ } & {};
55
+
47
56
  declare type __VLS_Props = {
48
57
  color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
49
58
  variant?: 'outline' | 'dash' | 'soft' | 'ghost' | 'link';
@@ -156,6 +165,22 @@ declare function closeDropdown(): void;
156
165
 
157
166
  export declare const Combobox: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
158
167
 
168
+ export declare const DocumentGate: <GenericConfig extends AnyDialecteConfig>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
169
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & {
170
+ project: Project<GenericConfig>;
171
+ documentId: string | undefined;
172
+ } & Partial<{}>> & PublicProps;
173
+ expose(exposed: ShallowUnwrapRef< {}>): void;
174
+ attrs: any;
175
+ slots: {
176
+ default?(_: {}): any;
177
+ loading?(_: {}): any;
178
+ };
179
+ emit: {};
180
+ }>) => VNode & {
181
+ __ctx?: Awaited<typeof __VLS_setup>;
182
+ };
183
+
159
184
  export declare const Dropdown: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
160
185
 
161
186
  export declare const ELEMENT_TO_COLOR: Record<string, ElementColor>;
@@ -188,7 +213,27 @@ export declare function useDocumentState<GenericConfig extends AnyDialecteConfig
188
213
 
189
214
  export declare function useDocumentState<GenericConfig extends AnyDialecteConfig>(document: Document_2<GenericConfig>): DocumentState;
190
215
 
191
- export declare function useLiveData<T, GenericConfig extends AnyDialecteConfig>(params: {
216
+ /**
217
+ * Access the currently active Document.
218
+ *
219
+ * Must be called from within a <DocumentGate> subtree.
220
+ * Accessing `document` outside the gate throws.
221
+ *
222
+ * Generic on the dialecte config so consumers get fully typed
223
+ * query/transaction APIs without runtime overhead.
224
+ *
225
+ * @example
226
+ * const { document, isHydrated } = useDocumentStore<Scl.Config>()
227
+ * const root = await document.value.query.getRoot()
228
+ */
229
+ export declare function useDocumentStore<GenericConfig extends AnyDialecteConfig = AnyDialecteConfig>(): {
230
+ document: ComputedRef<Document_2<GenericConfig>>;
231
+ isHydrated: ComputedRef<boolean>;
232
+ hydrate: (doc: Document_2<GenericConfig>) => void;
233
+ clear: () => void;
234
+ };
235
+
236
+ export declare function useLiveData<GenericConfig extends AnyDialecteConfig, T>(params: {
192
237
  document: Document_2<GenericConfig> | ComputedRef<Document_2<GenericConfig>>;
193
238
  fetcher: () => Promise<T>;
194
239
  initial: T;
@@ -199,7 +244,7 @@ export declare function useLiveData<T, GenericConfig extends AnyDialecteConfig>(
199
244
  refresh: (delay?: number) => Promise<T | undefined>;
200
245
  };
201
246
 
202
- export declare function useProjectLiveData<T, GenericConfig extends AnyDialecteConfig>(params: {
247
+ export declare function useProjectLiveData<GenericConfig extends AnyDialecteConfig, T>(params: {
203
248
  project: Project<GenericConfig>;
204
249
  fetcher: () => Promise<T>;
205
250
  initial: T;
package/dist/index.js CHANGED
@@ -1,11 +1,14 @@
1
- import { useLiveData as e, useProjectLiveData as t } from "./composables/use-live-data.js";
2
- import { useDocumentState as n, useProjectState as r } from "./composables/use-live-state.js";
3
- import i from "./button/button.js";
4
- import a from "./dropdown/dropdown.js";
5
- import o from "./dropdown/combobox.js";
1
+ import { useDocumentStore as e } from "./dialecte/use-document-store.js";
2
+ import t from "./dialecte/document-gate.js";
3
+ import { useLiveData as n, useProjectLiveData as r } from "./dialecte/composables/use-live-data.js";
4
+ import { useDocumentState as i, useProjectState as a } from "./dialecte/composables/use-live-state.js";
5
+ import "./dialecte/index.js";
6
+ import o from "./button/button.js";
7
+ import s from "./dropdown/dropdown.js";
8
+ import c from "./dropdown/combobox.js";
6
9
  import "./dropdown/index.js";
7
- import { CATEGORY_ELEMENTS as s, ELEMENT_TO_COLOR as c } from "./icons/element-color-map.generated.js";
8
- import { ELEMENT_TO_ICON as l } from "./icons/element-icon-mapper.js";
9
- import u from "./explorer/explorer.js";
10
+ import { CATEGORY_ELEMENTS as l, ELEMENT_TO_COLOR as u } from "./icons/element-color-map.generated.js";
11
+ import { ELEMENT_TO_ICON as d } from "./icons/element-icon-mapper.js";
12
+ import f from "./explorer/explorer.js";
10
13
  import "./explorer/index.js";
11
- export { i as Button, s as CATEGORY_ELEMENTS, o as Combobox, a as Dropdown, c as ELEMENT_TO_COLOR, l as ELEMENT_TO_ICON, u as SclExplorer, n as useDocumentState, e as useLiveData, t as useProjectLiveData, r as useProjectState };
14
+ export { o as Button, l as CATEGORY_ELEMENTS, c as Combobox, t as DocumentGate, s as Dropdown, u as ELEMENT_TO_COLOR, d as ELEMENT_TO_ICON, f as SclExplorer, i as useDocumentState, e as useDocumentStore, n as useLiveData, r as useProjectLiveData, a as useProjectState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/ui",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "source": "lib/index.ts",
6
6
  "scripts": {