@septkit/ui 0.0.25 → 0.0.27

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,7 +1,7 @@
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
7
  return r(() => {
@@ -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,20 @@
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/create-document-store.ts
4
+ function r() {
5
+ let r = n(null), i = t(() => (e(r.value, { detail: "createDocumentStore: document accessed before hydration. Ensure hydrate() is called before consumers read document, or guard with isHydrated." }), r.value)), a = t(() => r.value !== null);
6
+ function o(e) {
7
+ r.value = e;
8
+ }
9
+ function s() {
10
+ r.value = null;
11
+ }
12
+ return {
13
+ document: i,
14
+ isHydrated: a,
15
+ hydrate: o,
16
+ clear: s
17
+ };
18
+ }
19
+ //#endregion
20
+ export { r as createDocumentStore };
@@ -0,0 +1,4 @@
1
+ import "./create-document-store.js";
2
+ import "./composables/use-live-data.js";
3
+ import "./composables/use-live-state.js";
4
+ import "./composables/index.js";
@@ -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
@@ -156,6 +156,37 @@ declare function closeDropdown(): void;
156
156
 
157
157
  export declare const Combobox: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
158
158
 
159
+ /**
160
+ * Build a per-extension reactive document store.
161
+ *
162
+ * Each call returns an isolated singleton (closure-scoped state). Extensions
163
+ * should invoke this once at module level and re-export the returned bindings.
164
+ *
165
+ * The store has no knowledge of the shell. The extension is responsible for
166
+ * calling `hydrate(doc)` whenever the active document changes, and `clear()`
167
+ * when no document is selected.
168
+ *
169
+ * `document.value` throws if accessed before hydration. Use `isHydrated` to
170
+ * guard render paths that depend on a real document.
171
+ *
172
+ * @example
173
+ * // per-extension: src/document-store.ts
174
+ * import type { Scl } from '@dialecte/scl/v2019C1'
175
+ * export const { document, isHydrated, hydrate, clear } =
176
+ * createDocumentStore<Scl.Document>()
177
+ *
178
+ * // bootstrap (e.g. set-editor.ts), wired before app.mount:
179
+ * api.activeDocumentId.subscribe((id) => {
180
+ * id ? hydrate(api.project.openDocument(id)) : clear()
181
+ * })
182
+ */
183
+ export declare function createDocumentStore<GenericDocument>(): {
184
+ document: ComputedRef<GenericDocument>;
185
+ isHydrated: ComputedRef<boolean>;
186
+ hydrate: (doc: GenericDocument) => void;
187
+ clear: () => void;
188
+ };
189
+
159
190
  export declare const Dropdown: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
160
191
 
161
192
  export declare const ELEMENT_TO_COLOR: Record<string, ElementColor>;
@@ -188,7 +219,7 @@ export declare function useDocumentState<GenericConfig extends AnyDialecteConfig
188
219
 
189
220
  export declare function useDocumentState<GenericConfig extends AnyDialecteConfig>(document: Document_2<GenericConfig>): DocumentState;
190
221
 
191
- export declare function useLiveData<T, GenericConfig extends AnyDialecteConfig>(params: {
222
+ export declare function useLiveData<GenericConfig extends AnyDialecteConfig, T>(params: {
192
223
  document: Document_2<GenericConfig> | ComputedRef<Document_2<GenericConfig>>;
193
224
  fetcher: () => Promise<T>;
194
225
  initial: T;
@@ -199,7 +230,7 @@ export declare function useLiveData<T, GenericConfig extends AnyDialecteConfig>(
199
230
  refresh: (delay?: number) => Promise<T | undefined>;
200
231
  };
201
232
 
202
- export declare function useProjectLiveData<T, GenericConfig extends AnyDialecteConfig>(params: {
233
+ export declare function useProjectLiveData<GenericConfig extends AnyDialecteConfig, T>(params: {
203
234
  project: Project<GenericConfig>;
204
235
  fetcher: () => Promise<T>;
205
236
  initial: T;
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
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 { createDocumentStore as e } from "./dialecte/create-document-store.js";
2
+ import { useLiveData as t, useProjectLiveData as n } from "./dialecte/composables/use-live-data.js";
3
+ import { useDocumentState as r, useProjectState as i } from "./dialecte/composables/use-live-state.js";
4
+ import "./dialecte/index.js";
5
+ import a from "./button/button.js";
6
+ import o from "./dropdown/dropdown.js";
7
+ import s from "./dropdown/combobox.js";
6
8
  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";
9
+ import { CATEGORY_ELEMENTS as c, ELEMENT_TO_COLOR as l } from "./icons/element-color-map.generated.js";
10
+ import { ELEMENT_TO_ICON as u } from "./icons/element-icon-mapper.js";
11
+ import d from "./explorer/explorer.js";
10
12
  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 };
13
+ export { a as Button, c as CATEGORY_ELEMENTS, s as Combobox, o as Dropdown, l as ELEMENT_TO_COLOR, u as ELEMENT_TO_ICON, d as SclExplorer, e as createDocumentStore, r as useDocumentState, t as useLiveData, n as useProjectLiveData, i as useProjectState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/ui",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "source": "lib/index.ts",
6
6
  "scripts": {