@joystick.js/ui-canary 0.0.0-canary.27 → 0.0.0-canary.271

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 (231) hide show
  1. package/build.js +15 -0
  2. package/dist/index.js +20 -20
  3. package/increment_version.js +3 -0
  4. package/index.html +7 -0
  5. package/package.json +9 -13
  6. package/src/accounts/authenticated.js +8 -0
  7. package/src/accounts/index.js +21 -0
  8. package/src/accounts/login.js +7 -0
  9. package/src/accounts/logout.js +8 -0
  10. package/src/accounts/recover_password.js +7 -0
  11. package/src/accounts/request.js +70 -0
  12. package/src/accounts/reset_password.js +7 -0
  13. package/src/accounts/signup.js +7 -0
  14. package/src/accounts/user.js +8 -0
  15. package/src/api/get.js +73 -0
  16. package/src/api/index.js +10 -0
  17. package/src/api/set.js +83 -0
  18. package/src/attach_joystick_to_window.js +31 -0
  19. package/src/cache/class.js +98 -0
  20. package/src/cache/index.js +5 -0
  21. package/src/component/class.js +360 -0
  22. package/src/component/css/compile.js +108 -0
  23. package/src/component/data/compile.js +44 -0
  24. package/src/component/data/fetch.js +12 -0
  25. package/src/component/data/load_data_from_window.js +14 -0
  26. package/src/component/dom/is_valid_attribute_name.js +11 -0
  27. package/src/component/events/attach_event_listener_for_element.js +32 -0
  28. package/src/component/events/serialize.js +12 -0
  29. package/src/component/index.js +17 -0
  30. package/src/component/methods/compile.js +28 -0
  31. package/src/component/props/compile.js +21 -0
  32. package/src/component/props/compile_default.js +21 -0
  33. package/src/component/register_component_options.js +44 -0
  34. package/src/component/render_methods/component.js +53 -0
  35. package/src/component/render_methods/component_ssr.js +22 -0
  36. package/src/component/render_methods/each.js +19 -0
  37. package/src/component/render_methods/i18n.js +50 -0
  38. package/src/component/render_methods/index.js +19 -0
  39. package/src/component/render_methods/when.js +20 -0
  40. package/src/component/state/compile.js +21 -0
  41. package/src/component/url/compile.js +39 -0
  42. package/src/component/validate_component_options/has_required_options.js +9 -0
  43. package/src/component/validate_component_options/index.js +16 -0
  44. package/src/component/validate_component_options/required_options.js +5 -0
  45. package/src/component/virtual_dom/diff.js +61 -0
  46. package/src/component/virtual_dom/diff_attributes.js +37 -0
  47. package/src/component/virtual_dom/diff_children.js +74 -0
  48. package/src/component/virtual_dom/element_patch_functions.js +31 -0
  49. package/src/component/virtual_dom/map_patch_functions_to_nodes.js +14 -0
  50. package/src/component/virtual_dom/render_virtual_dom_to_dom.js +37 -0
  51. package/src/external/get.js +9 -0
  52. package/src/external/track.js +10 -0
  53. package/src/forms/validate.js +306 -0
  54. package/src/forms/validators/credit_card.js +19 -0
  55. package/src/forms/validators/custom.js +5 -0
  56. package/src/forms/validators/email.js +12 -0
  57. package/src/forms/validators/equals.js +5 -0
  58. package/src/forms/validators/index.js +43 -0
  59. package/src/forms/validators/matches.js +5 -0
  60. package/src/forms/validators/max_length.js +5 -0
  61. package/src/forms/validators/min_length.js +5 -0
  62. package/src/forms/validators/phone.js +14 -0
  63. package/src/forms/validators/postal_code.js +204 -0
  64. package/src/forms/validators/regex.js +5 -0
  65. package/src/forms/validators/required.js +13 -0
  66. package/src/forms/validators/semver.js +14 -0
  67. package/src/forms/validators/slug.js +12 -0
  68. package/src/forms/validators/strong_password.js +12 -0
  69. package/src/forms/validators/url.js +12 -0
  70. package/src/forms/validators/vat.js +54 -0
  71. package/src/index.js +55 -0
  72. package/src/lib/constants.js +13 -0
  73. package/src/lib/debounce.js +9 -0
  74. package/src/lib/generate_cookie_header.js +7 -0
  75. package/src/lib/generate_id.js +15 -0
  76. package/src/lib/get_joystick_environment.js +13 -0
  77. package/src/lib/log_request_errors.js +15 -0
  78. package/src/lib/nested_object_diff.js +164 -0
  79. package/src/lib/parse_json.js +12 -0
  80. package/src/lib/throw_framework_error.js +5 -0
  81. package/src/lib/types.js +59 -0
  82. package/src/mount/index.js +45 -0
  83. package/src/test/create_file.js +10 -0
  84. package/src/test/index.js +13 -0
  85. package/src/test/track_function_call.js +16 -0
  86. package/src/tree/add_node_to_tree.js +6 -0
  87. package/src/tree/clean_up.js +11 -0
  88. package/src/tree/get_child_instance_ids.js +7 -0
  89. package/src/tree/get_children_from_tree.js +25 -0
  90. package/src/tree/get_css_from_tree.js +43 -0
  91. package/src/tree/get_event_listeners_for_nodes.js +15 -0
  92. package/src/tree/get_node_from_tree.js +7 -0
  93. package/src/tree/get_parent_from_tree.js +8 -0
  94. package/src/tree/jobs/index.js +210 -0
  95. package/src/tree/jobs/run.js +11 -0
  96. package/src/tree/replace_child_in_vdom.js +18 -0
  97. package/src/upload/index.js +72 -0
  98. package/src/websockets/client.js +125 -0
  99. package/src/websockets/register_on_component.js +27 -0
  100. package/test.js +145 -0
  101. package/README.md +0 -8
  102. package/_package.json +0 -26
  103. package/canary.js +0 -12
  104. package/dist/accounts/authenticated.js +0 -1
  105. package/dist/accounts/index.js +0 -1
  106. package/dist/accounts/login.js +0 -1
  107. package/dist/accounts/logout.js +0 -1
  108. package/dist/accounts/recoverPassword.js +0 -1
  109. package/dist/accounts/request.js +0 -1
  110. package/dist/accounts/resetPassword.js +0 -1
  111. package/dist/accounts/signup.js +0 -1
  112. package/dist/accounts/user.js +0 -1
  113. package/dist/api/get.js +0 -1
  114. package/dist/api/index.js +0 -1
  115. package/dist/api/set.js +0 -1
  116. package/dist/attachJoystickToWindow.js +0 -1
  117. package/dist/cache/class.js +0 -1
  118. package/dist/cache/index.js +0 -1
  119. package/dist/component/class/css/compile.js +0 -21
  120. package/dist/component/class/css/prefix.js +0 -1
  121. package/dist/component/class/data/compile.js +0 -1
  122. package/dist/component/class/data/fetch.js +0 -1
  123. package/dist/component/class/data/findComponentDataFromSSR.js +0 -1
  124. package/dist/component/class/data/loadDataFromWindow.js +0 -1
  125. package/dist/component/class/events/_registerListeners.js +0 -1
  126. package/dist/component/class/events/_unregisterListeners.js +0 -1
  127. package/dist/component/class/events/registerListeners.js +0 -1
  128. package/dist/component/class/events/serialize.js +0 -1
  129. package/dist/component/class/events/unregisterListeners.js +0 -1
  130. package/dist/component/class/index.js +0 -21
  131. package/dist/component/class/lifecycle/compile.js +0 -1
  132. package/dist/component/class/methods/compile.js +0 -1
  133. package/dist/component/class/options/allowedComponentOptions.js +0 -1
  134. package/dist/component/class/options/allowedDOMEvents.js +0 -1
  135. package/dist/component/class/options/allowedLifecycleMethods.js +0 -1
  136. package/dist/component/class/options/defaultLifecycleMethods.js +0 -1
  137. package/dist/component/class/options/hasAllRequiredOptions.js +0 -1
  138. package/dist/component/class/options/registerOptions.js +0 -21
  139. package/dist/component/class/options/requiredOptions.js +0 -1
  140. package/dist/component/class/options/validateOptions.js +0 -1
  141. package/dist/component/class/options/validators/css.js +0 -1
  142. package/dist/component/class/options/validators/events.js +0 -1
  143. package/dist/component/class/options/validators/index.js +0 -1
  144. package/dist/component/class/options/validators/lifecycle.js +0 -1
  145. package/dist/component/class/options/validators/methods.js +0 -1
  146. package/dist/component/class/options/validators/name.js +0 -1
  147. package/dist/component/class/options/validators/render.js +0 -1
  148. package/dist/component/class/options/validators/websockets.js +0 -1
  149. package/dist/component/class/options/validators/wrapper.js +0 -1
  150. package/dist/component/class/props/compile.js +0 -1
  151. package/dist/component/class/props/compileDefault.js +0 -1
  152. package/dist/component/class/render/clearTimersOnChildren.js +0 -1
  153. package/dist/component/class/render/forMount.js +0 -1
  154. package/dist/component/class/render/getExistingPropsMap.js +0 -1
  155. package/dist/component/class/render/getExistingStateMap.js +0 -1
  156. package/dist/component/class/render/getUpdatedDOM.js +0 -1
  157. package/dist/component/class/render/sanitizeHTML.js +0 -1
  158. package/dist/component/class/render/toHTML.js +0 -1
  159. package/dist/component/class/render/wrapHTML.js +0 -1
  160. package/dist/component/class/renderMethods/compile.js +0 -1
  161. package/dist/component/class/renderMethods/component.js +0 -1
  162. package/dist/component/class/renderMethods/dragDrop/attachEventListeners.js +0 -1
  163. package/dist/component/class/renderMethods/dragDrop/concept.js +0 -0
  164. package/dist/component/class/renderMethods/dragDrop/draggable.js +0 -1
  165. package/dist/component/class/renderMethods/dragDrop/droppable.js +0 -1
  166. package/dist/component/class/renderMethods/dragDrop/index.js +0 -1
  167. package/dist/component/class/renderMethods/dragDrop/isBefore.js +0 -1
  168. package/dist/component/class/renderMethods/each.js +0 -1
  169. package/dist/component/class/renderMethods/i18n.js +0 -1
  170. package/dist/component/class/renderMethods/index.js +0 -1
  171. package/dist/component/class/renderMethods/when.js +0 -1
  172. package/dist/component/class/state/compile.js +0 -1
  173. package/dist/component/class/url/compile.js +0 -1
  174. package/dist/component/class/virtualDOM/build.js +0 -1
  175. package/dist/component/class/virtualDOM/buildTree.js +0 -1
  176. package/dist/component/class/virtualDOM/diff/attributes.js +0 -1
  177. package/dist/component/class/virtualDOM/diff/children.js +0 -1
  178. package/dist/component/class/virtualDOM/diff/elementPatchFunctions.js +0 -1
  179. package/dist/component/class/virtualDOM/diff/index.js +0 -1
  180. package/dist/component/class/virtualDOM/diff/mapPatchFunctionsToNodes.js +0 -1
  181. package/dist/component/class/virtualDOM/renderTreeToDOM.js +0 -1
  182. package/dist/component/index.js +0 -21
  183. package/dist/component/renderComponentToHTML.js +0 -1
  184. package/dist/component/tree/addChildToParent.js +0 -1
  185. package/dist/component/tree/clearChildrenOnParent.js +0 -1
  186. package/dist/component/tree/findComponentInTreeByField.js +0 -1
  187. package/dist/component/tree/replaceChildInVDOMTree.js +0 -1
  188. package/dist/component/tree/updateParentInstanceInTree.js +0 -1
  189. package/dist/css/getCSSFromTree.js +0 -21
  190. package/dist/css/update.js +0 -21
  191. package/dist/forms/validate.js +0 -1
  192. package/dist/forms/validators/creditCard.js +0 -1
  193. package/dist/forms/validators/email.js +0 -1
  194. package/dist/forms/validators/equals.js +0 -1
  195. package/dist/forms/validators/index.js +0 -1
  196. package/dist/forms/validators/matches.js +0 -1
  197. package/dist/forms/validators/maxLength.js +0 -1
  198. package/dist/forms/validators/minLength.js +0 -1
  199. package/dist/forms/validators/phone.js +0 -1
  200. package/dist/forms/validators/postalCode.js +0 -1
  201. package/dist/forms/validators/required.js +0 -1
  202. package/dist/forms/validators/semVer.js +0 -1
  203. package/dist/forms/validators/slug.js +0 -1
  204. package/dist/forms/validators/strongPassword.js +0 -1
  205. package/dist/forms/validators/types.js +0 -1
  206. package/dist/forms/validators/url.js +0 -1
  207. package/dist/forms/validators/vat.js +0 -1
  208. package/dist/html/index.js +0 -1
  209. package/dist/lib/addToQueue.js +0 -1
  210. package/dist/lib/assignOptionsToInstance.js +0 -1
  211. package/dist/lib/constants.js +0 -1
  212. package/dist/lib/debounce.js +0 -1
  213. package/dist/lib/generateId.js +0 -1
  214. package/dist/lib/isNode.js +0 -1
  215. package/dist/lib/isValidAttributeName.js +0 -1
  216. package/dist/lib/logRequestErrors.js +0 -1
  217. package/dist/lib/parseJSON.js +0 -1
  218. package/dist/lib/processQueue.js +0 -1
  219. package/dist/lib/queueArray.js +0 -1
  220. package/dist/lib/serializeEvents.js +0 -1
  221. package/dist/lib/stringContainsHTML.js +0 -1
  222. package/dist/lib/throttle.js +0 -1
  223. package/dist/lib/throwFrameworkError.js +0 -1
  224. package/dist/lib/types.js +0 -1
  225. package/dist/lib/windowIsUndefined.js +0 -1
  226. package/dist/mount/appendToTarget.js +0 -1
  227. package/dist/mount/index.js +0 -1
  228. package/dist/mount/initializeJoystickComponentTree.js +0 -1
  229. package/dist/overrideTimers.js +0 -1
  230. package/dist/upload/index.js +0 -1
  231. package/dist/websockets/client.js +0 -1
@@ -0,0 +1,125 @@
1
+ import generate_id from "../lib/generate_id.js";
2
+ import track_function_call from "../test/track_function_call.js";
3
+
4
+ let reconnect_interval = null;
5
+ let reconnect_attempts = 0;
6
+
7
+ const websocket_client = (options = {}, on_connect = null) => {
8
+ if (window?.__joystick_test__) {
9
+ // NOTE: Skip connection in test environment and fire the on_connect callback.
10
+ return on_connect();
11
+ }
12
+
13
+ let url = options?.url;
14
+
15
+ if (options?.query) {
16
+ url = `${url}?${new URLSearchParams(options.query).toString()}`;
17
+ }
18
+
19
+ let client = new WebSocket(url);
20
+
21
+ if (reconnect_interval) {
22
+ clearInterval(reconnect_interval);
23
+ reconnect_interval = null;
24
+ }
25
+
26
+ const connection = {
27
+ _id: generate_id(8),
28
+ client,
29
+ send: (message = {}) => {
30
+ track_function_call(`ui.${options?.test?.name || generate_id(16)}.websockets.send`, [
31
+ message
32
+ ]);
33
+
34
+ return client.send(JSON.stringify(message));
35
+ },
36
+ };
37
+
38
+ client.addEventListener("open", () => {
39
+ if (options?.options?.logging) {
40
+ console.log(`[joystick.websockets] Connected to ${options?.url}`);
41
+ }
42
+
43
+ if (options?.events?.onOpen || options?.events?.on_open) {
44
+ (options.events.onOpen || options.events.on_open)(connection);
45
+ track_function_call(`ui.websockets.${options?.test?.name || generate_id()}.on_open`, [
46
+ connection
47
+ ]);
48
+ }
49
+
50
+ reconnect_attempts = 0;
51
+ });
52
+
53
+ client.addEventListener("message", (event) => {
54
+ if (event?.data && (options?.events?.onMessage || options?.events?.on_message)) {
55
+ (options.events.onMessage || options.events.on_message)(JSON.parse(event.data || {}), connection);
56
+ track_function_call(`ui.websockets.${options?.test?.name || generate_id()}.on_message`, [
57
+ event.data || {},
58
+ connection
59
+ ]);
60
+ }
61
+ });
62
+
63
+ client.addEventListener("close", (event) => {
64
+ if (options?.options?.logging) {
65
+ console.log(`[joystick.websockets] Disconnected from ${options?.url}`);
66
+ }
67
+
68
+ if (options?.events?.onClose || options?.events?.on_close) {
69
+ (options.events.onClose || options.events.on_close)(event?.code, event?.reason, connection);
70
+ track_function_call(`ui.websockets.${options?.test?.name || generate_id()}.on_close`, [
71
+ event.data || {},
72
+ connection
73
+ ]);
74
+ }
75
+
76
+ client = null;
77
+
78
+ // NOTE: An intentional close refers to a close that was initiated by the user (refresh),
79
+ // or, a close that was terminated purposefully by the server. An unintentional close
80
+ // would be a server going down/restarting or not responding properly.
81
+ const was_intentional_close = [1000, 1001]?.includes(event?.code);
82
+
83
+ if (window.joystick._internal.websockets) {
84
+ window.joystick._internal.websockets = window.joystick._internal.websockets?.filter((existing_websocket) => {
85
+ return existing_websocket?._id !== connection?._id;
86
+ });
87
+ }
88
+
89
+ if ((options?.options?.autoReconnect || options?.options?.auto_reconnect) && !reconnect_interval && !was_intentional_close) {
90
+ reconnect_interval = setInterval(() => {
91
+ client = null;
92
+
93
+ // NOTE: 12 attempts === try to reconnect for up to 1 minute (12 * 5 seconds between each attempt).
94
+ if (reconnect_attempts < (options?.options?.reconnectAttempts || options?.options?.reconnect_attempts || 12)) {
95
+ websocket_client(options, on_connect);
96
+
97
+ if (options?.options?.logging) {
98
+ console.log(
99
+ `[joystick.websockets] Attempting to reconnect (${
100
+ reconnect_attempts + 1
101
+ }/12)...`
102
+ );
103
+ }
104
+
105
+ reconnect_attempts += 1;
106
+ } else {
107
+ clearInterval(reconnect_interval);
108
+ }
109
+ }, (((options?.options?.reconnectDelayInSeconds || options?.options?.reconnect_delay_in_seconds) * 1000) || 5000));
110
+ }
111
+ });
112
+
113
+ if (on_connect) on_connect(connection);
114
+
115
+ if (window.joystick?._internal) {
116
+ window.joystick._internal.websockets = [
117
+ ...(window.joystick._internal.websockets || []),
118
+ connection,
119
+ ];
120
+ }
121
+
122
+ return connection;
123
+ };
124
+
125
+ export default websocket_client;
@@ -0,0 +1,27 @@
1
+ import types from "../lib/types.js";
2
+ import websocket_client from './client.js';
3
+
4
+ const register_on_component = (component_options = {}, component_instance = {}) => {
5
+ const compiled_websockets_option = types.is_function(component_options.websockets) && component_options.websockets(component_instance);
6
+ const websocket_definitions = types.is_object(compiled_websockets_option) && Object.entries(compiled_websockets_option);
7
+
8
+ for (let i = 0; i < websocket_definitions?.length; i += 1) {
9
+ const [websocket_name, websocket_definition] = websocket_definitions[i];
10
+
11
+ websocket_client({
12
+ component_instance,
13
+ test: component_instance?.test,
14
+ url: `${window?.process?.env.NODE_ENV === 'development' ? 'ws' : 'wss'}://${location.host}/api/_websockets/${websocket_name}`,
15
+ options: websocket_definition?.options || {},
16
+ query: websocket_definition?.query || {},
17
+ events: websocket_definition?.events || {},
18
+ }, (websocket_connection = {}) => {
19
+ component_instance.websockets = {
20
+ ...(component_instance.websockets || {}),
21
+ [websocket_name]: websocket_connection,
22
+ }
23
+ });
24
+ }
25
+ };
26
+
27
+ export default register_on_component;
package/test.js ADDED
@@ -0,0 +1,145 @@
1
+ document.addEventListener("DOMContentLoaded", function(event) {
2
+ const Child = joystick.component({
3
+ _componentId: 'child_component',
4
+ state: {
5
+ name: 'Kara',
6
+ },
7
+ methods: {
8
+ testing: (instance = {}) => {
9
+ console.log('TESTING METHOD', instance);
10
+ },
11
+ },
12
+ lifecycle: {
13
+ onBeforeMount: () => {
14
+ // console.log('ON B4 MAWNT');
15
+ },
16
+ onMount: (instance = {}) => {
17
+ },
18
+ onRender: (instance = {}) => {
19
+ // instance.setInterval(() => {
20
+ // console.log('TICK CHILD');
21
+ // }, 1000);
22
+ },
23
+ onUpdateProps: () => {
24
+ // console.log('ON UPDATE PROPS');
25
+ },
26
+ onBeforeUnmount: () => {
27
+ // localStorage.setItem('blammo', 'unmount my nigga');
28
+ },
29
+ },
30
+ events: {
31
+ 'submit form': (event, instance) => {
32
+ event.preventDefault();
33
+ instance.validateForm(event.target, {
34
+ rules: {
35
+ bingo: {
36
+ required: true,
37
+ },
38
+ },
39
+ messages: {
40
+ bingo: {
41
+ required: 'was his name oh',
42
+ }
43
+ }
44
+ }).then(() => {
45
+ console.log('butta');
46
+ })
47
+ },
48
+ 'click .child': (event, instance) => {
49
+ instance.setState({
50
+ name: instance?.state?.name === 'Ryan' ? 'Kara' : 'Ryan',
51
+ })
52
+ },
53
+ },
54
+ css: {
55
+ min: {
56
+ width: {
57
+ 0: `
58
+ @wrapper.ponies {
59
+ display: block;
60
+ background: #0099ff;
61
+ }
62
+
63
+ .child {
64
+ color: purple;
65
+ }
66
+ `,
67
+ 768: `
68
+ .child {
69
+ color: orange;
70
+ }
71
+ `,
72
+ }
73
+ }
74
+ },
75
+ wrapper: {
76
+ id: 'the-thing',
77
+ tagName: 'a',
78
+ classList: ['ponies', 'doggies', 'zebras'],
79
+ },
80
+ render: ({ state, props }) => {
81
+ return `
82
+ <div class="child" style="margin-left: 30px;">
83
+ <p>I'm a child ${state?.name} ${props?.hotdog}</p>
84
+ <form>
85
+ <input type="text" placeholder="bingo dingo" name="bingo" />
86
+ <button type="submit">DO IT TO IT LARS</button>
87
+ </form>
88
+ </div>
89
+ `;
90
+ },
91
+ });
92
+
93
+ const Test = joystick.component({
94
+ _componentId: 'test_parent',
95
+ state: {
96
+ name: 'Ryan',
97
+ },
98
+ lifecycle: {
99
+ onMount: (instance = {}) => {
100
+ },
101
+ onBeforeRender: (instance = {}) => {
102
+ // console.log('KARAAAAAAAAAAA');
103
+ },
104
+ onRender: (instance = {}) => {
105
+ // instance.setInterval(() => {
106
+ // instance.setState({
107
+ // name: instance?.state?.name === 'Ryan' ? 'Kara' : 'Ryan',
108
+ // })
109
+ // }, 500);
110
+ },
111
+ onBeforeUnmount: () => {
112
+ // localStorage.setItem('unmounted', true);
113
+ // console.log("UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT UNMOUNT")
114
+ },
115
+ },
116
+ events: {
117
+ 'click .testing': (event, instance) => {
118
+ instance.setState({
119
+ name: instance?.state?.name === 'Ryan' ? 'Kara' : 'Ryan',
120
+ })
121
+ },
122
+ },
123
+ css: {
124
+ min: {
125
+ width: {
126
+ 0: `
127
+ .testing {
128
+ font-size: 48px;
129
+ }
130
+ `,
131
+ }
132
+ }
133
+ },
134
+ render: ({ component, state }) => {
135
+ return `
136
+ <div>
137
+ <p class="testing">Testing ${state?.name}</p>
138
+ ${component(Child, { hotdog: state.name })}
139
+ </div>
140
+ `;
141
+ },
142
+ });
143
+
144
+ joystick.mount(Test, {}, document.getElementById('app'));
145
+ });
package/README.md DELETED
@@ -1,8 +0,0 @@
1
- <br />
2
- <img style="width: 200px;" src="https://cheatcode-assets.s3.amazonaws.com/logo-transparent.png" alt="CheatCode">
3
-
4
- ## @joystick.js/ui (Beta)
5
-
6
- A JavaScript framework for building user interfaces.
7
-
8
- [Read the Documentation](https://github.com/cheatcode/joystick)
package/_package.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "name": "@joystick.js/ui",
3
- "type": "module",
4
- "version": "1.0.0-beta.86",
5
- "developmentVersion": "1.0.0-beta.3438",
6
- "description": "A JavaScript framework for building user interfaces.",
7
- "main": "./dist/index.js",
8
- "scripts": {
9
- "build": "node .build/index.js",
10
- "canary:release": "export NODE_ENV=development && npm run build && node canary.js",
11
- "production:release": "export NODE_ENV=production && npm run build && node release.js",
12
- "win:development:release": "SET NODE_ENV=development&& npm run build && node release.js",
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- },
15
- "keywords": [],
16
- "author": "",
17
- "license": "SAUCR",
18
- "dependencies": {
19
- "lodash": "^4.17.21",
20
- "nested-object-diff": "^1.1.0"
21
- },
22
- "devDependencies": {
23
- "esbuild": "^0.13.15",
24
- "semver": "^7.3.5"
25
- }
26
- }
package/canary.js DELETED
@@ -1,12 +0,0 @@
1
- import fs from 'fs';
2
- import child_process from 'child_process';
3
-
4
- fs.renameSync('package.json', '_package.json');
5
- fs.renameSync('canary.json', 'package.json');
6
-
7
- child_process.execSync('npm version prerelease --preid=canary');
8
-
9
- child_process.execSync('npm publish --access=public');
10
-
11
- fs.renameSync('package.json', 'canary.json');
12
- fs.renameSync('_package.json', 'package.json');
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var c=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(r,e)}};var p=async(r={})=>{try{let t=await r.text();return u(t)}catch(t){o("accounts.request.handleParseResponse",t)}},w=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(e){o("accounts.request.getBody",e)}},m=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},h=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((e,n)=>{let d=`${window.location.origin}/api/_accounts/${r}`,i=m(r),l=w(i,t);return fetch(d,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:l,credentials:"include"}).then(async s=>{let a=await p(s);return a?.errors?(c(`accounts.${r}`,a.errors),n(a)):e(a)}).catch(s=>(c(`accounts.${r}`,[s]),n({errors:[s]})))})}catch(e){o(`accounts.request.${r}`,e)}};var O=async(r={})=>{try{let t=await h("authenticated",r);return t?.status===200&&t?.authenticated}catch(t){o("accounts.authenticated",t)}};export{O as default};
@@ -1 +0,0 @@
1
- var m=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var n=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(s=>{console.log(s.message),s.stack&&console.log(s.stack)})}catch(s){o(r,s)}};var E=async(r={})=>{try{let t=await r.text();return m(t)}catch(t){o("accounts.request.handleParseResponse",t)}},q=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(s){o("accounts.request.getBody",s)}},k=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},e=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((s,u)=>{let y=`${window.location.origin}/api/_accounts/${r}`,i=k(r),x=q(i,t);return fetch(y,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:x,credentials:"include"}).then(async a=>{let c=await E(a);return c?.errors?(n(`accounts.${r}`,c.errors),u(c)):s(c)}).catch(a=>(n(`accounts.${r}`,[a]),u({errors:[a]})))})}catch(s){o(`accounts.request.${r}`,s)}};var p=async(r={})=>{try{let t=await e("authenticated",r);return t?.status===200&&t?.authenticated}catch(t){o("accounts.authenticated",t)}};var w=(r={})=>{try{return e("login",r)}catch(t){o("accounts.login",t)}};var h=()=>{try{return e("logout")}catch(r){o("accounts.logout",r)}};var l=(r={})=>{try{return e("recover-password",r)}catch(t){o("accounts.recoverPassword",t)}};var d=(r={})=>{try{return e("reset-password",r)}catch(t){o("accounts.resetPassword",t)}};var f=(r={})=>{try{return e("signup",r)}catch(t){o("accounts.signup",t)}};var g=async(r={})=>{try{let t=await e("user",r);return t?.status===200&&t?.user}catch(t){o("accounts.user",t)}};var ar={authenticated:p,login:w,logout:h,recoverPassword:l,resetPassword:d,signup:f,user:g};export{ar as default};
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var n=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(r,e)}};var p=async(r={})=>{try{let t=await r.text();return u(t)}catch(t){o("accounts.request.handleParseResponse",t)}},m=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(e){o("accounts.request.getBody",e)}},w=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},l=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((e,a)=>{let h=`${window.location.origin}/api/_accounts/${r}`,i=w(r),d=m(i,t);return fetch(h,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:d,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(n(`accounts.${r}`,c.errors),a(c)):e(c)}).catch(s=>(n(`accounts.${r}`,[s]),a({errors:[s]})))})}catch(e){o(`accounts.request.${r}`,e)}};var O=(r={})=>{try{return l("login",r)}catch(t){o("accounts.login",t)}};export{O as default};
@@ -1 +0,0 @@
1
- var i=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var n=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(r,e)}};var p=async(r={})=>{try{let t=await r.text();return i(t)}catch(t){o("accounts.request.handleParseResponse",t)}},m=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(e){o("accounts.request.getBody",e)}},w=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},l=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((e,a)=>{let h=`${window.location.origin}/api/_accounts/${r}`,u=w(r),d=m(u,t);return fetch(h,{method:u,mode:"cors",headers:{"Content-Type":"application/json"},body:d,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(n(`accounts.${r}`,c.errors),a(c)):e(c)}).catch(s=>(n(`accounts.${r}`,[s]),a({errors:[s]})))})}catch(e){o(`accounts.request.${r}`,e)}};var O=()=>{try{return l("logout")}catch(r){o("accounts.logout",r)}};export{O as default};
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",e={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${e.message||e.reason||e}`)};var a=(r="",e=[])=>{try{console.error(`${r} failed with the following errors:`),e.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){o(r,t)}};var p=async(r={})=>{try{let e=await r.text();return u(e)}catch(e){o("accounts.request.handleParseResponse",e)}},w=(r="GET",e={})=>{try{return["POST"].includes(r)?JSON.stringify({...e,origin:window?.location?.origin}):null}catch(t){o("accounts.request.getBody",t)}},m=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(e){o("accounts.request.getHTTPMethod",e)}},d=(r="",e={})=>{try{if(typeof window.fetch!="undefined")return new Promise((t,n)=>{let h=`${window.location.origin}/api/_accounts/${r}`,i=m(r),l=w(i,e);return fetch(h,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:l,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(a(`accounts.${r}`,c.errors),n(c)):t(c)}).catch(s=>(a(`accounts.${r}`,[s]),n({errors:[s]})))})}catch(t){o(`accounts.request.${r}`,t)}};var O=(r={})=>{try{return d("recover-password",r)}catch(e){o("accounts.recoverPassword",e)}};export{O as default};
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",e={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${e.message||e.reason||e}`)};var n=(r="",e=[])=>{try{console.error(`${r} failed with the following errors:`),e.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){o(r,t)}};var l=async(r={})=>{try{let e=await r.text();return u(e)}catch(e){o("accounts.request.handleParseResponse",e)}},p=(r="GET",e={})=>{try{return["POST"].includes(r)?JSON.stringify({...e,origin:window?.location?.origin}):null}catch(t){o("accounts.request.getBody",t)}},w=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(e){o("accounts.request.getHTTPMethod",e)}},$=(r="",e={})=>{try{if(typeof window.fetch!="undefined")return new Promise((t,a)=>{let d=`${window.location.origin}/api/_accounts/${r}`,i=w(r),h=p(i,e);return fetch(d,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:h,credentials:"include"}).then(async s=>{let c=await l(s);return c?.errors?(n(`accounts.${r}`,c.errors),a(c)):t(c)}).catch(s=>(n(`accounts.${r}`,[s]),a({errors:[s]})))})}catch(t){o(`accounts.request.${r}`,t)}};export{$ as default};
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",e={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${e.message||e.reason||e}`)};var a=(r="",e=[])=>{try{console.error(`${r} failed with the following errors:`),e.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){o(r,t)}};var p=async(r={})=>{try{let e=await r.text();return u(e)}catch(e){o("accounts.request.handleParseResponse",e)}},w=(r="GET",e={})=>{try{return["POST"].includes(r)?JSON.stringify({...e,origin:window?.location?.origin}):null}catch(t){o("accounts.request.getBody",t)}},m=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(e){o("accounts.request.getHTTPMethod",e)}},d=(r="",e={})=>{try{if(typeof window.fetch!="undefined")return new Promise((t,n)=>{let h=`${window.location.origin}/api/_accounts/${r}`,i=m(r),l=w(i,e);return fetch(h,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:l,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(a(`accounts.${r}`,c.errors),n(c)):t(c)}).catch(s=>(a(`accounts.${r}`,[s]),n({errors:[s]})))})}catch(t){o(`accounts.request.${r}`,t)}};var O=(r={})=>{try{return d("reset-password",r)}catch(e){o("accounts.resetPassword",e)}};export{O as default};
@@ -1 +0,0 @@
1
- var u=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var n=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(r,e)}};var p=async(r={})=>{try{let t=await r.text();return u(t)}catch(t){o("accounts.request.handleParseResponse",t)}},m=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(e){o("accounts.request.getBody",e)}},w=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},h=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((e,a)=>{let l=`${window.location.origin}/api/_accounts/${r}`,i=w(r),d=m(i,t);return fetch(l,{method:i,mode:"cors",headers:{"Content-Type":"application/json"},body:d,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(n(`accounts.${r}`,c.errors),a(c)):e(c)}).catch(s=>(n(`accounts.${r}`,[s]),a({errors:[s]})))})}catch(e){o(`accounts.request.${r}`,e)}};var O=(r={})=>{try{return h("signup",r)}catch(t){o("accounts.signup",t)}};export{O as default};
@@ -1 +0,0 @@
1
- var i=(r="{}")=>{try{return JSON.parse(r)}catch{return r}};var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var a=(r="",t=[])=>{try{console.error(`${r} failed with the following errors:`),t.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(r,e)}};var p=async(r={})=>{try{let t=await r.text();return i(t)}catch(t){o("accounts.request.handleParseResponse",t)}},w=(r="GET",t={})=>{try{return["POST"].includes(r)?JSON.stringify({...t,origin:window?.location?.origin}):null}catch(e){o("accounts.request.getBody",e)}},m=(r=null)=>{try{switch(r){case"authenticated":case"user":return"GET";default:return"POST"}}catch(t){o("accounts.request.getHTTPMethod",t)}},h=(r="",t={})=>{try{if(typeof window.fetch!="undefined")return new Promise((e,n)=>{let l=`${window.location.origin}/api/_accounts/${r}`,u=m(r),d=w(u,t);return fetch(l,{method:u,mode:"cors",headers:{"Content-Type":"application/json"},body:d,credentials:"include"}).then(async s=>{let c=await p(s);return c?.errors?(a(`accounts.${r}`,c.errors),n(c)):e(c)}).catch(s=>(a(`accounts.${r}`,[s]),n({errors:[s]})))})}catch(e){o(`accounts.request.${r}`,e)}};var O=async(r={})=>{try{let t=await h("user",r);return t?.status===200&&t?.user}catch(t){o("accounts.user",t)}};export{O as default};
package/dist/api/get.js DELETED
@@ -1 +0,0 @@
1
- var o=(e="",r={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${r.message||r.reason||r}`)};var a=(e="",r=[])=>{try{console.error(`${e} failed with the following errors:`),r.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){o(e,t)}};var u=(e="{}")=>{try{return JSON.parse(e)}catch{return e}};var f=async(e={})=>{try{let r=await e.text();return u(r)}catch(r){o("api.get.handleParseResponse",r)}},x=(e="",r={})=>{try{return typeof window.fetch!="undefined"&&!r?.skip?new Promise((t,c)=>{let i=r.input?JSON.stringify(r.input):null,l=r.output?JSON.stringify(r.output):null,p=`${window.location.origin}/api/_getters/${e}?input=${i}&output=${l}`,d=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(p,{method:"GET",mode:"cors",headers:{...r?.headers||{},"x-joystick-csrf":d},credentials:"include"}).then(async s=>{let n=await f(s);return n?.errors?(a("get request",n.errors),c(n)):t(n)}).catch(s=>(a("get request",[s]),c({errors:[s]})))}):Promise.resolve()}catch(t){o("get request",t)}};export{x as default};
package/dist/api/index.js DELETED
@@ -1 +0,0 @@
1
- var s=(e="",r={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${r.message||r.reason||r}`)};var a=(e="",r=[])=>{try{console.error(`${e} failed with the following errors:`),r.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){s(e,t)}};var u=(e="{}")=>{try{return JSON.parse(e)}catch{return e}};var h=async(e={})=>{try{let r=await e.text();return u(r)}catch(r){s("api.get.handleParseResponse",r)}},l=(e="",r={})=>{try{return typeof window.fetch!="undefined"&&!r?.skip?new Promise((t,c)=>{let p=r.input?JSON.stringify(r.input):null,d=r.output?JSON.stringify(r.output):null,m=`${window.location.origin}/api/_getters/${e}?input=${p}&output=${d}`,n=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(m,{method:"GET",mode:"cors",headers:{...r?.headers||{},"x-joystick-csrf":n},credentials:"include"}).then(async o=>{let i=await h(o);return i?.errors?(a("get request",i.errors),c(i)):t(i)}).catch(o=>(a("get request",[o]),c({errors:[o]})))}):Promise.resolve()}catch(t){s("get request",t)}};var w=async(e={})=>{try{let r=await e.text();return u(r)}catch(r){s("api.set.handleParseResponse",r)}},y=(e={})=>{try{return JSON.stringify(e)}catch(r){s("api.set.getBody",r)}},f=(e="",r={})=>{try{return typeof window.fetch!="undefined"?new Promise((t,c)=>{let p=`${window.location.origin}/api/_setters/${e}`,d=y(r),m=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(p,{method:"POST",mode:"cors",headers:{...r?.headers||{},"Content-Type":"application/json","x-joystick-csrf":m},body:d,credentials:"include"}).then(async n=>{let o=await w(n);return o?.errors?(a("set request",o.errors),c(o)):t(o)}).catch(n=>(a("set request",[n]),c({errors:[n]})))}):Promise.resolve()}catch(t){s("set request",t)}};var T={get:l,set:f};export{T as default};
package/dist/api/set.js DELETED
@@ -1 +0,0 @@
1
- var o=(e="",r={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${r.message||r.reason||r}`)};var a=(e="",r=[])=>{try{console.error(`${e} failed with the following errors:`),r.forEach(t=>{console.log(t.message),t.stack&&console.log(t.stack)})}catch(t){o(e,t)}};var i=(e="{}")=>{try{return JSON.parse(e)}catch{return e}};var l=async(e={})=>{try{let r=await e.text();return i(r)}catch(r){o("api.set.handleParseResponse",r)}},m=(e={})=>{try{return JSON.stringify(e)}catch(r){o("api.set.getBody",r)}},E=(e="",r={})=>{try{return typeof window.fetch!="undefined"?new Promise((t,c)=>{let d=`${window.location.origin}/api/_setters/${e}`,p=m(r),u=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(d,{method:"POST",mode:"cors",headers:{...r?.headers||{},"Content-Type":"application/json","x-joystick-csrf":u},body:p,credentials:"include"}).then(async s=>{let n=await l(s);return n?.errors?(a("set request",n.errors),c(n)):t(n)}).catch(s=>(a("set request",[s]),c({errors:[s]})))}):Promise.resolve()}catch(t){o("set request",t)}};export{E as default};
@@ -1 +0,0 @@
1
- var r=(t="",o={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${o.message||o.reason||o}`)};var s=(t={})=>{try{let o=null;typeof window!="undefined"&&(o=window),typeof global!="undefined"&&(o=global),o&&(o.joystick={...o?.joystick||{},settings:o?.__joystick_settings__,...t})}catch(o){r("attachJoystickToWindow",o)}};export{s as default};
@@ -1 +0,0 @@
1
- var c=(s="",t={})=>{throw new Error(`[joystick${s?`.${s}`:""}] ${t.message||t.reason||t}`)};var o=s=>{try{return typeof s=="function"}catch(t){c("types.isFunction",t)}};var h=s=>{try{return!!(s&&typeof s=="object"&&!Array.isArray(s))}catch(t){c("types.isObject",t)}};var p=class{constructor(t="",e={}){this.name=t,this.value=e||{},this.listeners={change:[],set:[],unset:[]}}_getValueAtPath(t=""){return t?.split(".").reduce((e=null,r="")=>(e[r]&&(e=e[r]),e),this.value)}get(t=""){return t?.trim()===""?{...this.value||{}}:this._getValueAtPath(t)}set(t=null,e=""){if(!t||!o(t))throw new Error("First argument passed to set() must be a function.");let r=t(this.value);if(!h(r))throw new Error("Value to set must be an object representing the current cache state.");this.value=r,this._handleEvent(e,"set"),this._handleEvent(e,"change")}unset(t="",e=""){t?.trim()===""&&(this.value={});let r=t?.split("."),n=r?.length-1;r.reduce((i,u,a)=>(a===n&&delete i[u],i[u]),this.value),this._handleEvent(e,"unset"),this._handleEvent(e,"change")}on(t="",e=null){if(!["change","set","unset"].includes(t))throw new Error(`Event to listen for must be change, set, or unset. ${t} is not supported.`);if(!e||!o(e))throw new Error("Second argument passed to on("<t>") must be a function.");this.listeners={[t]:[...this.listeners[t]||[],e]}}_handleEvent(t="",e=""){let r=this.listeners[e]||[];for(let n=0;n<r?.length;n+=1){let i=r[n];o(i)&&i(this.value,t,e)}}},d=p;export{d as default};
@@ -1 +0,0 @@
1
- var n=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var c=r=>{try{return typeof r=="function"}catch(t){n("types.isFunction",t)}};var u=r=>{try{return!!(r&&typeof r=="object"&&!Array.isArray(r))}catch(t){n("types.isObject",t)}};var p=r=>{try{return typeof r=="string"}catch(t){n("types.isString",t)}};var a=class{constructor(t="",e={}){this.name=t,this.value=e||{},this.listeners={change:[],set:[],unset:[]}}_getValueAtPath(t=""){return t?.split(".").reduce((e=null,s="")=>(e[s]&&(e=e[s]),e),this.value)}get(t=""){return t?.trim()===""?{...this.value||{}}:this._getValueAtPath(t)}set(t=null,e=""){if(!t||!c(t))throw new Error("First argument passed to set() must be a function.");let s=t(this.value);if(!u(s))throw new Error("Value to set must be an object representing the current cache state.");this.value=s,this._handleEvent(e,"set"),this._handleEvent(e,"change")}unset(t="",e=""){t?.trim()===""&&(this.value={});let s=t?.split("."),o=s?.length-1;s.reduce((i,h,l)=>(l===o&&delete i[h],i[h]),this.value),this._handleEvent(e,"unset"),this._handleEvent(e,"change")}on(t="",e=null){if(!["change","set","unset"].includes(t))throw new Error(`Event to listen for must be change, set, or unset. ${t} is not supported.`);if(!e||!c(e))throw new Error("Second argument passed to on("<t>") must be a function.");this.listeners={[t]:[...this.listeners[t]||[],e]}}_handleEvent(t="",e=""){let s=this.listeners[e]||[];for(let o=0;o<s?.length;o+=1){let i=s[o];c(i)&&i(this.value,t,e)}}},y=a;var A=(r="",t={})=>{try{if(!r||r&&!p(r))throw new Error("Must pass a cache name as a string.");if(t&&!u(t))throw new Error("Default value for cache must be an object.");return new y(r,t)}catch(e){n("cache",e)}};export{A as default};
@@ -1,21 +0,0 @@
1
- var a=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var c=t=>{try{return typeof t=="function"}catch(e){a("types.isFunction",e)}};var h=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){a("types.isObject",e)}};var m=t=>{try{return typeof t=="string"}catch(e){a("types.isString",e)}};var j=(t="",e={})=>{try{let n="";if(t&&m(t))return n=t,n;if(t&&c(t))return n=t(e),n;if(t&&h(t)){let y=t?.print&&(m(t?.print)||c(t?.print)),x=t?.min&&h(t?.min),s=t?.min?.width&&h(t?.min?.width),f=t?.min?.height&&h(t?.min?.height),u=t?.max&&h(t?.max),d=t?.max?.width&&h(t?.max?.width),l=t?.max?.height&&h(t?.max?.height);if(y&&(n+=`
2
- @media print {
3
- ${typeof t?.print=="function"?t?.print(e):t.print}
4
- }
5
- `),x&&s){let o=Object.entries(t?.min?.width);for(let i=0;i<o.length;i+=1){let[p,r]=o[i];n+=`
6
- @media screen and (min-width: ${p}px) {
7
- ${typeof r=="function"?r(e):r}
8
- }
9
- `}}if(x&&f){let o=Object.entries(t?.min?.height);for(let i=0;i<o.length;i+=1){let[p,r]=o[i];n+=`
10
- @media screen and (min-height: ${p}px) {
11
- ${typeof r=="function"?r(e):r}
12
- }
13
- `}}if(u&&d){let o=Object.entries(t?.max?.width);for(let i=0;i<o.length;i+=1){let[p,r]=o[i];n+=`
14
- @media screen and (max-width: ${p}px) {
15
- ${typeof r=="function"?r(e):r}
16
- }
17
- `}}if(u&&l){let o=Object.entries(t?.max?.height);for(let i=0;i<o.length;i+=1){let[p,r]=o[i];n+=`
18
- @media screen and (max-height: ${p}px) {
19
- ${typeof r=="function"?r(e):r}
20
- }
21
- `}}return n}return""}catch(n){a("component.css.compileCSS",n)}};export{j as default};
@@ -1 +0,0 @@
1
- var s=(e="",r={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${r.message||r.reason||r}`)};var w=(e="",r="")=>{try{let o=new RegExp(/^(?!@).+({|,)/gim);return(e||"").replace(o,t=>["@",": "].some(n=>t?.includes(n))?t:`[js-c="${r}"] ${t.trim()}`)?.trim()}catch(o){s("component.css.prefix",o)}};export{w as default};
@@ -1 +0,0 @@
1
- var o=(t="",r={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${r.message||r.reason||r}`)};var c=(t="",r=[])=>{try{console.error(`${t} failed with the following errors:`),r.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(t,e)}};var p=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var g=async(t={})=>{try{let r=await t.text();return p(r)}catch(r){o("api.get.handleParseResponse",r)}},y=(t="",r={})=>{try{return typeof window.fetch!="undefined"&&!r?.skip?new Promise((e,s)=>{let i=r.input?JSON.stringify(r.input):null,d=r.output?JSON.stringify(r.output):null,f=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${d}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(f,{method:"GET",mode:"cors",headers:{...r?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async n=>{let u=await g(n);return u?.errors?(c("get request",u.errors),s(u)):e(u)}).catch(n=>(c("get request",[n]),s({errors:[n]})))}):Promise.resolve()}catch(e){o("get request",e)}};var F=async(t={})=>{try{let r=await t.text();return p(r)}catch(r){o("api.set.handleParseResponse",r)}},k=(t={})=>{try{return JSON.stringify(t)}catch(r){o("api.set.getBody",r)}},m=(t="",r={})=>{try{return typeof window.fetch!="undefined"?new Promise((e,s)=>{let i=`${window.location.origin}/api/_setters/${t}`,d=k(r),f=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...r?.headers||{},"Content-Type":"application/json","x-joystick-csrf":f},body:d,credentials:"include"}).then(async a=>{let n=await F(a);return n?.errors?(c("set request",n.errors),s(n)):e(n)}).catch(a=>(c("set request",[a]),s({errors:[a]})))}):Promise.resolve()}catch(e){o("set request",e)}};var l={get:y,set:m};var h=t=>{try{return typeof t=="function"}catch(r){o("types.isFunction",r)}};var w=async(t={},r={},e={},s={})=>{try{if(s?.options?.data&&h(s.options.data)){let i=await s.options.data(t,r,e,s);return Promise.resolve(i)}return Promise.resolve()}catch(i){o("component.data.fetch",i)}};var x=(t={},r={},e={})=>{try{return{...t,refetch:async(s={})=>{let i=await w(l,r,s,e);return e.data=x(i,r,e),window.__joystick_data__[e?.id]=i,e.render({afterRefetchDataRender:()=>{e?.lifecycle?.onRefetchData&&e?.lifecycle?.onRefetchData(e)}}),i}}}catch(s){o("component.data.compile",s)}},v=x;export{v as default};
@@ -1 +0,0 @@
1
- var o=(r="",t={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${t.message||t.reason||t}`)};var i=r=>{try{return typeof r=="function"}catch(t){o("types.isFunction",t)}};var u=async(r={},t={},n={},e={})=>{try{if(e?.options?.data&&i(e.options.data)){let s=await e.options.data(r,t,n,e);return Promise.resolve(s)}return Promise.resolve()}catch(s){o("component.data.fetch",s)}};export{u as default};
@@ -1 +0,0 @@
1
- var e=(t="",r={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${r.message||r.reason||r}`)};var n=t=>{try{return!!Array.isArray(t)}catch(r){e("types.isArray",r)}};var x=(t=[],r="")=>{try{return(n(t)&&t.find(s=>s?.componentId===r))?.data||{}}catch(o){e("findComponentDataFromSSR",o)}};export{x as default};
@@ -1 +0,0 @@
1
- var o=(t="",r={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${r.message||r.reason||r}`)};var m=()=>typeof window=="undefined";var c=(t="",r=[])=>{try{console.error(`${t} failed with the following errors:`),r.forEach(e=>{console.log(e.message),e.stack&&console.log(e.stack)})}catch(e){o(t,e)}};var p=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var g=async(t={})=>{try{let r=await t.text();return p(r)}catch(r){o("api.get.handleParseResponse",r)}},y=(t="",r={})=>{try{return typeof window.fetch!="undefined"&&!r?.skip?new Promise((e,s)=>{let i=r.input?JSON.stringify(r.input):null,d=r.output?JSON.stringify(r.output):null,f=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${d}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(f,{method:"GET",mode:"cors",headers:{...r?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async n=>{let u=await g(n);return u?.errors?(c("get request",u.errors),s(u)):e(u)}).catch(n=>(c("get request",[n]),s({errors:[n]})))}):Promise.resolve()}catch(e){o("get request",e)}};var _=async(t={})=>{try{let r=await t.text();return p(r)}catch(r){o("api.set.handleParseResponse",r)}},E=(t={})=>{try{return JSON.stringify(t)}catch(r){o("api.set.getBody",r)}},w=(t="",r={})=>{try{return typeof window.fetch!="undefined"?new Promise((e,s)=>{let i=`${window.location.origin}/api/_setters/${t}`,d=E(r),f=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...r?.headers||{},"Content-Type":"application/json","x-joystick-csrf":f},body:d,credentials:"include"}).then(async a=>{let n=await _(a);return n?.errors?(c("set request",n.errors),s(n)):e(n)}).catch(a=>(c("set request",[a]),s({errors:[a]})))}):Promise.resolve()}catch(e){o("set request",e)}};var l={get:y,set:w};var h=t=>{try{return typeof t=="function"}catch(r){o("types.isFunction",r)}};var x=async(t={},r={},e={},s={})=>{try{if(s?.options?.data&&h(s.options.data)){let i=await s.options.data(t,r,e,s);return Promise.resolve(i)}return Promise.resolve()}catch(i){o("component.data.fetch",i)}};var F=(t={},r={},e={})=>{try{return{...t,refetch:async(s={})=>{let i=await x(l,r,s,e);return e.data=F(i,r,e),window.__joystick_data__[e?.id]=i,e.render({afterRefetchDataRender:()=>{e?.lifecycle?.onRefetchData&&e?.lifecycle?.onRefetchData(e)}}),i}}}catch(s){o("component.data.compile",s)}},k=F;var or=(t={})=>{try{if(!m()){let r=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},e=window.__joystick_req__||{};return k(r,e,t)}return t?.data||{}}catch(r){o("component.loadDataFromWindow",r)}};export{or as default};
@@ -1 +0,0 @@
1
- var c=(e="",t={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${t.message||t.reason||t}`)};var p=(e={})=>{try{return Object.entries(e).map(([t,r])=>{let[s,...i]=t.split(" ");return{type:s.toLowerCase(),selector:i.join(" "),handler:r}})}catch(t){c("component.events.serialize",t)}};var l=e=>{try{return typeof e=="function"}catch(t){c("types.isFunction",t)}};var f=(e={})=>{try{if(e.lifecycle&&e.lifecycle.onBeforeUnmount&&l(e.lifecycle.onBeforeUnmount)){let t=function(){e.lifecycle.onBeforeUnmount(e)};window.removeEventListener("beforeunload",t),window.addEventListener("beforeunload",t)}}catch(t){c("component.events.registerListeners.attachOnBeforeUnmount",t)}},y=(e={},t=[],r={})=>{let s=e.instance.options.events||e.instance.dragDrop?{...e.instance.options?.events||{},...e.instance.dragDrop?.events||{}}:{},i=Object.keys(s).length>0;if(f(e.instance),i&&t.push({id:e.id,instanceId:e.instance.instanceId,events:p(s).map(n=>{let o=document.querySelectorAll(`body [js-i="${e.instance.instanceId}"] ${n.selector}`);return{...n,eventListener:function(a){Object.defineProperty(a,"target",{value:a.composedPath()[0]}),n.handler(a,{...e.instance||{},setState:e?.instance?.setState.bind(e.instance),...r||{}})},elements:o?.length>0?o:[]}}),instance:e.instance}),e?.children?.length>0)for(let n=0;n<e?.children?.length;n+=1){let o=e?.children[n];y(o,t,r)}return t},j=(e={})=>{setTimeout(()=>{let t=y(window.joystick._internal.tree,[],e);for(let r=0;r<t?.length;r+=1){let s=t[r];for(let i=0;i<s?.events?.length;i+=1){let n=s.events[i];for(let o=0;o<n?.elements?.length;o+=1)n.elements[o].addEventListener(n.type,n.eventListener)}}window.joystick._internal.eventListeners=t},0)};export{j as default};
@@ -1 +0,0 @@
1
- var l=()=>{setTimeout(()=>{let o=window.joystick._internal.eventListeners;for(let e=0;e<o?.length;e+=1){let s=o[e];for(let r=0;r<s?.events?.length;r+=1){let t=s.events[r];for(let n=0;n<t?.elements?.length;n+=1)t.elements[n].removeEventListener(t.type,t.eventListener)}}},0)};export{l as default};
@@ -1 +0,0 @@
1
- var c=(e="",n={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${n.message||n.reason||n}`)};var h=(e={})=>{try{return Object.entries(e).map(([n,s])=>{let[o,...t]=n.split(" ");return{type:o.toLowerCase(),selector:t.join(" "),handler:s}})}catch(n){c("component.events.serialize",n)}};var p=(e={},n={},s=[])=>{try{let o=Object.keys(e?.events||{})?.length>0?h(e?.events):[];for(let t=0;t<o?.length;t+=1){let r=o[t];s.push({...r,instance:e,elements:document.querySelectorAll(`body [js-i="${e.instanceId}"] ${r?.selector}`),handler:function(i){r.handler(i,{...e||{},setState:e?.setState.bind(e),...n||{}})}})}if(e?.children){let t=Object.entries(e?.children)?.flatMap(([r,l])=>l);for(let r=0;r<t?.length;r+=1){let l=t[r];p(l,n,s)}}return s}catch(o){c("component.eve!nts.registerListenersFix.getListeners",o)}},d=(e={},n={})=>{try{let o=p(e,n,[])?.flatMap((t={})=>[].flatMap.call(t?.elements||[],r=>{let{elements:l=[],...i}=t||{};return{...i,element:r}}));for(let t=0;t<o?.length;t+=1){let{instance:r,element:l,elementSelector:i,type:a,handler:m}=o[t];l.addEventListener(a,m),r._eventListeners=[...r?._eventListeners||[],{instance:r,element:l,elementSelector:i,type:a,handler:m}]}}catch(s){c("component.events.registerListenersFix",s)}},y=d;export{y as default};
@@ -1 +0,0 @@
1
- var t=(e="",r={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${r.message||r.reason||r}`)};var c=(e={})=>{try{return Object.entries(e).map(([r,o])=>{let[s,...a]=r.split(" ");return{type:s.toLowerCase(),selector:a.join(" "),handler:o}})}catch(r){t("component.events.serialize",r)}};export{c as default};
@@ -1 +0,0 @@
1
- var o=(r="",e={})=>{throw new Error(`[joystick${r?`.${r}`:""}] ${e.message||e.reason||e}`)};var c=(r={})=>{try{let e=r?._eventListeners||[];if(r?.children){let s=(Object.values(r?.children||{})?.reduce((n=[],i=[])=>[...n,...i],[])).flatMap((n={})=>c(n));e=[...e,...s]}return e}catch(e){o("component.events.unregisterListenersFix.getListeners",e)}},a=(r={})=>{try{let e=c(r);for(let t=0;t<e?.length;t+=1){let{instance:s,element:n,type:i,handler:l}=e[t];n.removeEventListener(i,l),s._eventListeners=s._eventListeners?.splice(t,1)}}catch(e){o("component.events.unregisterListenersFix",e)}},L=a;export{L as default};