zero-query 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.
package/index.js ADDED
@@ -0,0 +1,173 @@
1
+ /**
2
+ * ┌─────────────────────────────────────────────────────────┐
3
+ * │ zQuery (zeroQuery) — Lightweight Frontend Library │
4
+ * │ │
5
+ * │ jQuery-like selectors · Reactive components │
6
+ * │ SPA router · State management · Zero dependencies │
7
+ * │ │
8
+ * │ https://github.com/tonywied17/zero-query │
9
+ * └─────────────────────────────────────────────────────────┘
10
+ */
11
+
12
+ import { query, queryAll, ZQueryCollection } from './src/core.js';
13
+ import { reactive, signal, computed, effect } from './src/reactive.js';
14
+ import { component, mount, mountAll, getInstance, destroy, getRegistry, style } from './src/component.js';
15
+ import { createRouter, getRouter } from './src/router.js';
16
+ import { createStore, getStore } from './src/store.js';
17
+ import { http } from './src/http.js';
18
+ import {
19
+ debounce, throttle, pipe, once, sleep,
20
+ escapeHtml, html, trust, uuid, camelCase, kebabCase,
21
+ deepClone, deepMerge, isEqual, param, parseQuery,
22
+ storage, session, bus,
23
+ } from './src/utils.js';
24
+
25
+
26
+ // ---------------------------------------------------------------------------
27
+ // $ — The main function & namespace
28
+ // ---------------------------------------------------------------------------
29
+
30
+ /**
31
+ * Main selector function
32
+ *
33
+ * $('selector') → single Element (querySelector)
34
+ * $('<div>hello</div>') → create element (first created node)
35
+ * $(element) → return element as-is
36
+ * $(fn) → DOMContentLoaded shorthand
37
+ *
38
+ * @param {string|Element|NodeList|Function} selector
39
+ * @param {string|Element} [context]
40
+ * @returns {Element|null}
41
+ */
42
+ function $(selector, context) {
43
+ // $(fn) → DOM ready shorthand
44
+ if (typeof selector === 'function') {
45
+ query.ready(selector);
46
+ return;
47
+ }
48
+ return query(selector, context);
49
+ }
50
+
51
+
52
+ // --- Quick refs ------------------------------------------------------------
53
+ $.id = query.id;
54
+ $.class = query.class;
55
+ $.classes = query.classes;
56
+ $.tag = query.tag;
57
+ $.children = query.children;
58
+
59
+ // --- Collection selector ---------------------------------------------------
60
+ /**
61
+ * Collection selector (like jQuery's $)
62
+ *
63
+ * $.all('selector') → ZQueryCollection (querySelectorAll)
64
+ * $.all('<div>hello</div>') → create elements as collection
65
+ * $.all(element) → wrap element in collection
66
+ * $.all(nodeList) → wrap NodeList in collection
67
+ *
68
+ * @param {string|Element|NodeList|Array} selector
69
+ * @param {string|Element} [context]
70
+ * @returns {ZQueryCollection}
71
+ */
72
+ $.all = function(selector, context) {
73
+ return queryAll(selector, context);
74
+ };
75
+
76
+ // --- DOM helpers -----------------------------------------------------------
77
+ $.create = query.create;
78
+ $.ready = query.ready;
79
+ $.on = query.on;
80
+ $.fn = query.fn;
81
+
82
+ // --- Reactive primitives ---------------------------------------------------
83
+ $.reactive = reactive;
84
+ $.signal = signal;
85
+ $.computed = computed;
86
+ $.effect = effect;
87
+
88
+ // --- Components ------------------------------------------------------------
89
+ $.component = component;
90
+ $.mount = mount;
91
+ $.mountAll = mountAll;
92
+ $.getInstance = getInstance;
93
+ $.destroy = destroy;
94
+ $.components = getRegistry;
95
+ $.style = style;
96
+
97
+ // --- Router ----------------------------------------------------------------
98
+ $.router = createRouter;
99
+ $.getRouter = getRouter;
100
+
101
+ // --- Store -----------------------------------------------------------------
102
+ $.store = createStore;
103
+ $.getStore = getStore;
104
+
105
+ // --- HTTP ------------------------------------------------------------------
106
+ $.http = http;
107
+ $.get = http.get;
108
+ $.post = http.post;
109
+ $.put = http.put;
110
+ $.patch = http.patch;
111
+ $.delete = http.delete;
112
+
113
+ // --- Utilities -------------------------------------------------------------
114
+ $.debounce = debounce;
115
+ $.throttle = throttle;
116
+ $.pipe = pipe;
117
+ $.once = once;
118
+ $.sleep = sleep;
119
+ $.escapeHtml = escapeHtml;
120
+ $.html = html;
121
+ $.trust = trust;
122
+ $.uuid = uuid;
123
+ $.camelCase = camelCase;
124
+ $.kebabCase = kebabCase;
125
+ $.deepClone = deepClone;
126
+ $.deepMerge = deepMerge;
127
+ $.isEqual = isEqual;
128
+ $.param = param;
129
+ $.parseQuery = parseQuery;
130
+ $.storage = storage;
131
+ $.session = session;
132
+ $.bus = bus;
133
+
134
+ // --- Meta ------------------------------------------------------------------
135
+ $.version = '0.1.0';
136
+
137
+ $.noConflict = () => {
138
+ if (typeof window !== 'undefined' && window.$ === $) {
139
+ delete window.$;
140
+ }
141
+ return $;
142
+ };
143
+
144
+
145
+ // ---------------------------------------------------------------------------
146
+ // Global exposure (browser)
147
+ // ---------------------------------------------------------------------------
148
+ if (typeof window !== 'undefined') {
149
+ window.$ = $;
150
+ window.zQuery = $;
151
+ }
152
+
153
+
154
+ // ---------------------------------------------------------------------------
155
+ // Named exports (ES modules)
156
+ // ---------------------------------------------------------------------------
157
+ export {
158
+ $,
159
+ $ as zQuery,
160
+ ZQueryCollection,
161
+ queryAll,
162
+ reactive, signal, computed, effect,
163
+ component, mount, mountAll, getInstance, destroy, style,
164
+ createRouter, getRouter,
165
+ createStore, getStore,
166
+ http,
167
+ debounce, throttle, pipe, once, sleep,
168
+ escapeHtml, html, trust, uuid,
169
+ deepClone, deepMerge, isEqual, param, parseQuery,
170
+ storage, session, bus,
171
+ };
172
+
173
+ export default $;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "zero-query",
3
+ "version": "0.1.0",
4
+ "description": "Lightweight modern frontend library — jQuery-like selectors, reactive components, SPA router, and state management with zero dependencies.",
5
+ "main": "index.js",
6
+ "files": [
7
+ "src",
8
+ "index.js",
9
+ "LICENSE",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "node build.js",
14
+ "dev": "node build.js --watch",
15
+ "serve": "node examples/starter-app/local-server.js",
16
+ "watch": "node watch.js"
17
+ },
18
+ "keywords": [
19
+ "dom",
20
+ "query",
21
+ "selector",
22
+ "components",
23
+ "spa",
24
+ "router",
25
+ "reactive",
26
+ "lightweight",
27
+ "frontend",
28
+ "zero",
29
+ "zquery",
30
+ "zero-dependency"
31
+ ],
32
+ "author": "Anthony Wiedman",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/tonywied17/zero-query.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/tonywied17/zero-query/issues"
40
+ },
41
+ "homepage": "https://github.com/tonywied17/zero-query#readme",
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "devDependencies": {
46
+ "zero-http": "^0.2.3"
47
+ }
48
+ }