@openpen/module-api 1.1.0 → 1.2.0

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/_chunks/AppButtonDropdown.vue_vue_type_style_index_0_lang-DBVFUpxc.js +245 -0
  3. package/dist/_chunks/AppButtonDropdown.vue_vue_type_style_index_0_lang-DBVFUpxc.js.map +1 -0
  4. package/dist/_chunks/inject-keys-CRXCpN-M.js +196 -0
  5. package/dist/_chunks/inject-keys-CRXCpN-M.js.map +1 -0
  6. package/dist/_chunks/module-context-registry-Cn1IWYu9.js +16 -0
  7. package/dist/_chunks/module-context-registry-Cn1IWYu9.js.map +1 -0
  8. package/dist/_chunks/passthrough-DKU7JYuQ.js +6 -0
  9. package/dist/_chunks/passthrough-DKU7JYuQ.js.map +1 -0
  10. package/dist/cursors.d.ts +83 -0
  11. package/dist/define-module.d.ts +17 -0
  12. package/dist/host/color-utils.d.ts +11 -0
  13. package/{src/host/event-bus.ts → dist/host/event-bus.d.ts} +7 -5
  14. package/dist/host/host-commands.d.ts +1 -0
  15. package/dist/host/index.d.ts +24 -0
  16. package/dist/host/index.js +49 -0
  17. package/dist/host/index.js.map +1 -0
  18. package/{src/host/module-context-registry.ts → dist/host/module-context-registry.d.ts} +5 -19
  19. package/dist/host/passthrough.d.ts +2 -0
  20. package/dist/host/popup-anchor.d.ts +3 -0
  21. package/dist/host/registry.d.ts +39 -0
  22. package/dist/host/registry.js +37 -0
  23. package/dist/host/registry.js.map +1 -0
  24. package/dist/host/slot-entries.d.ts +2 -0
  25. package/dist/host/stroke-store.d.ts +5 -0
  26. package/dist/host/stroke-style.d.ts +3 -0
  27. package/dist/host/types.d.ts +164 -0
  28. package/dist/index.d.ts +28 -0
  29. package/dist/index.js +349 -0
  30. package/dist/index.js.map +1 -0
  31. package/{src/inject-keys.ts → dist/inject-keys.d.ts} +37 -66
  32. package/{src/locale.ts → dist/locale.d.ts} +3 -22
  33. package/dist/slots.d.ts +57 -0
  34. package/dist/types/contributions.d.ts +288 -0
  35. package/dist/types/control-bar-layout.d.ts +227 -0
  36. package/dist/types/module.d.ts +208 -0
  37. package/{src/types/notification.ts → dist/types/notification.d.ts} +12 -14
  38. package/dist/types/tool.d.ts +77 -0
  39. package/dist/uikit/components/AppBanner.vue.d.ts +34 -0
  40. package/dist/uikit/components/AppButton.vue.d.ts +30 -0
  41. package/dist/uikit/components/AppButtonDropdown.vue.d.ts +52 -0
  42. package/dist/uikit/components/AppDialog.vue.d.ts +53 -0
  43. package/dist/uikit/components/AppPopover.vue.d.ts +43 -0
  44. package/dist/uikit/components/AppSegmented.vue.d.ts +19 -0
  45. package/dist/uikit/components/AppSelect.vue.d.ts +26 -0
  46. package/dist/uikit/components/AppSlider.vue.d.ts +43 -0
  47. package/dist/uikit/components/AppTabs.vue.d.ts +35 -0
  48. package/dist/uikit/components/AppToggle.vue.d.ts +13 -0
  49. package/dist/uikit/components/AppTooltip.vue.d.ts +27 -0
  50. package/dist/uikit/components/DialogHost.vue.d.ts +3 -0
  51. package/{src/uikit/composables/dialog-internal-keys.ts → dist/uikit/composables/dialog-internal-keys.d.ts} +3 -5
  52. package/dist/uikit/composables/useDialog.d.ts +399 -0
  53. package/dist/uikit/composables/useDialogPluginComponent.d.ts +9 -0
  54. package/dist/uikit/index.d.ts +42 -0
  55. package/dist/uikit/index.js +884 -0
  56. package/dist/uikit/index.js.map +1 -0
  57. package/{src/uikit/internal.ts → dist/uikit/internal.d.ts} +1 -1
  58. package/dist/uikit/internal.js +157 -0
  59. package/dist/uikit/internal.js.map +1 -0
  60. package/dist/uikit/module-api.css +851 -0
  61. package/dist/uikit/primitives.d.ts +42 -0
  62. package/{src/use-module-context.ts → dist/use-module-context.d.ts} +2 -15
  63. package/{src/validation.ts → dist/validation.d.ts} +2 -6
  64. package/package.json +26 -12
  65. package/packages/module-api/CHANGELOG.md +0 -27
  66. package/src/cursors.ts +0 -369
  67. package/src/define-module.ts +0 -55
  68. package/src/host/color-utils.ts +0 -18
  69. package/src/host/host-commands.ts +0 -9
  70. package/src/host/index.ts +0 -53
  71. package/src/host/passthrough.ts +0 -10
  72. package/src/host/popup-anchor.ts +0 -14
  73. package/src/host/slot-entries.ts +0 -9
  74. package/src/host/stroke-store.ts +0 -20
  75. package/src/host/stroke-style.ts +0 -15
  76. package/src/index.ts +0 -131
  77. package/src/slots.ts +0 -135
  78. package/src/types/contributions.ts +0 -333
  79. package/src/types/control-bar-layout.ts +0 -174
  80. package/src/types/module.ts +0 -225
  81. package/src/types/tool.ts +0 -82
  82. package/src/uikit/components/.gitkeep +0 -0
  83. package/src/uikit/components/AppBanner.vue +0 -131
  84. package/src/uikit/components/AppButton.vue +0 -135
  85. package/src/uikit/components/AppDialog.vue +0 -393
  86. package/src/uikit/components/AppPopover.vue +0 -268
  87. package/src/uikit/components/AppSegmented.vue +0 -128
  88. package/src/uikit/components/AppSelect.vue +0 -235
  89. package/src/uikit/components/AppSlider.vue +0 -204
  90. package/src/uikit/components/AppTabs.vue +0 -163
  91. package/src/uikit/components/AppToggle.vue +0 -96
  92. package/src/uikit/components/AppTooltip.vue +0 -118
  93. package/src/uikit/components/DialogHost.vue +0 -272
  94. package/src/uikit/composables/useDialog.ts +0 -141
  95. package/src/uikit/composables/useDialogPluginComponent.ts +0 -27
  96. package/src/uikit/index.ts +0 -79
  97. package/src/uikit/primitives.ts +0 -150
  98. /package/{src → dist}/uikit/tokens.css +0 -0
@@ -1,141 +0,0 @@
1
- /**
2
- * useDialog — imperative dialog API for OpenPen modules.
3
- *
4
- * Returns a DialogApi with confirm/alert/prompt/custom methods that each
5
- * return a Promise. At most one imperative dialog is open at a time; extra
6
- * calls are queued and executed sequentially.
7
- *
8
- * The active request is stored in a module-scoped reactive store. DialogHost
9
- * (mounted by the host at bootstrap) reads this store and renders the dialog.
10
- *
11
- * Usage:
12
- * const dialog = useDialog()
13
- * const ok = await dialog.confirm({ title: 'Delete?', message: '...' })
14
- */
15
- import type { Component } from 'vue'
16
- import { ref } from 'vue'
17
-
18
- // ── Public option types ───────────────────────────────────────────────────────
19
-
20
- interface BaseDialogOptions {
21
- title: string
22
- persistent?: boolean
23
- danger?: boolean
24
- }
25
-
26
- export interface DialogConfirmOptions extends BaseDialogOptions {
27
- message: string
28
- okLabel?: string
29
- cancelLabel?: string
30
- }
31
-
32
- export interface DialogAlertOptions extends BaseDialogOptions {
33
- message: string
34
- okLabel?: string
35
- }
36
-
37
- export interface DialogPromptOptions extends BaseDialogOptions {
38
- message: string
39
- defaultValue?: string
40
- placeholder?: string
41
- okLabel?: string
42
- cancelLabel?: string
43
- }
44
-
45
- export interface DialogCustomOptions<T = unknown> extends BaseDialogOptions {
46
- component: Component
47
- componentProps?: Record<string, unknown>
48
- /** Phantom type field for TypeScript to infer the resolution payload type. */
49
- __payloadType?: T
50
- }
51
-
52
- // ── Internal request types (tagged union) ─────────────────────────────────────
53
-
54
- type DialogRequest =
55
- | { kind: 'confirm'; opts: DialogConfirmOptions; resolve: (v: boolean) => void }
56
- | { kind: 'alert'; opts: DialogAlertOptions; resolve: () => void }
57
- | { kind: 'prompt'; opts: DialogPromptOptions; resolve: (v: string | null) => void }
58
- | { kind: 'custom'; opts: DialogCustomOptions<unknown>; resolve: (v: unknown) => void }
59
-
60
- // ── Module-scoped store ───────────────────────────────────────────────────────
61
- //
62
- // Single reactive ref holds the currently rendered request. DialogHost watches
63
- // this and renders the appropriate dialog. When DialogHost resolves a request,
64
- // it calls resolveActive() which drains the queue.
65
-
66
- export const _activeRequest = ref<DialogRequest | null>(null)
67
-
68
- const _queue: (() => void)[] = []
69
- let _processing = false
70
-
71
- function _enqueue(run: () => void): void {
72
- if (_processing) {
73
- _queue.push(run)
74
- } else {
75
- _processing = true
76
- run()
77
- }
78
- }
79
-
80
- /**
81
- * Called by DialogHost when the dialog is resolved (ok/cancel/dismiss).
82
- * Advances the queue if there are pending requests.
83
- */
84
- export function _resolveActive(): void {
85
- _activeRequest.value = null
86
- const next = _queue.shift()
87
- if (next) {
88
- next()
89
- } else {
90
- _processing = false
91
- }
92
- }
93
-
94
- // ── Public API ────────────────────────────────────────────────────────────────
95
-
96
- export interface DialogApi {
97
- confirm(opts: DialogConfirmOptions): Promise<boolean>
98
- alert(opts: DialogAlertOptions): Promise<void>
99
- prompt(opts: DialogPromptOptions): Promise<string | null>
100
- custom<T = unknown>(opts: DialogCustomOptions<T>): Promise<T | null>
101
- }
102
-
103
- export function useDialog(): DialogApi {
104
- return {
105
- confirm(opts: DialogConfirmOptions): Promise<boolean> {
106
- return new Promise<boolean>((resolve) => {
107
- _enqueue(() => {
108
- _activeRequest.value = { kind: 'confirm', opts, resolve }
109
- })
110
- })
111
- },
112
-
113
- alert(opts: DialogAlertOptions): Promise<void> {
114
- return new Promise<void>((resolve) => {
115
- _enqueue(() => {
116
- _activeRequest.value = { kind: 'alert', opts, resolve }
117
- })
118
- })
119
- },
120
-
121
- prompt(opts: DialogPromptOptions): Promise<string | null> {
122
- return new Promise<string | null>((resolve) => {
123
- _enqueue(() => {
124
- _activeRequest.value = { kind: 'prompt', opts, resolve }
125
- })
126
- })
127
- },
128
-
129
- custom<T = unknown>(opts: DialogCustomOptions<T>): Promise<T | null> {
130
- return new Promise<T | null>((resolve) => {
131
- _enqueue(() => {
132
- _activeRequest.value = {
133
- kind: 'custom',
134
- opts: opts as DialogCustomOptions<unknown>,
135
- resolve: resolve as (v: unknown) => void,
136
- }
137
- })
138
- })
139
- },
140
- }
141
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * useDialogPluginComponent — composable for components rendered via useDialog().custom().
3
- *
4
- * The custom component calls this to get ok/cancel/dismiss callbacks, which
5
- * resolve the Promise returned by useDialog().custom().
6
- */
7
- import { inject } from 'vue'
8
- import { DIALOG_PLUGIN_HANDLE_KEY } from './dialog-internal-keys'
9
-
10
- export interface DialogPluginComponentHandle<T = unknown> {
11
- /** Resolve with a payload value and close the dialog. */
12
- ok(payload?: T): void
13
- /** Resolve with null and close the dialog. */
14
- cancel(): void
15
- /** Alias for cancel() — resolves with null. */
16
- dismiss(): void
17
- }
18
-
19
- export function useDialogPluginComponent<T = unknown>(): DialogPluginComponentHandle<T> {
20
- const handle = inject(DIALOG_PLUGIN_HANDLE_KEY)
21
- if (!handle) {
22
- throw new Error(
23
- 'useDialogPluginComponent() must be called inside a component rendered via useDialog().custom()'
24
- )
25
- }
26
- return handle as DialogPluginComponentHandle<T>
27
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * @openpen/module-api/uikit — Three-layer API surface
3
- *
4
- * Layer 1 — High-level Wrappers (80% case)
5
- * OpenPen-opinionated components with preset styles + auto-injected host
6
- * context. Plugin authors should start here: no knowledge of inject keys
7
- * or Reka UI primitives required.
8
- *
9
- * Layer 2 — Primitive Re-exports (20% advanced)
10
- * Raw Reka UI headless components. Use when you need full control over
11
- * markup / styling but still want a11y / focus / keyboard nav behaviour.
12
- * Note: you must manually handle modal-manager, animating guard,
13
- * passthrough, and teleport target when walking this layer.
14
- *
15
- * Layer 3 — Escape Hatch (5% fully custom)
16
- * Plugin installs reka-ui (or any library) directly in its own package.json.
17
- * UIKit MUST NOT block this. Not handled here — plugin author's choice.
18
- *
19
- * See docs/reference/uikit.md for the full trade-off description.
20
- */
21
-
22
- // ── Layer 1: High-level Wrappers ──────────────────────────────────────────────
23
-
24
- export { default as AppPopover } from './components/AppPopover.vue'
25
- export type { AppPopoverProps, Placement } from './components/AppPopover.vue'
26
-
27
- export { default as AppSlider } from './components/AppSlider.vue'
28
- export { default as AppToggle } from './components/AppToggle.vue'
29
- export { default as AppSegmented } from './components/AppSegmented.vue'
30
-
31
- export { default as AppDialog } from './components/AppDialog.vue'
32
- export type { AppDialogProps } from './components/AppDialog.vue'
33
-
34
- export { useDialog } from './composables/useDialog'
35
- export type {
36
- DialogConfirmOptions,
37
- DialogAlertOptions,
38
- DialogPromptOptions,
39
- DialogCustomOptions,
40
- } from './composables/useDialog'
41
- export { useDialogPluginComponent } from './composables/useDialogPluginComponent'
42
-
43
- // Host-internal: shared by DialogHost so it sees the same _activeRequest ref
44
- // instance as useDialog() callers. MUST be exported via this barrel — the
45
- // uikit runtime bundle (dist/openpen-runtime/module-api-uikit.js) is the
46
- // single shared module instance referenced by the importmap; a relative
47
- // '../composables/useDialog' import in DialogHost would bundle a second
48
- // duplicate ref into the host bundle (see project_dev_prod_parity.md), so
49
- // dialog.confirm() would never reach DialogHost in production.
50
- // Underscore-prefixed: NOT part of the plugin-facing API surface.
51
- export { _activeRequest, _resolveActive } from './composables/useDialog'
52
- export { default as AppSelect } from './components/AppSelect.vue'
53
- export type { AppSelectProps, SelectOption } from './components/AppSelect.vue'
54
- export { default as AppTooltip } from './components/AppTooltip.vue'
55
- export type { AppTooltipProps, TooltipSide } from './components/AppTooltip.vue'
56
- export { default as AppTabs } from './components/AppTabs.vue'
57
- export type { AppTabsProps, AppTabItem } from './components/AppTabs.vue'
58
-
59
- export { default as AppBanner } from './components/AppBanner.vue'
60
- export type { BannerVariant } from './components/AppBanner.vue'
61
-
62
- export { default as AppButton } from './components/AppButton.vue'
63
-
64
- // ── Layer 2: Primitive Re-exports ────────────────────────────────────────────
65
- //
66
- // Re-export entire primitives namespace.
67
- // MUST NOT re-export any reka-ui type through this index — wrapper types only.
68
- // (primitives.ts is the designated channel for the raw headless exports.)
69
- export * from './primitives'
70
-
71
- // ── Host context inject keys ──────────────────────────────────────────────────
72
- //
73
- // Keys are defined in @openpen/module-api root inject-keys.ts and re-exported
74
- // here for convenience. Plugin authors who need to walk Layer 2 should import
75
- // from the root package:
76
- // import { WRAPPER_EL_KEY, MODAL_MANAGER_KEY } from '@openpen/module-api'
77
- //
78
- // Root index.ts already covers:
79
- // WRAPPER_EL_KEY, SNAP_EDGE_KEY, MODAL_MANAGER_KEY, ANCHOR_EL_KEY.
@@ -1,150 +0,0 @@
1
- /**
2
- * Reka UI primitive re-exports.
3
- *
4
- * This module exposes the raw Reka UI headless components for plugin authors
5
- * who need full control over markup and styling but still want Reka UI's
6
- * a11y / focus / keyboard navigation behaviour.
7
- *
8
- * Usage (escape hatch from high-level wrappers):
9
- * import { PopoverRoot, PopoverTrigger, ... } from '@openpen/module-api/uikit'
10
- * // or directly:
11
- * import { ... } from '@openpen/module-api/uikit/primitives' (if re-exported)
12
- *
13
- * WARNING: Walking this layer means you must manually handle:
14
- * - Modal manager mutual exclusion
15
- * - ControlBar animation auto-close (inject CONTROL_BAR_ANIMATING_KEY)
16
- * - Mouse passthrough guard (usePassthroughGuard)
17
- * - Teleport target (inject WRAPPER_EL_KEY)
18
- *
19
- * See docs/reference/uikit.md for the full trade-off description.
20
- *
21
- * All v1.0 high-level wrappers are implemented — prefer them over
22
- * the corresponding primitive:
23
- * Popover → AppPopover
24
- * Dialog → AppDialog
25
- * Slider → AppSlider
26
- * Switch → AppToggle
27
- * RadioGroup → AppSegmented
28
- * Select → AppSelect
29
- * Tooltip → AppTooltip
30
- * Tabs → AppTabs
31
- */
32
-
33
- // ── Popover ──────────────────────────────────────────────────────────────────
34
- export {
35
- PopoverRoot,
36
- PopoverTrigger,
37
- PopoverPortal,
38
- PopoverContent,
39
- PopoverArrow,
40
- PopoverClose,
41
- PopoverAnchor,
42
- } from 'reka-ui'
43
-
44
- // ── Dialog (Modal) ────────────────────────────────────────────────────────────
45
- export {
46
- DialogRoot,
47
- DialogTrigger,
48
- DialogPortal,
49
- DialogContent,
50
- DialogOverlay,
51
- DialogClose,
52
- DialogTitle,
53
- DialogDescription,
54
- } from 'reka-ui'
55
-
56
- // ── Slider ────────────────────────────────────────────────────────────────────
57
- export {
58
- SliderRoot,
59
- SliderTrack,
60
- SliderRange,
61
- SliderThumb,
62
- } from 'reka-ui'
63
-
64
- // ── Switch (Toggle) ───────────────────────────────────────────────────────────
65
- export {
66
- SwitchRoot,
67
- SwitchThumb,
68
- } from 'reka-ui'
69
-
70
- // ── RadioGroup (Segmented) ────────────────────────────────────────────────────
71
- export {
72
- RadioGroupRoot,
73
- RadioGroupItem,
74
- RadioGroupIndicator,
75
- } from 'reka-ui'
76
-
77
- // ── Select ────────────────────────────────────────────────────────────────────
78
- export {
79
- SelectRoot,
80
- SelectTrigger,
81
- SelectPortal,
82
- SelectContent,
83
- SelectViewport,
84
- SelectItem,
85
- SelectItemText,
86
- SelectItemIndicator,
87
- SelectLabel,
88
- SelectGroup,
89
- SelectSeparator,
90
- SelectScrollUpButton,
91
- SelectScrollDownButton,
92
- SelectArrow,
93
- SelectValue,
94
- SelectIcon,
95
- } from 'reka-ui'
96
-
97
- // ── Tooltip ───────────────────────────────────────────────────────────────────
98
- export {
99
- TooltipProvider,
100
- TooltipRoot,
101
- TooltipTrigger,
102
- TooltipPortal,
103
- TooltipContent,
104
- TooltipArrow,
105
- } from 'reka-ui'
106
-
107
- // ── Tabs ──────────────────────────────────────────────────────────────────────
108
- export {
109
- TabsRoot,
110
- TabsList,
111
- TabsTrigger,
112
- TabsContent,
113
- } from 'reka-ui'
114
-
115
- // ── NumberField (numeric spinner with +/- buttons) ────────────────────────────
116
- export {
117
- NumberFieldRoot,
118
- NumberFieldInput,
119
- NumberFieldIncrement,
120
- NumberFieldDecrement,
121
- } from 'reka-ui'
122
-
123
- // ── TagsInput (chip / token input) ────────────────────────────────────────────
124
- export {
125
- TagsInputRoot,
126
- TagsInputInput,
127
- TagsInputItem,
128
- TagsInputItemText,
129
- TagsInputItemDelete,
130
- TagsInputClear,
131
- } from 'reka-ui'
132
-
133
- // ── Combobox (searchable dropdown with free-text input) ───────────────────────
134
- export {
135
- ComboboxRoot,
136
- ComboboxAnchor,
137
- ComboboxInput,
138
- ComboboxTrigger,
139
- ComboboxPortal,
140
- ComboboxContent,
141
- ComboboxViewport,
142
- ComboboxItem,
143
- ComboboxItemIndicator,
144
- ComboboxGroup,
145
- ComboboxLabel,
146
- ComboboxSeparator,
147
- ComboboxEmpty,
148
- ComboboxArrow,
149
- ComboboxCancel,
150
- } from 'reka-ui'
File without changes