@septkit/ui 0.0.26 → 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,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 };
@@ -1,5 +1,4 @@
1
- import "./use-document-store.js";
2
- import "./document-gate.js";
1
+ import "./create-document-store.js";
3
2
  import "./composables/use-live-data.js";
4
3
  import "./composables/use-live-state.js";
5
4
  import "./composables/index.js";
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { AcceptableValue } from 'reka-ui';
2
- import { AllowedComponentProps } from 'vue';
3
2
  import { AnyDialecteConfig } from '@dialecte/core';
4
3
  import { Component } from 'vue';
5
- import { ComponentCustomProps } from 'vue';
6
4
  import { ComponentOptionsMixin } from 'vue';
7
5
  import { ComponentProvideOptions } from 'vue';
8
6
  import { ComputedRef } from 'vue';
@@ -13,9 +11,6 @@ import { Project } from '@dialecte/core';
13
11
  import { ProjectState } from '@dialecte/core';
14
12
  import { PublicProps } from 'vue';
15
13
  import { Ref } from 'vue';
16
- import { ShallowUnwrapRef } from 'vue';
17
- import { VNode } from 'vue';
18
- import { VNodeProps } from 'vue';
19
14
 
20
15
  declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLButtonElement>;
21
16
 
@@ -49,10 +44,6 @@ size: "xs" | "sm" | "md" | "lg" | "xl";
49
44
  color: "neutral" | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "error";
50
45
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
51
46
 
52
- declare type __VLS_PrettifyLocal<T> = {
53
- [K in keyof T]: T[K];
54
- } & {};
55
-
56
47
  declare type __VLS_Props = {
57
48
  color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
58
49
  variant?: 'outline' | 'dash' | 'soft' | 'ghost' | 'link';
@@ -165,20 +156,35 @@ declare function closeDropdown(): void;
165
156
 
166
157
  export declare const Combobox: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
167
158
 
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>;
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;
182
188
  };
183
189
 
184
190
  export declare const Dropdown: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
@@ -213,26 +219,6 @@ export declare function useDocumentState<GenericConfig extends AnyDialecteConfig
213
219
 
214
220
  export declare function useDocumentState<GenericConfig extends AnyDialecteConfig>(document: Document_2<GenericConfig>): DocumentState;
215
221
 
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
222
  export declare function useLiveData<GenericConfig extends AnyDialecteConfig, T>(params: {
237
223
  document: Document_2<GenericConfig> | ComputedRef<Document_2<GenericConfig>>;
238
224
  fetcher: () => Promise<T>;
package/dist/index.js CHANGED
@@ -1,14 +1,13 @@
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";
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";
5
4
  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";
5
+ import a from "./button/button.js";
6
+ import o from "./dropdown/dropdown.js";
7
+ import s from "./dropdown/combobox.js";
9
8
  import "./dropdown/index.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";
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";
13
12
  import "./explorer/index.js";
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 };
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.26",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "source": "lib/index.ts",
6
6
  "scripts": {
@@ -1,5 +0,0 @@
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 };
@@ -1,18 +0,0 @@
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 };
@@ -1,21 +0,0 @@
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 };