@manyducks.co/dolla 2.0.0 → 3.0.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 (112) hide show
  1. package/README.md +133 -284
  2. package/dist/core/context.d.ts +22 -146
  3. package/dist/core/debug.d.ts +19 -0
  4. package/dist/core/index.d.ts +15 -16
  5. package/dist/core/markup/helpers.d.ts +34 -0
  6. package/dist/core/markup/html.d.ts +3 -0
  7. package/dist/core/{nodes → markup/nodes}/dom.d.ts +5 -4
  8. package/dist/core/markup/nodes/dynamic.d.ts +16 -0
  9. package/dist/core/markup/nodes/element.d.ts +14 -0
  10. package/dist/core/markup/nodes/portal.d.ts +15 -0
  11. package/dist/core/markup/nodes/repeat.d.ts +21 -0
  12. package/dist/core/markup/nodes/view.d.ts +17 -0
  13. package/dist/core/markup/scheduler.d.ts +1 -0
  14. package/dist/core/markup/types.d.ts +62 -0
  15. package/dist/core/markup/utils.d.ts +22 -0
  16. package/dist/core/ref.d.ts +6 -12
  17. package/dist/core/root.d.ts +36 -0
  18. package/dist/core/signals.d.ts +46 -76
  19. package/dist/core/symbols.d.ts +2 -0
  20. package/dist/core-BLkJ-xuh.js +242 -0
  21. package/dist/core-BLkJ-xuh.js.map +1 -0
  22. package/dist/http/index.d.ts +21 -33
  23. package/dist/http.js +89 -149
  24. package/dist/http.js.map +1 -1
  25. package/dist/index.js +4 -174
  26. package/dist/jsx-dev-runtime.d.ts +4 -3
  27. package/dist/jsx-dev-runtime.js +12 -9
  28. package/dist/jsx-dev-runtime.js.map +1 -1
  29. package/dist/jsx-runtime.d.ts +5 -4
  30. package/dist/jsx-runtime.js +17 -12
  31. package/dist/jsx-runtime.js.map +1 -1
  32. package/dist/router/index.d.ts +4 -3
  33. package/dist/router/router.d.ts +19 -162
  34. package/dist/router/store.d.ts +12 -0
  35. package/dist/router/types.d.ts +152 -0
  36. package/dist/router/utils.d.ts +99 -0
  37. package/dist/router/utils.test.d.ts +1 -0
  38. package/dist/router.js +428 -5
  39. package/dist/router.js.map +1 -1
  40. package/dist/signals-CMJPGr_M.js +354 -0
  41. package/dist/signals-CMJPGr_M.js.map +1 -0
  42. package/dist/translate/index.d.ts +82 -0
  43. package/dist/translate.js +125 -0
  44. package/dist/translate.js.map +1 -0
  45. package/dist/types.d.ts +21 -39
  46. package/dist/utils.d.ts +41 -29
  47. package/dist/utils.test.d.ts +1 -0
  48. package/dist/view-cBN-hn_T.js +360 -0
  49. package/dist/view-cBN-hn_T.js.map +1 -0
  50. package/dist/virtual/index.d.ts +1 -0
  51. package/dist/virtual/list.d.ts +53 -0
  52. package/package.json +19 -16
  53. package/dist/core/app.d.ts +0 -24
  54. package/dist/core/env.d.ts +0 -3
  55. package/dist/core/hooks.d.ts +0 -70
  56. package/dist/core/logger.d.ts +0 -42
  57. package/dist/core/logger.test.d.ts +0 -0
  58. package/dist/core/markup.d.ts +0 -82
  59. package/dist/core/markup.test.d.ts +0 -0
  60. package/dist/core/nodes/_markup.d.ts +0 -36
  61. package/dist/core/nodes/dynamic.d.ts +0 -22
  62. package/dist/core/nodes/element.d.ts +0 -27
  63. package/dist/core/nodes/portal.d.ts +0 -18
  64. package/dist/core/nodes/repeat.d.ts +0 -27
  65. package/dist/core/nodes/view.d.ts +0 -25
  66. package/dist/core/views/default-crash-view.d.ts +0 -25
  67. package/dist/core/views/for.d.ts +0 -21
  68. package/dist/core/views/fragment.d.ts +0 -7
  69. package/dist/core/views/portal.d.ts +0 -16
  70. package/dist/core/views/show.d.ts +0 -25
  71. package/dist/fragment-BahD_BJA.js +0 -7
  72. package/dist/fragment-BahD_BJA.js.map +0 -1
  73. package/dist/i18n/index.d.ts +0 -134
  74. package/dist/i18n.js +0 -309
  75. package/dist/i18n.js.map +0 -1
  76. package/dist/index-DRJlxs-Q.js +0 -535
  77. package/dist/index-DRJlxs-Q.js.map +0 -1
  78. package/dist/index.js.map +0 -1
  79. package/dist/logger-Aqi9m1CF.js +0 -565
  80. package/dist/logger-Aqi9m1CF.js.map +0 -1
  81. package/dist/markup-8jNhoqDe.js +0 -1089
  82. package/dist/markup-8jNhoqDe.js.map +0 -1
  83. package/dist/router/hooks.d.ts +0 -2
  84. package/dist/router/router.utils.d.ts +0 -93
  85. package/dist/typeChecking-5kmX0ulW.js +0 -65
  86. package/dist/typeChecking-5kmX0ulW.js.map +0 -1
  87. package/dist/typeChecking.d.ts +0 -95
  88. package/docs/buildless.md +0 -132
  89. package/docs/components.md +0 -238
  90. package/docs/hooks.md +0 -356
  91. package/docs/http.md +0 -178
  92. package/docs/i18n.md +0 -220
  93. package/docs/index.md +0 -10
  94. package/docs/markup.md +0 -136
  95. package/docs/mixins.md +0 -176
  96. package/docs/ref.md +0 -77
  97. package/docs/router.md +0 -281
  98. package/docs/setup.md +0 -137
  99. package/docs/signals.md +0 -262
  100. package/docs/stores.md +0 -113
  101. package/docs/views.md +0 -356
  102. package/notes/atomic.md +0 -452
  103. package/notes/elimination.md +0 -33
  104. package/notes/observable.md +0 -180
  105. package/notes/scratch.md +0 -565
  106. package/notes/splitting.md +0 -5
  107. package/notes/views.md +0 -195
  108. package/vite.config.js +0 -22
  109. /package/dist/core/{hooks.test.d.ts → markup/html.test.d.ts} +0 -0
  110. /package/dist/core/{ref.test.d.ts → markup/utils.test.d.ts} +0 -0
  111. /package/dist/router/{router.utils.test.d.ts → matcher.test.d.ts} +0 -0
  112. /package/dist/{typeChecking.test.d.ts → router/router.test.d.ts} +0 -0
package/dist/http.js CHANGED
@@ -1,150 +1,90 @@
1
- import { a } from "./typeChecking-5kmX0ulW.js";
2
- class p {
3
- #t = [];
4
- #s = h();
5
- /**
6
- * Adds a new middleware that will apply to subsequent requests.
7
- * Returns a function to remove this middleware.
8
- *
9
- * @param middleware - A middleware function that will intercept requests.
10
- */
11
- use(e) {
12
- return this.#t.push(e), () => {
13
- this.#t.splice(this.#t.indexOf(e), 1);
14
- };
15
- }
16
- async get(e, t) {
17
- return this.#e("get", e, t);
18
- }
19
- async put(e, t) {
20
- return this.#e("put", e, t);
21
- }
22
- async patch(e, t) {
23
- return this.#e("patch", e, t);
24
- }
25
- async post(e, t) {
26
- return this.#e("post", e, t);
27
- }
28
- async delete(e, t) {
29
- return this.#e("delete", e, t);
30
- }
31
- async head(e, t) {
32
- return this.#e("head", e, t);
33
- }
34
- async options(e, t) {
35
- return this.#e("options", e, t);
36
- }
37
- async trace(e, t) {
38
- return this.#e("trace", e, t);
39
- }
40
- async #e(e, t, s) {
41
- return new u({
42
- ...s,
43
- method: e,
44
- uri: t,
45
- middleware: this.#t,
46
- fetch: this.#s
47
- }).fetch();
48
- }
49
- }
50
- function h() {
51
- if (typeof window < "u" && window.fetch)
52
- return window.fetch.bind(window);
53
- if (typeof global < "u" && global.fetch)
54
- return global.fetch.bind(global);
55
- throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
56
- }
57
- class l extends Error {
58
- response;
59
- constructor(e) {
60
- const { status: t, statusText: s, method: r, url: n } = e, o = `${t} ${s}: Request failed (${r.toUpperCase()} ${n.toString()})`;
61
- super(o), this.response = e;
62
- }
63
- }
64
- class c {
65
- method;
66
- url;
67
- headers = new Headers();
68
- body;
69
- get isSameOrigin() {
70
- return this.url.origin === window.location.origin;
71
- }
72
- constructor(e) {
73
- this.method = e.method, this.body = e.body, e.uri.startsWith("http") ? this.url = new URL(e.uri) : this.url = new URL(e.uri, window.location.origin), this._applyHeaders(e.headers), this._applyQueryParams(e.query);
74
- }
75
- _applyHeaders(e) {
76
- if (e != null)
77
- if (e instanceof Map || e instanceof Headers)
78
- e.forEach((t, s) => {
79
- this.headers.set(s, t);
80
- });
81
- else if (a(e))
82
- for (const t in e) {
83
- const s = e[t];
84
- s instanceof Date ? this.headers.set(t, s.toISOString()) : s != null && this.headers.set(t, String(s));
85
- }
86
- else
87
- throw new TypeError(`Unknown headers type. Got: ${e}`);
88
- }
89
- _applyQueryParams(e) {
90
- if (e != null)
91
- if (e instanceof Map || e instanceof URLSearchParams)
92
- e.forEach((t, s) => {
93
- this.url.searchParams.set(s, t);
94
- });
95
- else if (a(e))
96
- for (const t in e) {
97
- const s = e[t];
98
- s instanceof Date ? this.url.searchParams.set(t, s.toISOString()) : s != null && this.url.searchParams.set(t, String(s));
99
- }
100
- else
101
- throw new TypeError(`Unknown query params type. Got: ${e}`);
102
- }
103
- }
104
- class u {
105
- _middleware;
106
- _fetch;
107
- _request;
108
- _response;
109
- constructor(e) {
110
- this._middleware = e.middleware, this._fetch = e.fetch, this._request = new c(e);
111
- }
112
- async fetch() {
113
- if (this._middleware.length > 0) {
114
- const e = (t = 0) => {
115
- const s = this._middleware[t], r = this._middleware[t + 1] ? e(t + 1) : this._handler.bind(this);
116
- return async () => s(this._request, async () => (await r(), this._response));
117
- };
118
- await e()();
119
- } else
120
- await this._handler();
121
- if (this._response.status < 200 || this._response.status >= 400)
122
- throw new l(this._response);
123
- return this._response;
124
- }
125
- // This is the function that performs the actual request after the final middleware.
126
- async _handler() {
127
- let e;
128
- const t = this._request;
129
- !t.headers.has("content-type") && a(t.body) ? (t.headers.set("content-type", "application/json"), e = JSON.stringify(t.body)) : e = t.body;
130
- const s = await this._fetch(t.url.toString(), {
131
- method: t.method,
132
- headers: t.headers,
133
- body: e
134
- }), r = s.headers.get("content-type");
135
- let n;
136
- r?.includes("application/json") ? n = await s.json() : r?.includes("application/x-www-form-urlencoded") ? n = await s.formData() : n = await s.text(), this._response = {
137
- method: t.method,
138
- url: t.url,
139
- status: s.status,
140
- statusText: s.statusText,
141
- headers: s.headers,
142
- body: n
143
- };
144
- }
145
- }
146
- export {
147
- p as HTTP,
148
- l as HTTPResponseError
1
+ //#region src/http/index.ts
2
+ var e = class extends Error {
3
+ response;
4
+ constructor(e) {
5
+ super(`${e.status} ${e.statusText}: Request failed (${e.method.toUpperCase()} ${e.url.toString()})`), this.response = e;
6
+ }
7
+ }, t = class {
8
+ #e = [];
9
+ #t = typeof window < "u" && window.fetch ? window.fetch.bind(window) : typeof global < "u" && global.fetch ? global.fetch.bind(global) : null;
10
+ constructor() {
11
+ if (!this.#t) throw Error("Fetch API not found. Unsupported environment.");
12
+ }
13
+ use(e) {
14
+ return this.#e.push(e), () => {
15
+ this.#e = this.#e.filter((t) => t !== e);
16
+ };
17
+ }
18
+ async get(e, t) {
19
+ return this.#n("GET", e, t);
20
+ }
21
+ async put(e, t) {
22
+ return this.#n("PUT", e, t);
23
+ }
24
+ async patch(e, t) {
25
+ return this.#n("PATCH", e, t);
26
+ }
27
+ async post(e, t) {
28
+ return this.#n("POST", e, t);
29
+ }
30
+ async delete(e, t) {
31
+ return this.#n("DELETE", e, t);
32
+ }
33
+ async head(e, t) {
34
+ return this.#n("HEAD", e, t);
35
+ }
36
+ async options(e, t) {
37
+ return this.#n("OPTIONS", e, t);
38
+ }
39
+ async trace(e, t) {
40
+ return this.#n("TRACE", e, t);
41
+ }
42
+ async #n(t, n, r = {}) {
43
+ let i = typeof window < "u" ? window.location.origin : "http://localhost", a = new URL(n, n.startsWith("http") ? void 0 : i);
44
+ if (r.query) if (r.query instanceof URLSearchParams) r.query.forEach((e, t) => a.searchParams.set(t, e));
45
+ else for (let [e, t] of Object.entries(r.query)) t != null && a.searchParams.set(e, t instanceof Date ? t.toISOString() : String(t));
46
+ let o = new Headers(r.headers), s = r.body, c = s && typeof s == "object" && s.constructor === Object;
47
+ !o.has("content-type") && (c || Array.isArray(s)) && (o.set("content-type", "application/json"), s = JSON.stringify(s));
48
+ let l = {
49
+ method: t,
50
+ url: a,
51
+ headers: o,
52
+ body: t === "GET" || t === "HEAD" ? void 0 : s,
53
+ signal: r.signal
54
+ }, u = -1, d = async (t) => {
55
+ if (t <= u) throw Error("next() called multiple times");
56
+ u = t;
57
+ let n = this.#e[t];
58
+ if (n) {
59
+ let e;
60
+ return await n(l, async () => (e = await d(t + 1), e)), e;
61
+ }
62
+ let i = await this.#t(l.url.toString(), {
63
+ method: l.method,
64
+ headers: l.headers,
65
+ body: l.body,
66
+ signal: l.signal
67
+ }), a;
68
+ if (r.parse) a = await r.parse(i);
69
+ else {
70
+ let e = i.headers.get("content-type") || "";
71
+ a = e.includes("json") ? await i.json() : e.includes("form") ? await i.formData() : await i.text();
72
+ }
73
+ let o = {
74
+ method: l.method,
75
+ url: l.url,
76
+ status: i.status,
77
+ statusText: i.statusText,
78
+ headers: i.headers,
79
+ body: a
80
+ };
81
+ if (!i.ok) throw new e(o);
82
+ return o;
83
+ };
84
+ return d(0);
85
+ }
149
86
  };
150
- //# sourceMappingURL=http.js.map
87
+ //#endregion
88
+ export { t as HTTP, e as HTTPResponseError };
89
+
90
+ //# sourceMappingURL=http.js.map
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sources":["../src/http/index.ts"],"sourcesContent":["import { isObject } from \"../typeChecking.js\";\n\n/**\n * A simple HTTP client with middleware support. Middleware applies to all requests made through this store,\n * so it's the perfect way to handle things like auth headers and permission checks for API calls.\n */\nexport class HTTP {\n #middleware: HTTPMiddleware[] = [];\n #fetch = getDefaultFetch();\n\n /**\n * Adds a new middleware that will apply to subsequent requests.\n * Returns a function to remove this middleware.\n *\n * @param middleware - A middleware function that will intercept requests.\n */\n use(fn: HTTPMiddleware) {\n this.#middleware.push(fn);\n\n // Call returned function to remove this middleware for subsequent requests.\n return () => {\n this.#middleware.splice(this.#middleware.indexOf(fn), 1);\n };\n }\n\n async get<ResBody = unknown>(uri: string, options?: RequestOptions<never>) {\n return this.#request<ResBody, never>(\"get\", uri, options);\n }\n\n async put<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"put\", uri, options);\n }\n\n async patch<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"patch\", uri, options);\n }\n\n async post<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"post\", uri, options);\n }\n\n async delete<ResBody = unknown>(uri: string, options?: RequestOptions<never>) {\n return this.#request<ResBody, never>(\"delete\", uri, options);\n }\n\n async head<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"head\", uri, options);\n }\n\n async options<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"options\", uri, options);\n }\n\n async trace<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody>) {\n return this.#request<ResBody, ReqBody>(\"trace\", uri, options);\n }\n\n async #request<ResBody, ReqBody>(method: string, uri: string, options?: RequestOptions<any>) {\n const runner = new Runner<ResBody, ReqBody>({\n ...options,\n method,\n uri,\n middleware: this.#middleware,\n fetch: this.#fetch,\n });\n return runner.fetch();\n }\n}\n\nfunction getDefaultFetch(): typeof window.fetch {\n if (typeof window !== \"undefined\" && window.fetch) {\n return window.fetch.bind(window);\n }\n\n if (typeof global !== \"undefined\" && global.fetch) {\n return global.fetch.bind(global);\n }\n\n throw new Error(\"Running in neither browser nor node. Please run this app in one of the supported environments.\");\n}\n\n/*====================*\\\n|| Request ||\n\\*====================*/\n\nexport type HTTPMiddleware = (\n request: HTTPRequest<unknown>,\n next: () => Promise<HTTPResponse<unknown>>,\n) => void | Promise<void>;\n\nexport interface RequestOptions<ReqBody> {\n /**\n * Body to send with the request.\n */\n body?: ReqBody;\n\n /**\n * Headers to send with the request.\n */\n headers?: Record<string, any> | Headers;\n\n /**\n * Query params to interpolate into the URL.\n */\n query?: Record<string, any> | URLSearchParams;\n}\n\nexport interface HTTPRequest<Body> {\n method: string;\n url: URL;\n headers: Headers;\n body: Body;\n}\n\nexport interface HTTPResponse<Body> {\n method: string;\n url: URL;\n headers: Headers;\n status: number;\n statusText: string;\n body: Body;\n}\n\ninterface MakeRequestConfig<ReqBody> extends RequestOptions<ReqBody> {\n method: string;\n uri: string;\n middleware: HTTPMiddleware[];\n fetch: typeof window.fetch;\n}\n\nexport class HTTPResponseError extends Error {\n response;\n\n constructor(response: HTTPResponse<any>) {\n const { status, statusText, method, url } = response;\n const message = `${status} ${statusText}: Request failed (${method.toUpperCase()} ${url.toString()})`;\n\n super(message);\n\n this.response = response;\n }\n}\n\nclass Request<ReqBody> implements HTTPRequest<ReqBody> {\n method: string;\n url: URL;\n headers = new Headers();\n body!: ReqBody;\n\n get isSameOrigin() {\n return this.url.origin === window.location.origin;\n }\n\n constructor(config: MakeRequestConfig<ReqBody>) {\n this.method = config.method;\n this.body = config.body!;\n if (config.uri.startsWith(\"http\")) {\n this.url = new URL(config.uri);\n } else {\n this.url = new URL(config.uri, window.location.origin);\n }\n\n this._applyHeaders(config.headers);\n this._applyQueryParams(config.query);\n }\n\n private _applyHeaders(headers: any) {\n if (headers == null) return;\n\n if (headers instanceof Map || headers instanceof Headers) {\n headers.forEach((value, key) => {\n this.headers.set(key, value);\n });\n } else if (isObject(headers)) {\n for (const name in headers) {\n const value = headers[name];\n if (value instanceof Date) {\n this.headers.set(name, value.toISOString());\n } else if (value != null) {\n this.headers.set(name, String(value));\n }\n }\n } else {\n throw new TypeError(`Unknown headers type. Got: ${headers}`);\n }\n }\n\n private _applyQueryParams(query: any) {\n if (query == null) return;\n\n if (query instanceof Map || query instanceof URLSearchParams) {\n query.forEach((value, key) => {\n this.url.searchParams.set(key, value);\n });\n } else if (isObject(query)) {\n for (const name in query) {\n const value = query[name];\n if (value instanceof Date) {\n this.url.searchParams.set(name, value.toISOString());\n } else if (value != null) {\n this.url.searchParams.set(name, String(value));\n }\n }\n } else {\n throw new TypeError(`Unknown query params type. Got: ${query}`);\n }\n }\n}\n\nclass Runner<ResBody, ReqBody> {\n private _middleware;\n private _fetch;\n\n private _request: Request<ReqBody>;\n private _response?: HTTPResponse<ResBody>;\n\n constructor(config: MakeRequestConfig<ReqBody>) {\n this._middleware = config.middleware;\n this._fetch = config.fetch;\n\n this._request = new Request(config);\n }\n\n async fetch() {\n if (this._middleware.length > 0) {\n const mount = (index = 0) => {\n const current = this._middleware[index];\n const next = this._middleware[index + 1] ? mount(index + 1) : this._handler.bind(this);\n\n return async () =>\n current(this._request, async () => {\n await next();\n return this._response!;\n });\n };\n\n await mount()();\n } else {\n await this._handler();\n }\n\n if (this._response!.status < 200 || this._response!.status >= 400) {\n throw new HTTPResponseError(this._response!);\n }\n\n return this._response!;\n }\n\n // This is the function that performs the actual request after the final middleware.\n private async _handler() {\n let reqBody: BodyInit;\n\n const req = this._request;\n\n if (!req.headers.has(\"content-type\") && isObject(req.body)) {\n // Auto-detect JSON bodies and encode as a string with correct headers.\n req.headers.set(\"content-type\", \"application/json\");\n reqBody = JSON.stringify(req.body);\n } else {\n reqBody = req.body as BodyInit;\n }\n\n const fetched = await this._fetch(req.url.toString(), {\n method: req.method,\n headers: req.headers,\n body: reqBody,\n });\n\n // Auto-parse response body based on content-type header\n const contentType = fetched.headers.get(\"content-type\");\n\n let body: ResBody;\n\n if (contentType?.includes(\"application/json\")) {\n body = await fetched.json();\n } else if (contentType?.includes(\"application/x-www-form-urlencoded\")) {\n body = (await fetched.formData()) as ResBody;\n } else {\n body = (await fetched.text()) as ResBody;\n }\n\n this._response = {\n method: req.method,\n url: req.url,\n status: fetched.status,\n statusText: fetched.statusText,\n headers: fetched.headers,\n body,\n };\n }\n}\n"],"names":["HTTP","#middleware","#fetch","getDefaultFetch","fn","uri","options","#request","method","Runner","HTTPResponseError","response","status","statusText","url","message","Request","config","headers","value","key","isObject","name","query","mount","index","current","next","reqBody","req","fetched","contentType","body"],"mappings":";AAMO,MAAMA,EAAK;AAAA,EAChBC,KAAgC,CAAA;AAAA,EAChCC,KAASC,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQT,IAAIC,GAAoB;AACtB,gBAAKH,GAAY,KAAKG,CAAE,GAGjB,MAAM;AACX,WAAKH,GAAY,OAAO,KAAKA,GAAY,QAAQG,CAAE,GAAG,CAAC;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,MAAM,IAAu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AAIkB;AAEJ,UAAMC,IAAM,KAAK;AAEjB,IAAI,CAACA,EAAI,QAAQ,IAAI,cAAc,KAAKR,EAASQ,EAAI,IAAI,KAEvDA,EAAI,QAAQ,IAAI,gBAAgB,kBAAkB,GAClDD,IAAU,KAAK,UAAUC,EAAI,IAAI,KAEjCD,IAAUC,EAAI;AAGhB,UAAMC,IAAU,MAAM,KAAK,OAAOD,EAAI,IAAI,YAAY;AAAA,MACpD,QAAQA,EAAI;AAAA,MACZ,SAASA,EAAI;AAAA,MACb,MAAMD;AAAA,IAAA,CACP,GAGKG,IAAcD,EAAQ,QAAQ,IAAI,cAAc;AAEtD,QAAIE;AAEJ,IAAID,GAAa,SAAS,kBAAkB,IAC1CC,IAAO,MAAMF,EAAQ,KAAA,IACZC,GAAa,SAAS,mCAAmC,IAClEC,IAAQ,MAAMF,EAAQ,SAAA,IAEtBE,IAAQ,MAAMF,EAAQ,KAAA,GAGxB,KAAK,YAAY;AAAA,MACf,QAAQD,EAAI;AAAA,MACZ,KAAKA,EAAI;AAAA,MACT,QAAQC,EAAQ;AAAA,MAChB,YAAYA,EAAQ;AAAA,MACpB,SAASA,EAAQ;AAAA,MACjB,MAAAE;AAAA,IAAA;AAAA,EAEJ;AACF;"}
1
+ {"version":3,"file":"http.js","names":["#fetch","#middleware","#request"],"sources":["../src/http/index.ts"],"sourcesContent":["export type HTTPMiddleware = (\n request: HTTPRequest<unknown>,\n next: () => Promise<HTTPResponse<unknown>>,\n) => Promise<HTTPResponse<unknown> | void> | void;\n\nexport interface RequestOptions<ReqBody, ResBody> {\n body?: ReqBody;\n headers?: Record<string, any> | Headers;\n query?: Record<string, any> | URLSearchParams;\n parse?: (response: Response) => Promise<ResBody>;\n signal?: AbortSignal;\n}\n\nexport interface HTTPRequest<Body> {\n method: string;\n url: URL;\n headers: Headers;\n body: Body;\n signal?: AbortSignal;\n}\n\nexport interface HTTPResponse<Body> {\n method: string;\n url: URL;\n headers: Headers;\n status: number;\n statusText: string;\n body: Body;\n}\n\nexport class HTTPResponseError extends Error {\n response: HTTPResponse<any>;\n\n constructor(response: HTTPResponse<any>) {\n super(\n `${response.status} ${response.statusText}: Request failed (${response.method.toUpperCase()} ${response.url.toString()})`,\n );\n this.response = response;\n }\n}\n\n/**\n * A simple HTTP client with middleware support.\n */\nexport class HTTP {\n #middleware: HTTPMiddleware[] = [];\n #fetch =\n typeof window !== \"undefined\" && window.fetch\n ? window.fetch.bind(window)\n : typeof global !== \"undefined\" && global.fetch\n ? global.fetch.bind(global)\n : null;\n\n constructor() {\n if (!this.#fetch) throw new Error(\"Fetch API not found. Unsupported environment.\");\n }\n\n use(fn: HTTPMiddleware) {\n this.#middleware.push(fn);\n return () => {\n this.#middleware = this.#middleware.filter((m) => m !== fn);\n };\n }\n\n async get<ResBody = unknown>(uri: string, options?: RequestOptions<never, ResBody>) {\n return this.#request<ResBody, never>(\"GET\", uri, options);\n }\n async put<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"PUT\", uri, options);\n }\n async patch<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"PATCH\", uri, options);\n }\n async post<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"POST\", uri, options);\n }\n async delete<ResBody = unknown>(uri: string, options?: RequestOptions<never, ResBody>) {\n return this.#request<ResBody, never>(\"DELETE\", uri, options);\n }\n async head<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"HEAD\", uri, options);\n }\n async options<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"OPTIONS\", uri, options);\n }\n async trace<ResBody = unknown, ReqBody = unknown>(uri: string, options?: RequestOptions<ReqBody, ResBody>) {\n return this.#request<ResBody, ReqBody>(\"TRACE\", uri, options);\n }\n\n async #request<ResBody, ReqBody>(\n method: string,\n uri: string,\n options: RequestOptions<any, ResBody> = {},\n ): Promise<HTTPResponse<ResBody>> {\n const base = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n const url = new URL(uri, uri.startsWith(\"http\") ? undefined : base);\n\n if (options.query) {\n if (options.query instanceof URLSearchParams) {\n options.query.forEach((v, k) => url.searchParams.set(k, v));\n } else {\n for (const [k, v] of Object.entries(options.query)) {\n if (v != null) url.searchParams.set(k, v instanceof Date ? v.toISOString() : String(v));\n }\n }\n }\n\n const headers = new Headers(options.headers as HeadersInit);\n\n let body = options.body;\n const isPlainObject = body && typeof body === \"object\" && body.constructor === Object;\n\n if (!headers.has(\"content-type\") && (isPlainObject || Array.isArray(body))) {\n headers.set(\"content-type\", \"application/json\");\n body = JSON.stringify(body);\n }\n\n const req: HTTPRequest<any> = {\n method,\n url,\n headers,\n body: method === \"GET\" || method === \"HEAD\" ? undefined : body,\n signal: options.signal,\n };\n\n // Execute middleware\n let index = -1;\n const dispatch = async (i: number): Promise<HTTPResponse<any>> => {\n if (i <= index) throw new Error(\"next() called multiple times\");\n index = i;\n\n const mw = this.#middleware[i];\n if (mw) {\n let res: HTTPResponse<any> | undefined;\n await mw(req, async () => {\n res = await dispatch(i + 1);\n return res;\n });\n return res!;\n }\n\n // Terminal Request Handler\n const fetched = await this.#fetch!(req.url.toString(), {\n method: req.method,\n headers: req.headers,\n body: req.body,\n signal: req.signal,\n });\n\n let resBody: any;\n if (options.parse) {\n resBody = await options.parse(fetched);\n } else {\n const type = fetched.headers.get(\"content-type\") || \"\";\n if (type.includes(\"json\")) resBody = await fetched.json();\n else if (type.includes(\"form\")) resBody = await fetched.formData();\n else resBody = await fetched.text();\n }\n\n const response: HTTPResponse<any> = {\n method: req.method,\n url: req.url,\n status: fetched.status,\n statusText: fetched.statusText,\n headers: fetched.headers,\n body: resBody,\n };\n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,CAAC,EAEE;AACJ,OAAI,EAAQ,MACV,KAAU,MAAM,EAAQ,MAAM,EAAQ;QACjC;IACL,IAAM,IAAO,EAAQ,QAAQ,IAAI,eAAe,IAAI;AACpD,IAEK,IAFD,EAAK,SAAS,OAAO,GAAY,MAAM,EAAQ,MAAM,GAChD,EAAK,SAAS,OAAO,GAAY,MAAM,EAAQ,UAAU,GACnD,MAAM,EAAQ,MAAM;;GAGrC,IAAM,IAA8B;IAClC,QAAQ,EAAI;IACZ,KAAK,EAAI;IACT,QAAQ,EAAQ;IAChB,YAAY,EAAQ;IACpB,SAAS,EAAQ;IACjB,MAAM;IACP;AAED,OAAI,CAAC,EAAQ,GAAI,OAAM,IAAI,EAAkB,EAAS;AACtD,UAAO;;AAGT,SAAO,EAAS,EAAE"}
package/dist/index.js CHANGED
@@ -1,174 +1,4 @@
1
- import { R as f, c as d, M as g, a as w, U as y } from "./index-DRJlxs-Q.js";
2
- import { t as b, i as x } from "./typeChecking-5kmX0ulW.js";
3
- import { c as n, C as r, V as m, L as i, u as h, R as N, M as k, a as E, D as M } from "./markup-8jNhoqDe.js";
4
- import { d as I, b as _, e as j, r as A, m as B, k as W, h as z, l as K, n as G, j as H, f as J, g as Q, i as X } from "./markup-8jNhoqDe.js";
5
- import { o as S, r as u, g as l } from "./logger-Aqi9m1CF.js";
6
- import { b as Z, i as ee, d as te, e as se, f as ne, m as ae, h as re, j as oe, k as ie, a as le, s as ce, c as ue, u as he, w as me } from "./logger-Aqi9m1CF.js";
7
- import { F as R } from "./fragment-BahD_BJA.js";
8
- function U(e) {
9
- return n("div", {
10
- style: {
11
- backgroundColor: "#880000",
12
- color: "#fff",
13
- padding: "2rem",
14
- position: "fixed",
15
- inset: 0,
16
- fontSize: "20px"
17
- },
18
- children: [
19
- n("h1", { style: { marginBottom: "0.5rem" }, children: "The app has crashed" }),
20
- n("p", {
21
- style: { marginBottom: "0.25rem" },
22
- children: [
23
- n("span", {
24
- style: { fontFamily: "monospace" },
25
- children: e.loggerName
26
- }),
27
- e.tag && n("span", {
28
- style: { fontFamily: "monospace", opacity: 0.5 },
29
- children: ` [${e.tagName ? `${e.tagName}: ` : ""}${e.tag}]`
30
- }),
31
- " says:"
32
- ]
33
- }),
34
- n("blockquote", {
35
- style: {
36
- backgroundColor: "#991111",
37
- padding: "0.25em",
38
- borderRadius: "6px",
39
- fontFamily: "monospace",
40
- marginBottom: "1rem"
41
- },
42
- children: [
43
- n("span", {
44
- style: {
45
- display: "inline-block",
46
- backgroundColor: "red",
47
- padding: "0.1em 0.4em",
48
- marginRight: "0.5em",
49
- borderRadius: "4px",
50
- fontSize: "0.9em",
51
- fontWeight: "bold"
52
- },
53
- children: e.error.name
54
- }),
55
- e.error.message
56
- ]
57
- }),
58
- n("p", { children: "Please see the browser console for details." })
59
- ]
60
- });
61
- }
62
- class c {
63
- #n;
64
- #e;
65
- #r;
66
- #t;
67
- #s = !1;
68
- #o = U;
69
- #a = [];
70
- get context() {
71
- return this.#e;
72
- }
73
- constructor(t) {
74
- this.#r = t.view ?? R, this.#t = t.router, this.#e = t.context ?? new r("App");
75
- }
76
- setCrashView(t) {
77
- return this.#o = t, this;
78
- }
79
- async mount(t) {
80
- if (this.#s) return Promise.resolve();
81
- const s = this.#i(t);
82
- this.#a.push(
83
- S((a) => {
84
- this.#s && this.unmount(), new m(this.#e, this.#o, a).mount(s);
85
- })
86
- ), r.emit(this.#e, i.WILL_MOUNT), this.#t ? (this.#n = await this.#t[g](s, this.#e), this.#e.setState(w, this.#t)) : this.#n = new m(this.#e, this.#r, {}), this.#n.mount(s), this.#s = !0, r.emit(this.#e, i.DID_MOUNT);
87
- }
88
- async unmount() {
89
- if (!this.#s) return Promise.resolve();
90
- r.emit(this.#e, i.WILL_UNMOUNT), this.#s = !1, this.#n.unmount(!1), this.#t && await this.#t[y]();
91
- for (const t of this.#a)
92
- t();
93
- this.#a = [], r.emit(this.#e, i.DID_UNMOUNT);
94
- }
95
- #i(t) {
96
- if (typeof t == "string") {
97
- const s = document.querySelector(t);
98
- if (!s)
99
- throw new Error(`Selector '${t}' did not many any element.`);
100
- return s;
101
- } else {
102
- if (t instanceof Element)
103
- return t;
104
- throw new Error("Expected a selector string or DOM element.");
105
- }
106
- }
107
- }
108
- function D(e, t) {
109
- return e instanceof f ? new c({ ...t, router: e }) : b(e) === "object" ? new c({ ...t, router: d(e) }) : new c({ ...t, view: e });
110
- }
111
- const v = (e) => e;
112
- function P(e) {
113
- const t = h("For");
114
- return new N(t, u(e.each), e.key ?? v, e.children);
115
- }
116
- function p(e) {
117
- const t = h("Portal");
118
- if (x(e.into)) {
119
- if (document.querySelector(e.into) == null)
120
- throw t.crash(new Error(`Portal: selector '${e.into}' did not match any element`));
121
- } else
122
- e.into;
123
- return new k(E.Portal, {
124
- parent: e.into,
125
- content: e.children
126
- });
127
- }
128
- function q(e) {
129
- const t = h("Show"), s = e.when ? u(e.when) : null, a = e.unless ? u(e.unless) : null;
130
- return new M(t, () => {
131
- let o = !0;
132
- return s != null && a != null ? o = l(s) && !l(a) : s != null ? o = l(s) : a != null && (o = !l(a)), o ? e.children : e.fallback;
133
- });
134
- }
135
- export {
136
- P as For,
137
- k as Markup,
138
- I as MarkupNode,
139
- p as Portal,
140
- q as Show,
141
- Z as batch,
142
- D as createApp,
143
- _ as createContext,
144
- ee as createLogger,
145
- n as createMarkup,
146
- te as deepEqual,
147
- se as effect,
148
- l as get,
149
- ne as getEnv,
150
- ae as memo,
151
- S as onLoggerCrash,
152
- u as readable,
153
- j as ref,
154
- A as render,
155
- re as setEnv,
156
- oe as setLogFilter,
157
- ie as setLogLevels,
158
- le as shallowEqual,
159
- ce as signal,
160
- ue as strictEqual,
161
- he as untracked,
162
- h as useContext,
163
- B as useEffect,
164
- W as useMemo,
165
- z as useMount,
166
- K as useReducer,
167
- G as useRef,
168
- H as useSignal,
169
- J as useStore,
170
- Q as useStoreProvider,
171
- X as useUnmount,
172
- me as writable
173
- };
174
- //# sourceMappingURL=index.js.map
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./signals-CMJPGr_M.js";
2
+ import { _ as s, h as c, i as l, p as u, s as d, t as f, v as p, y as m } from "./view-cBN-hn_T.js";
3
+ import { a as h, c as g, d as _, i as v, l as y, n as b, o as x, r as S, s as C, t as w, u as T } from "./core-BLkJ-xuh.js";
4
+ export { f as ViewNode, u as addStore, o as batch, n as compose, i as createAtom, C as createDebug, t as createEffect, l as createMarkup, S as createPortal, w as createRef, _ as createRoot, v as forEach, g as getDebug, c as getStore, h as hideIf, b as html, s as onCleanup, p as onEffect, m as onMount, e as peek, d as render, y as setLogFilter, T as setLogLevel, x as showIf, r as subscribe, a as unwrap };
@@ -1,3 +1,4 @@
1
- export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): Markup<any>;
2
- export { Fragment } from "./core/views/fragment";
3
- import { Markup } from "./core/markup";
1
+ export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): import("./core/index.js").Markup<any>;
2
+ export function Fragment({ children }: {
3
+ children: any;
4
+ }): any;
@@ -1,10 +1,13 @@
1
- import { M as n } from "./markup-8jNhoqDe.js";
2
- import { F as m } from "./fragment-BahD_BJA.js";
3
- function u(e, r, t, o, a, i) {
4
- return new n(e, t != null ? { ...r, key: t } : r);
1
+ import { i as e } from "./view-cBN-hn_T.js";
2
+ //#region src/jsx-dev-runtime.js
3
+ var t = ({ children: e }) => e;
4
+ function n(t, n, r, i, a, o) {
5
+ return e(t, r == null ? n : {
6
+ ...n,
7
+ key: r
8
+ });
5
9
  }
6
- export {
7
- m as Fragment,
8
- u as jsxDEV
9
- };
10
- //# sourceMappingURL=jsx-dev-runtime.js.map
10
+ //#endregion
11
+ export { t as Fragment, n as jsxDEV };
12
+
13
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-dev-runtime.js","sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createLogger } from \"./core\";\nimport { Markup } from \"./core/markup\";\nexport { Fragment } from \"./core/views/fragment\";\n\nexport function jsxDEV(element, props, key, isStaticChildren, source, self) {\n // TODO: Take additional dev arguments and use them for better debugging.\n // console.info({ element, props, key, isStaticChildren, source, self });\n return new Markup(element, key != null ? { ...props, key } : props);\n}\n"],"names":["jsxDEV","element","props","key","isStaticChildren","source","self","Markup"],"mappings":";;AAIO,SAASA,EAAOC,GAASC,GAAOC,GAAKC,GAAkBC,GAAQC,GAAM;AAG1E,SAAO,IAAIC,EAAON,GAASE,KAAO,OAAO,EAAE,GAAGD,GAAO,KAAAC,EAAG,IAAKD,CAAK;AACpE;"}
1
+ {"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup/utils.js\";\n\nexport const Fragment = ({ children }) => children;\n\nexport function jsxDEV(element, props, key, isStaticChildren, source, self) {\n // TODO: Take additional dev arguments and use them for better debugging.\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n"],"mappings":";;AAEA,IAAa,KAAY,EAAE,kBAAe;AAE1C,SAAgB,EAAO,GAAS,GAAO,GAAK,GAAkB,GAAQ,GAAM;AAE1E,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS"}
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * JSX function for elements with dynamic children.
3
3
  */
4
- export function jsx(element: any, props: any, key: any): Markup<any>;
4
+ export function jsx(element: any, props: any, key: any): import("./core/index.js").Markup<any>;
5
5
  /**
6
6
  * JSX function for elements with static children.
7
7
  */
8
- export function jsxs(element: any, props: any, key: any): Markup<any>;
9
- export { Fragment } from "./core/views/fragment";
10
- import { Markup } from "./core/markup";
8
+ export function jsxs(element: any, props: any, key: any): import("./core/index.js").Markup<any>;
9
+ export function Fragment({ children }: {
10
+ children: any;
11
+ }): any;
@@ -1,14 +1,19 @@
1
- import { M as u } from "./markup-8jNhoqDe.js";
2
- import { F as m } from "./fragment-BahD_BJA.js";
3
- function o(t, n, r) {
4
- return new u(t, r != null ? { ...n, key: r } : n);
1
+ import { i as e } from "./view-cBN-hn_T.js";
2
+ //#region src/jsx-runtime.js
3
+ var t = ({ children: e }) => e;
4
+ function n(t, n, r) {
5
+ return e(t, r == null ? n : {
6
+ ...n,
7
+ key: r
8
+ });
5
9
  }
6
- function a(t, n, r) {
7
- return new u(t, r != null ? { ...n, key: r } : n);
10
+ function r(t, n, r) {
11
+ return e(t, r == null ? n : {
12
+ ...n,
13
+ key: r
14
+ });
8
15
  }
9
- export {
10
- m as Fragment,
11
- o as jsx,
12
- a as jsxs
13
- };
14
- //# sourceMappingURL=jsx-runtime.js.map
16
+ //#endregion
17
+ export { t as Fragment, n as jsx, r as jsxs };
18
+
19
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.js"],"sourcesContent":["import { Markup } from \"./core/markup\";\nexport { Fragment } from \"./core/views/fragment\";\n\n/**\n * JSX function for elements with dynamic children.\n */\nexport function jsx(element, props, key) {\n return new Markup(element, key != null ? { ...props, key } : props);\n}\n\n/**\n * JSX function for elements with static children.\n */\nexport function jsxs(element, props, key) {\n return new Markup(element, key != null ? { ...props, key } : props);\n}\n"],"names":["jsx","element","props","key","Markup","jsxs"],"mappings":";;AAMO,SAASA,EAAIC,GAASC,GAAOC,GAAK;AACvC,SAAO,IAAIC,EAAOH,GAASE,KAAO,OAAO,EAAE,GAAGD,GAAO,KAAAC,EAAG,IAAKD,CAAK;AACpE;AAKO,SAASG,EAAKJ,GAASC,GAAOC,GAAK;AACxC,SAAO,IAAIC,EAAOH,GAASE,KAAO,OAAO,EAAE,GAAGD,GAAO,KAAAC,EAAG,IAAKD,CAAK;AACpE;"}
1
+ {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup/utils.js\";\n\nexport const Fragment = ({ children }) => children;\n\n/**\n * JSX function for elements with dynamic children.\n */\nexport function jsx(element, props, key) {\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n\n/**\n * JSX function for elements with static children.\n */\nexport function jsxs(element, props, key) {\n return createMarkup(element, key != null ? { ...props, key } : props);\n}\n"],"mappings":";;AAEA,IAAa,KAAY,EAAE,kBAAe;AAK1C,SAAgB,EAAI,GAAS,GAAO,GAAK;AACvC,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS;;AAMvE,SAAgB,EAAK,GAAS,GAAO,GAAK;AACxC,QAAO,EAAa,GAAS,KAAO,OAA2B,IAApB;EAAE,GAAG;EAAO;EAAK,CAAS"}
@@ -1,3 +1,4 @@
1
- import { Router, type RouterOptions } from "./router.js";
2
- export declare function createRouter(options: RouterOptions): Router;
3
- export { useRouter } from "./hooks.js";
1
+ import { Context } from "../core";
2
+ export { createRouterPlugin, lazy, Outlet, RedirectError } from "./router";
3
+ export type { RouterOptions } from "./types";
4
+ export declare function getRouter(context: Context): import("./types").Router;