@blogmcp/mdx-render-vue 0.1.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 (249) hide show
  1. package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
  2. package/dist/_virtual/constants.js +4 -0
  3. package/dist/_virtual/index.js +5 -0
  4. package/dist/_virtual/index2.js +4 -0
  5. package/dist/composables/index.d.ts +11 -0
  6. package/dist/composables/index.js +24 -0
  7. package/dist/composables/useAudioPlayer.d.ts +22 -0
  8. package/dist/composables/useAudioPlayer.js +58 -0
  9. package/dist/composables/useCallout.d.ts +43 -0
  10. package/dist/composables/useCallout.js +71 -0
  11. package/dist/composables/useCodeBlock.d.ts +23 -0
  12. package/dist/composables/useCodeBlock.js +67 -0
  13. package/dist/composables/useGallery.d.ts +37 -0
  14. package/dist/composables/useGallery.js +84 -0
  15. package/dist/composables/useMedia.d.ts +18 -0
  16. package/dist/composables/useMedia.js +9 -0
  17. package/dist/composables/useYouTube.d.ts +31 -0
  18. package/dist/composables/useYouTube.js +32 -0
  19. package/dist/edit/AlertEdit.vue.d.ts +12 -0
  20. package/dist/edit/AlertEdit.vue.js +4 -0
  21. package/dist/edit/AlertEdit.vue2.js +18 -0
  22. package/dist/edit/AudioPlayerEdit.vue.d.ts +3 -0
  23. package/dist/edit/AudioPlayerEdit.vue.js +117 -0
  24. package/dist/edit/AudioPlayerEdit.vue2.js +4 -0
  25. package/dist/edit/BadgeEdit.vue.d.ts +2 -0
  26. package/dist/edit/BadgeEdit.vue.js +4 -0
  27. package/dist/edit/BadgeEdit.vue2.js +13 -0
  28. package/dist/edit/ButtonEdit.vue.d.ts +2 -0
  29. package/dist/edit/ButtonEdit.vue.js +4 -0
  30. package/dist/edit/ButtonEdit.vue2.js +13 -0
  31. package/dist/edit/CalloutEdit.vue.d.ts +13 -0
  32. package/dist/edit/CalloutEdit.vue.js +85 -0
  33. package/dist/edit/CalloutEdit.vue2.js +4 -0
  34. package/dist/edit/CardEdit.vue.d.ts +12 -0
  35. package/dist/edit/CardEdit.vue.js +4 -0
  36. package/dist/edit/CardEdit.vue2.js +18 -0
  37. package/dist/edit/CodeBlockEdit.vue.d.ts +12 -0
  38. package/dist/edit/CodeBlockEdit.vue.js +7 -0
  39. package/dist/edit/CodeBlockEdit.vue2.js +89 -0
  40. package/dist/edit/GalleryEdit.vue.d.ts +3 -0
  41. package/dist/edit/GalleryEdit.vue.js +64 -0
  42. package/dist/edit/GalleryEdit.vue2.js +4 -0
  43. package/dist/edit/IconEdit.vue.d.ts +2 -0
  44. package/dist/edit/IconEdit.vue.js +4 -0
  45. package/dist/edit/IconEdit.vue2.js +13 -0
  46. package/dist/edit/TooltipEdit.vue.d.ts +16 -0
  47. package/dist/edit/TooltipEdit.vue.js +4 -0
  48. package/dist/edit/TooltipEdit.vue2.js +24 -0
  49. package/dist/edit/YouTubeEdit.vue.d.ts +3 -0
  50. package/dist/edit/YouTubeEdit.vue.js +41 -0
  51. package/dist/edit/YouTubeEdit.vue2.js +4 -0
  52. package/dist/edit/index.d.ts +29 -0
  53. package/dist/edit/index.js +35 -0
  54. package/dist/index.d.ts +12 -0
  55. package/dist/index.js +75 -0
  56. package/dist/mdx-render-vue.css +31 -0
  57. package/dist/node_modules/@ark-ui/vue/dist/_virtual/_rolldown/runtime.js +13 -0
  58. package/dist/node_modules/@ark-ui/vue/dist/components/factory.js +35 -0
  59. package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence-context.js +6 -0
  60. package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence.js +40 -0
  61. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.js +5 -0
  62. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.vue_vue_type_script_setup_true_lang.js +21 -0
  63. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.js +5 -0
  64. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.vue_vue_type_script_setup_true_lang.js +21 -0
  65. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.js +5 -0
  66. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.vue_vue_type_script_setup_true_lang.js +25 -0
  67. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.js +5 -0
  68. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.vue_vue_type_script_setup_true_lang.js +14 -0
  69. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.js +5 -0
  70. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.vue_vue_type_script_setup_true_lang.js +23 -0
  71. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.js +5 -0
  72. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.vue_vue_type_script_setup_true_lang.js +38 -0
  73. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.js +5 -0
  74. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.vue_vue_type_script_setup_true_lang.js +68 -0
  75. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.js +5 -0
  76. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.vue_vue_type_script_setup_true_lang.js +25 -0
  77. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip.js +22 -0
  78. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip-context.js +6 -0
  79. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip.js +36 -0
  80. package/dist/node_modules/@ark-ui/vue/dist/providers/environment/use-environment-context.js +13 -0
  81. package/dist/node_modules/@ark-ui/vue/dist/providers/locale/use-locale-context.js +12 -0
  82. package/dist/node_modules/@ark-ui/vue/dist/utils/clean-props.js +8 -0
  83. package/dist/node_modules/@ark-ui/vue/dist/utils/create-context.js +14 -0
  84. package/dist/node_modules/@ark-ui/vue/dist/utils/dynamic.js +34 -0
  85. package/dist/node_modules/@ark-ui/vue/dist/utils/unref-element.js +8 -0
  86. package/dist/node_modules/@ark-ui/vue/dist/utils/use-forward-expose.js +46 -0
  87. package/dist/node_modules/@ark-ui/vue/dist/utils/use-render-strategy.js +5 -0
  88. package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +20 -0
  89. package/dist/node_modules/@braintree/sanitize-url/dist/index.js +75 -0
  90. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +728 -0
  91. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +629 -0
  92. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +176 -0
  93. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +151 -0
  94. package/dist/node_modules/@iconify/vue/dist/iconify.js +1691 -0
  95. package/dist/node_modules/@zag-js/anatomy/dist/create-anatomy.js +29 -0
  96. package/dist/node_modules/@zag-js/core/dist/create-machine.js +28 -0
  97. package/dist/node_modules/@zag-js/core/dist/merge-props.js +55 -0
  98. package/dist/node_modules/@zag-js/core/dist/scope.js +20 -0
  99. package/dist/node_modules/@zag-js/core/dist/state.js +176 -0
  100. package/dist/node_modules/@zag-js/core/dist/types.js +11 -0
  101. package/dist/node_modules/@zag-js/dom-query/dist/chunk-QZ7TP4HQ.js +6 -0
  102. package/dist/node_modules/@zag-js/dom-query/dist/computed-style.js +11 -0
  103. package/dist/node_modules/@zag-js/dom-query/dist/event.js +37 -0
  104. package/dist/node_modules/@zag-js/dom-query/dist/node.js +64 -0
  105. package/dist/node_modules/@zag-js/dom-query/dist/overflow.js +28 -0
  106. package/dist/node_modules/@zag-js/dom-query/dist/platform.js +23 -0
  107. package/dist/node_modules/@zag-js/dom-query/dist/query.js +6 -0
  108. package/dist/node_modules/@zag-js/dom-query/dist/raf.js +52 -0
  109. package/dist/node_modules/@zag-js/dom-query/dist/set.js +22 -0
  110. package/dist/node_modules/@zag-js/dom-query/dist/shared.js +8 -0
  111. package/dist/node_modules/@zag-js/focus-visible/dist/index.js +159 -0
  112. package/dist/node_modules/@zag-js/popper/dist/get-anchor.js +39 -0
  113. package/dist/node_modules/@zag-js/popper/dist/get-placement.js +296 -0
  114. package/dist/node_modules/@zag-js/popper/dist/get-styles.js +47 -0
  115. package/dist/node_modules/@zag-js/popper/dist/middleware.js +79 -0
  116. package/dist/node_modules/@zag-js/popper/dist/placement.js +7 -0
  117. package/dist/node_modules/@zag-js/presence/dist/presence.connect.js +18 -0
  118. package/dist/node_modules/@zag-js/presence/dist/presence.machine.js +175 -0
  119. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.anatomy.js +7 -0
  120. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.connect.js +155 -0
  121. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.dom.js +24 -0
  122. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.machine.js +416 -0
  123. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.store.js +9 -0
  124. package/dist/node_modules/@zag-js/types/dist/prop-types.js +14 -0
  125. package/dist/node_modules/@zag-js/utils/dist/array.js +7 -0
  126. package/dist/node_modules/@zag-js/utils/dist/equal.js +36 -0
  127. package/dist/node_modules/@zag-js/utils/dist/functions.js +11 -0
  128. package/dist/node_modules/@zag-js/utils/dist/guard.js +26 -0
  129. package/dist/node_modules/@zag-js/utils/dist/object.js +16 -0
  130. package/dist/node_modules/@zag-js/utils/dist/store.js +44 -0
  131. package/dist/node_modules/@zag-js/utils/dist/warning.js +31 -0
  132. package/dist/node_modules/@zag-js/vue/dist/bindable.js +48 -0
  133. package/dist/node_modules/@zag-js/vue/dist/machine.js +258 -0
  134. package/dist/node_modules/@zag-js/vue/dist/normalize-props.js +42 -0
  135. package/dist/node_modules/@zag-js/vue/dist/refs.js +14 -0
  136. package/dist/node_modules/@zag-js/vue/dist/track.js +22 -0
  137. package/dist/node_modules/dompurify/dist/purify.es.js +1190 -0
  138. package/dist/registry.d.ts +76 -0
  139. package/dist/registry.js +164 -0
  140. package/dist/render/alert/Alert.vue.d.ts +18 -0
  141. package/dist/render/alert/Alert.vue.js +4 -0
  142. package/dist/render/alert/Alert.vue2.js +43 -0
  143. package/dist/render/alert/index.d.ts +2 -0
  144. package/dist/render/audioplayer/AudioPlayerDefault.vue.d.ts +3 -0
  145. package/dist/render/audioplayer/AudioPlayerDefault.vue.js +116 -0
  146. package/dist/render/audioplayer/AudioPlayerDefault.vue2.js +4 -0
  147. package/dist/render/audioplayer/index.d.ts +5 -0
  148. package/dist/render/audioplayer/index.js +5 -0
  149. package/dist/render/badge/Badge.vue.d.ts +10 -0
  150. package/dist/render/badge/Badge.vue.js +4 -0
  151. package/dist/render/badge/Badge.vue2.js +28 -0
  152. package/dist/render/badge/index.d.ts +2 -0
  153. package/dist/render/button/Button.vue.d.ts +13 -0
  154. package/dist/render/button/Button.vue.js +4 -0
  155. package/dist/render/button/Button.vue2.js +42 -0
  156. package/dist/render/button/index.d.ts +2 -0
  157. package/dist/render/callout/CalloutDefault.vue.d.ts +13 -0
  158. package/dist/render/callout/CalloutDefault.vue.js +86 -0
  159. package/dist/render/callout/CalloutDefault.vue2.js +4 -0
  160. package/dist/render/callout/CalloutMinimal.vue.d.ts +13 -0
  161. package/dist/render/callout/CalloutMinimal.vue.js +27 -0
  162. package/dist/render/callout/CalloutMinimal.vue2.js +4 -0
  163. package/dist/render/callout/index.d.ts +6 -0
  164. package/dist/render/callout/index.js +7 -0
  165. package/dist/render/card/Card.vue.d.ts +15 -0
  166. package/dist/render/card/Card.vue.js +4 -0
  167. package/dist/render/card/Card.vue2.js +29 -0
  168. package/dist/render/card/index.d.ts +2 -0
  169. package/dist/render/codeblock/CodeBlockDefault.vue.d.ts +12 -0
  170. package/dist/render/codeblock/CodeBlockDefault.vue.js +7 -0
  171. package/dist/render/codeblock/CodeBlockDefault.vue2.js +92 -0
  172. package/dist/render/codeblock/index.d.ts +5 -0
  173. package/dist/render/codeblock/index.js +5 -0
  174. package/dist/render/gallery/GalleryGrid.vue.d.ts +3 -0
  175. package/dist/render/gallery/GalleryGrid.vue.js +125 -0
  176. package/dist/render/gallery/GalleryGrid.vue2.js +4 -0
  177. package/dist/render/gallery/GalleryLightbox.vue.d.ts +16 -0
  178. package/dist/render/gallery/GalleryLightbox.vue.js +7 -0
  179. package/dist/render/gallery/GalleryLightbox.vue2.js +170 -0
  180. package/dist/render/gallery/index.d.ts +6 -0
  181. package/dist/render/gallery/index.js +7 -0
  182. package/dist/render/icon/Icon.vue.d.ts +9 -0
  183. package/dist/render/icon/Icon.vue.js +4 -0
  184. package/dist/render/icon/Icon.vue2.js +25 -0
  185. package/dist/render/icon/index.d.ts +2 -0
  186. package/dist/render/index.d.ts +40 -0
  187. package/dist/render/index.js +63 -0
  188. package/dist/render/tooltip/Tooltip.vue.d.ts +18 -0
  189. package/dist/render/tooltip/Tooltip.vue.js +4 -0
  190. package/dist/render/tooltip/Tooltip.vue2.js +58 -0
  191. package/dist/render/tooltip/index.d.ts +2 -0
  192. package/dist/render/youtube/YouTubeDefault.vue.d.ts +3 -0
  193. package/dist/render/youtube/YouTubeDefault.vue.js +79 -0
  194. package/dist/render/youtube/YouTubeDefault.vue2.js +4 -0
  195. package/dist/render/youtube/index.d.ts +5 -0
  196. package/dist/render/youtube/index.js +5 -0
  197. package/dist/useAudioPlayer.d.ts +22 -0
  198. package/dist/useCallout.d.ts +46 -0
  199. package/dist/useCodeBlock.d.ts +25 -0
  200. package/dist/useGallery.d.ts +44 -0
  201. package/dist/useMedia.d.ts +16 -0
  202. package/dist/useYouTube.d.ts +32 -0
  203. package/package.json +125 -0
  204. package/src/composables/index.ts +16 -0
  205. package/src/composables/useAudioPlayer.ts +84 -0
  206. package/src/composables/useCallout.ts +103 -0
  207. package/src/composables/useCodeBlock.ts +90 -0
  208. package/src/composables/useGallery.ts +143 -0
  209. package/src/composables/useMedia.ts +23 -0
  210. package/src/composables/useYouTube.ts +58 -0
  211. package/src/edit/AlertEdit.vue +9 -0
  212. package/src/edit/AudioPlayerEdit.vue +92 -0
  213. package/src/edit/BadgeEdit.vue +7 -0
  214. package/src/edit/ButtonEdit.vue +10 -0
  215. package/src/edit/CalloutEdit.vue +107 -0
  216. package/src/edit/CardEdit.vue +9 -0
  217. package/src/edit/CodeBlockEdit.vue +76 -0
  218. package/src/edit/GalleryEdit.vue +65 -0
  219. package/src/edit/IconEdit.vue +7 -0
  220. package/src/edit/TooltipEdit.vue +15 -0
  221. package/src/edit/YouTubeEdit.vue +33 -0
  222. package/src/edit/index.ts +32 -0
  223. package/src/index.ts +62 -0
  224. package/src/registry.ts +272 -0
  225. package/src/render/alert/Alert.vue +32 -0
  226. package/src/render/alert/index.ts +2 -0
  227. package/src/render/audioplayer/AudioPlayerDefault.vue +89 -0
  228. package/src/render/audioplayer/index.ts +8 -0
  229. package/src/render/badge/Badge.vue +25 -0
  230. package/src/render/badge/index.ts +2 -0
  231. package/src/render/button/Button.vue +41 -0
  232. package/src/render/button/index.ts +2 -0
  233. package/src/render/callout/CalloutDefault.vue +101 -0
  234. package/src/render/callout/CalloutMinimal.vue +31 -0
  235. package/src/render/callout/index.ts +9 -0
  236. package/src/render/card/Card.vue +15 -0
  237. package/src/render/card/index.ts +2 -0
  238. package/src/render/codeblock/CodeBlockDefault.vue +76 -0
  239. package/src/render/codeblock/index.ts +8 -0
  240. package/src/render/gallery/GalleryGrid.vue +162 -0
  241. package/src/render/gallery/GalleryLightbox.vue +162 -0
  242. package/src/render/gallery/index.ts +9 -0
  243. package/src/render/icon/Icon.vue +22 -0
  244. package/src/render/icon/index.ts +2 -0
  245. package/src/render/index.ts +76 -0
  246. package/src/render/tooltip/Tooltip.vue +35 -0
  247. package/src/render/tooltip/index.ts +2 -0
  248. package/src/render/youtube/YouTubeDefault.vue +72 -0
  249. package/src/render/youtube/index.ts +8 -0
@@ -0,0 +1,258 @@
1
+ import { computed, toValue, onMounted, onBeforeUnmount, nextTick } from "vue";
2
+ import { bindable } from "./bindable.js";
3
+ import { useRefs } from "./refs.js";
4
+ import { useTrack } from "./track.js";
5
+ import { createScope } from "../../core/dist/scope.js";
6
+ import { MachineStatus, INIT_STATE } from "../../core/dist/types.js";
7
+ import { findTransition, resolveStateValue, getExitEnterStates, hasTag, matchesState } from "../../core/dist/state.js";
8
+ import { compact } from "../../utils/dist/object.js";
9
+ import { ensure, warn } from "../../utils/dist/warning.js";
10
+ import { isFunction, isString } from "../../utils/dist/guard.js";
11
+ import { toArray } from "../../utils/dist/array.js";
12
+ function useMachine(machine, userProps = {}) {
13
+ const scope = computed(() => {
14
+ const { id, ids, getRootNode } = toValue(userProps);
15
+ return createScope({ id, ids, getRootNode });
16
+ });
17
+ const debug = (...args) => {
18
+ if (machine.debug) console.log(...args);
19
+ };
20
+ const props = computed(
21
+ () => machine.props?.({
22
+ props: compact(toValue(userProps)),
23
+ get scope() {
24
+ return scope.value;
25
+ }
26
+ }) ?? toValue(userProps)
27
+ );
28
+ const prop = useProp(props);
29
+ const context = machine.context?.({
30
+ prop,
31
+ bindable,
32
+ get scope() {
33
+ return scope.value;
34
+ },
35
+ flush,
36
+ getContext() {
37
+ return ctx;
38
+ },
39
+ getComputed() {
40
+ return computed$1;
41
+ },
42
+ getRefs() {
43
+ return refs;
44
+ },
45
+ getEvent() {
46
+ return getEvent();
47
+ }
48
+ });
49
+ const ctx = {
50
+ get(key) {
51
+ return context[key]?.get();
52
+ },
53
+ set(key, value) {
54
+ context[key]?.set(value);
55
+ },
56
+ initial(key) {
57
+ return context[key]?.initial;
58
+ },
59
+ hash(key) {
60
+ const current = context[key]?.get();
61
+ return context[key]?.hash(current);
62
+ }
63
+ };
64
+ let effects = /* @__PURE__ */ new Map();
65
+ let transitionRef = null;
66
+ let previousEventRef = { current: null };
67
+ let eventRef = { current: { type: "" } };
68
+ const getEvent = () => ({
69
+ ...eventRef.current,
70
+ current() {
71
+ return eventRef.current;
72
+ },
73
+ previous() {
74
+ return previousEventRef.current;
75
+ }
76
+ });
77
+ const getState = () => ({
78
+ ...state,
79
+ matches(...values) {
80
+ const currentState = state.get();
81
+ return values.some((value) => matchesState(currentState, value));
82
+ },
83
+ hasTag(tag) {
84
+ const currentState = state.get();
85
+ return hasTag(machine, currentState, tag);
86
+ }
87
+ });
88
+ const refs = useRefs(machine.refs?.({ prop, context: ctx }) ?? {});
89
+ const getParams = () => ({
90
+ state: getState(),
91
+ context: ctx,
92
+ event: getEvent(),
93
+ prop,
94
+ send,
95
+ action,
96
+ guard,
97
+ track: useTrack,
98
+ refs,
99
+ computed: computed$1,
100
+ flush,
101
+ get scope() {
102
+ return scope.value;
103
+ },
104
+ choose
105
+ });
106
+ const action = (keys) => {
107
+ const strs = isFunction(keys) ? keys(getParams()) : keys;
108
+ if (!strs) return;
109
+ const fns = strs.map((s) => {
110
+ const fn = machine.implementations?.actions?.[s];
111
+ if (!fn) warn(`[zag-js] No implementation found for action "${JSON.stringify(s)}"`);
112
+ return fn;
113
+ });
114
+ for (const fn of fns) {
115
+ fn?.(getParams());
116
+ }
117
+ };
118
+ const guard = (str) => {
119
+ if (isFunction(str)) return str(getParams());
120
+ return machine.implementations?.guards?.[str](getParams());
121
+ };
122
+ const effect = (keys) => {
123
+ const strs = isFunction(keys) ? keys(getParams()) : keys;
124
+ if (!strs) return;
125
+ const fns = strs.map((s) => {
126
+ const fn = machine.implementations?.effects?.[s];
127
+ if (!fn) warn(`[zag-js] No implementation found for effect "${JSON.stringify(s)}"`);
128
+ return fn;
129
+ });
130
+ const cleanups = [];
131
+ for (const fn of fns) {
132
+ const cleanup = fn?.(getParams());
133
+ if (cleanup) cleanups.push(cleanup);
134
+ }
135
+ return () => cleanups.forEach((fn) => fn?.());
136
+ };
137
+ const choose = (transitions) => {
138
+ return toArray(transitions).find((t) => {
139
+ let result = !t.guard;
140
+ if (isString(t.guard)) result = !!guard(t.guard);
141
+ else if (isFunction(t.guard)) result = t.guard(getParams());
142
+ return result;
143
+ });
144
+ };
145
+ const computed$1 = (key) => {
146
+ ensure(machine.computed, () => `[zag-js] No computed object found on machine`);
147
+ const fn = machine.computed[key];
148
+ return fn({
149
+ context: ctx,
150
+ event: getEvent(),
151
+ prop,
152
+ refs,
153
+ get scope() {
154
+ return scope.value;
155
+ },
156
+ computed: computed$1
157
+ });
158
+ };
159
+ const state = bindable(() => ({
160
+ defaultValue: resolveStateValue(machine, machine.initialState({ prop })),
161
+ onChange(nextState, prevState) {
162
+ const { exiting, entering } = getExitEnterStates(machine, prevState, nextState, transitionRef?.reenter);
163
+ exiting.forEach((item) => {
164
+ const exitEffects = effects.get(item.path);
165
+ exitEffects?.();
166
+ effects.delete(item.path);
167
+ });
168
+ exiting.forEach((item) => {
169
+ action(item.state?.exit);
170
+ });
171
+ action(transitionRef?.actions);
172
+ entering.forEach((item) => {
173
+ const cleanup = effect(item.state?.effects);
174
+ if (cleanup) effects.set(item.path, cleanup);
175
+ });
176
+ if (prevState === INIT_STATE) {
177
+ action(machine.entry);
178
+ const cleanup = effect(machine.effects);
179
+ if (cleanup) effects.set(INIT_STATE, cleanup);
180
+ }
181
+ entering.forEach((item) => {
182
+ action(item.state?.entry);
183
+ });
184
+ }
185
+ }));
186
+ let status = MachineStatus.NotStarted;
187
+ let pendingEvents = [];
188
+ onMounted(() => {
189
+ const started = status === MachineStatus.Started;
190
+ status = MachineStatus.Started;
191
+ debug(started ? "rehydrating..." : "initializing...");
192
+ state.invoke(state.initial, INIT_STATE);
193
+ const events = pendingEvents;
194
+ pendingEvents = [];
195
+ for (const event of events) {
196
+ send(event);
197
+ }
198
+ });
199
+ onBeforeUnmount(() => {
200
+ status = MachineStatus.Stopped;
201
+ pendingEvents = [];
202
+ debug("unmounting...");
203
+ const fns = effects.values();
204
+ for (const fn of fns) fn?.();
205
+ effects = /* @__PURE__ */ new Map();
206
+ action(machine.exit);
207
+ });
208
+ const send = (event) => {
209
+ if (status !== MachineStatus.Started) {
210
+ pendingEvents.push(event);
211
+ return;
212
+ }
213
+ previousEventRef.current = eventRef.current;
214
+ eventRef.current = event;
215
+ let currentState = state.get();
216
+ const { transitions, source } = findTransition(machine, currentState, event.type);
217
+ const transition = choose(transitions);
218
+ if (!transition) return;
219
+ transitionRef = transition;
220
+ const target = resolveStateValue(machine, transition.target ?? currentState, source);
221
+ debug("transition", event.type, transition.target || currentState, `(${transition.actions})`);
222
+ const changed = target !== currentState;
223
+ if (changed) {
224
+ state.set(target);
225
+ } else if (transition.reenter) {
226
+ state.invoke(currentState, currentState);
227
+ } else {
228
+ action(transition.actions);
229
+ }
230
+ };
231
+ machine.watch?.(getParams());
232
+ return {
233
+ state: getState(),
234
+ send,
235
+ context: ctx,
236
+ prop,
237
+ get scope() {
238
+ return scope.value;
239
+ },
240
+ refs,
241
+ computed: computed$1,
242
+ event: getEvent(),
243
+ getStatus: () => status
244
+ };
245
+ }
246
+ function useProp(valueRef) {
247
+ return function get(key) {
248
+ return valueRef.value[key];
249
+ };
250
+ }
251
+ var flush = (fn) => {
252
+ nextTick().then(() => {
253
+ fn();
254
+ });
255
+ };
256
+ export {
257
+ useMachine
258
+ };
@@ -0,0 +1,42 @@
1
+ import { createNormalizer } from "../../types/dist/prop-types.js";
2
+ function toCase(txt) {
3
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
4
+ }
5
+ var propMap = {
6
+ htmlFor: "for",
7
+ className: "class",
8
+ onDoubleClick: "onDblclick",
9
+ onChange: "onInput",
10
+ onFocus: "onFocusin",
11
+ onBlur: "onFocusout",
12
+ defaultValue: "value",
13
+ defaultChecked: "checked"
14
+ };
15
+ var preserveKeys = "viewBox,className,preserveAspectRatio,fillRule,clipPath,clipRule,strokeWidth,strokeLinecap,strokeLinejoin,strokeDasharray,strokeDashoffset,strokeMiterlimit".split(
16
+ ","
17
+ );
18
+ function toVueProp(prop) {
19
+ if (prop in propMap) return propMap[prop];
20
+ if (prop.startsWith("on")) return `on${toCase(prop.substr(2))}`;
21
+ if (preserveKeys.includes(prop)) return prop;
22
+ return prop.toLowerCase();
23
+ }
24
+ var normalizeProps = createNormalizer((props) => {
25
+ const normalized = {};
26
+ for (const key in props) {
27
+ const value = props[key];
28
+ if (key === "children") {
29
+ if (typeof value === "string") {
30
+ normalized["innerHTML"] = value;
31
+ } else if (process.env.NODE_ENV !== "production" && value != null) {
32
+ console.warn("[Vue Normalize Prop] : avoid passing non-primitive value as `children`");
33
+ }
34
+ } else {
35
+ normalized[toVueProp(key)] = props[key];
36
+ }
37
+ }
38
+ return normalized;
39
+ });
40
+ export {
41
+ normalizeProps
42
+ };
@@ -0,0 +1,14 @@
1
+ function useRefs(refs) {
2
+ const ref = { current: refs };
3
+ return {
4
+ get(key) {
5
+ return ref.current[key];
6
+ },
7
+ set(key, value) {
8
+ ref.current[key] = value;
9
+ }
10
+ };
11
+ }
12
+ export {
13
+ useRefs
14
+ };
@@ -0,0 +1,22 @@
1
+ import { watch, toValue } from "vue";
2
+ import { isEqual } from "../../utils/dist/equal.js";
3
+ var useTrack = (deps, effect) => {
4
+ watch(
5
+ () => [...deps.map((d) => d())],
6
+ (current, previous) => {
7
+ let changed = false;
8
+ for (let i = 0; i < current.length; i++) {
9
+ if (!isEqual(previous[i], toValue(current[i]))) {
10
+ changed = true;
11
+ break;
12
+ }
13
+ }
14
+ if (changed) {
15
+ effect();
16
+ }
17
+ }
18
+ );
19
+ };
20
+ export {
21
+ useTrack
22
+ };