@manyducks.co/dolla 2.0.0 → 3.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/README.md +133 -284
- package/dist/context-B5blupD2.js +363 -0
- package/dist/context-B5blupD2.js.map +1 -0
- package/dist/core/context.d.ts +29 -144
- package/dist/core/debug.d.ts +19 -0
- package/dist/core/index.d.ts +15 -16
- package/dist/core/markup/helpers.d.ts +34 -0
- package/dist/core/markup/html.d.ts +3 -0
- package/dist/core/{nodes → markup/nodes}/dom.d.ts +5 -4
- package/dist/core/markup/nodes/dynamic.d.ts +16 -0
- package/dist/core/markup/nodes/element.d.ts +14 -0
- package/dist/core/markup/nodes/portal.d.ts +15 -0
- package/dist/core/markup/nodes/repeat.d.ts +21 -0
- package/dist/core/markup/nodes/view.d.ts +17 -0
- package/dist/core/markup/scheduler.d.ts +1 -0
- package/dist/core/markup/types.d.ts +62 -0
- package/dist/core/markup/utils.d.ts +22 -0
- package/dist/core/ref.d.ts +6 -12
- package/dist/core/root.d.ts +36 -0
- package/dist/core/signals.d.ts +46 -76
- package/dist/core/symbols.d.ts +2 -0
- package/dist/core-JHktdqjt.js +242 -0
- package/dist/core-JHktdqjt.js.map +1 -0
- package/dist/http/index.d.ts +21 -33
- package/dist/http.js +89 -149
- package/dist/http.js.map +1 -1
- package/dist/index.js +4 -174
- package/dist/jsx-dev-runtime.d.ts +4 -3
- package/dist/jsx-dev-runtime.js +12 -9
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +5 -4
- package/dist/jsx-runtime.js +17 -12
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/router/index.d.ts +4 -3
- package/dist/router/router.d.ts +19 -162
- package/dist/router/store.d.ts +12 -0
- package/dist/router/types.d.ts +152 -0
- package/dist/router/utils.d.ts +99 -0
- package/dist/router/utils.test.d.ts +1 -0
- package/dist/router.js +428 -5
- package/dist/router.js.map +1 -1
- package/dist/signals-CMJPGr_M.js +354 -0
- package/dist/signals-CMJPGr_M.js.map +1 -0
- package/dist/translate/index.d.ts +82 -0
- package/dist/translate.js +125 -0
- package/dist/translate.js.map +1 -0
- package/dist/types.d.ts +21 -39
- package/dist/utils.d.ts +41 -29
- package/dist/utils.test.d.ts +1 -0
- package/dist/virtual/index.d.ts +1 -0
- package/dist/virtual/list.d.ts +53 -0
- package/package.json +19 -16
- package/dist/core/app.d.ts +0 -24
- package/dist/core/env.d.ts +0 -3
- package/dist/core/hooks.d.ts +0 -70
- package/dist/core/logger.d.ts +0 -42
- package/dist/core/logger.test.d.ts +0 -0
- package/dist/core/markup.d.ts +0 -82
- package/dist/core/markup.test.d.ts +0 -0
- package/dist/core/nodes/_markup.d.ts +0 -36
- package/dist/core/nodes/dynamic.d.ts +0 -22
- package/dist/core/nodes/element.d.ts +0 -27
- package/dist/core/nodes/portal.d.ts +0 -18
- package/dist/core/nodes/repeat.d.ts +0 -27
- package/dist/core/nodes/view.d.ts +0 -25
- package/dist/core/views/default-crash-view.d.ts +0 -25
- package/dist/core/views/for.d.ts +0 -21
- package/dist/core/views/fragment.d.ts +0 -7
- package/dist/core/views/portal.d.ts +0 -16
- package/dist/core/views/show.d.ts +0 -25
- package/dist/fragment-BahD_BJA.js +0 -7
- package/dist/fragment-BahD_BJA.js.map +0 -1
- package/dist/i18n/index.d.ts +0 -134
- package/dist/i18n.js +0 -309
- package/dist/i18n.js.map +0 -1
- package/dist/index-DRJlxs-Q.js +0 -535
- package/dist/index-DRJlxs-Q.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger-Aqi9m1CF.js +0 -565
- package/dist/logger-Aqi9m1CF.js.map +0 -1
- package/dist/markup-8jNhoqDe.js +0 -1089
- package/dist/markup-8jNhoqDe.js.map +0 -1
- package/dist/router/hooks.d.ts +0 -2
- package/dist/router/router.utils.d.ts +0 -93
- package/dist/typeChecking-5kmX0ulW.js +0 -65
- package/dist/typeChecking-5kmX0ulW.js.map +0 -1
- package/dist/typeChecking.d.ts +0 -95
- package/docs/buildless.md +0 -132
- package/docs/components.md +0 -238
- package/docs/hooks.md +0 -356
- package/docs/http.md +0 -178
- package/docs/i18n.md +0 -220
- package/docs/index.md +0 -10
- package/docs/markup.md +0 -136
- package/docs/mixins.md +0 -176
- package/docs/ref.md +0 -77
- package/docs/router.md +0 -281
- package/docs/setup.md +0 -137
- package/docs/signals.md +0 -262
- package/docs/stores.md +0 -113
- package/docs/views.md +0 -356
- package/notes/atomic.md +0 -452
- package/notes/elimination.md +0 -33
- package/notes/observable.md +0 -180
- package/notes/scratch.md +0 -565
- package/notes/splitting.md +0 -5
- package/notes/views.md +0 -195
- package/vite.config.js +0 -22
- /package/dist/core/{hooks.test.d.ts → markup/html.test.d.ts} +0 -0
- /package/dist/core/{ref.test.d.ts → markup/utils.test.d.ts} +0 -0
- /package/dist/router/{router.utils.test.d.ts → matcher.test.d.ts} +0 -0
- /package/dist/{typeChecking.test.d.ts → router/router.test.d.ts} +0 -0
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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ACrB,MAAMC,EAAA,GACC,KAAK,UACb;AAAA,MACL;AAEA,YAAMH,IAAM;AAAA,IACd;AACE,YAAM,KAAK,SAAA;AAGb,QAAI,KAAK,UAAW,SAAS,OAAO,KAAK,UAAW,UAAU;AAC5D,YAAM,IAAId,EAAkB,KAAK,SAAU;AAG7C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,MAAc,WAAW;AACvB,QAAIkB;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\n if (!fetched.ok) throw new HTTPResponseError(response);\n return response;\n };\n\n return dispatch(0);\n }\n}\n"],"mappings":";AA8BA,IAAa,IAAb,cAAuC,MAAM;CAC3C;CAEA,YAAY,GAA6B;AAIvC,EAHA,MACE,GAAG,EAAS,OAAO,GAAG,EAAS,WAAW,oBAAoB,EAAS,OAAO,aAAa,CAAC,GAAG,EAAS,IAAI,UAAU,CAAC,GACxH,EACD,KAAK,WAAW;;GAOP,IAAb,MAAkB;CAChB,KAAgC,EAAE;CAClC,KACE,OAAO,SAAW,OAAe,OAAO,QACpC,OAAO,MAAM,KAAK,OAAO,GACzB,OAAO,SAAW,OAAe,OAAO,QACtC,OAAO,MAAM,KAAK,OAAO,GACzB;CAER,cAAc;AACZ,MAAI,CAAC,MAAA,EAAa,OAAU,MAAM,gDAAgD;;CAGpF,IAAI,GAAoB;AAEtB,SADA,MAAA,EAAiB,KAAK,EAAG,QACZ;AACX,SAAA,IAAmB,MAAA,EAAiB,QAAQ,MAAM,MAAM,EAAG;;;CAI/D,MAAM,IAAuB,GAAa,GAA0C;AAClF,SAAO,MAAA,EAA8B,OAAO,GAAK,EAAQ;;CAE3D,MAAM,IAA0C,GAAa,GAA4C;AACvG,SAAO,MAAA,EAAgC,OAAO,GAAK,EAAQ;;CAE7D,MAAM,MAA4C,GAAa,GAA4C;AACzG,SAAO,MAAA,EAAgC,SAAS,GAAK,EAAQ;;CAE/D,MAAM,KAA2C,GAAa,GAA4C;AACxG,SAAO,MAAA,EAAgC,QAAQ,GAAK,EAAQ;;CAE9D,MAAM,OAA0B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,MAAA,EAAiB;AAC5B,OAAI,GAAI;IACN,IAAI;AAKJ,WAJA,MAAM,EAAG,GAAK,aACZ,IAAM,MAAM,EAAS,IAAI,EAAE,EACpB,GACP,EACK;;GAIT,IAAM,IAAU,MAAM,MAAA,EAAa,EAAI,IAAI,UAAU,EAAE;IACrD,QAAQ,EAAI;IACZ,SAAS,EAAI;IACb,MAAM,EAAI;IACV,QAAQ,EAAI;IACb,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 {
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
|
|
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, a as c, c as l, d as u, i as d, l as f, m as p, r as m, s as h, t as g } from "./context-B5blupD2.js";
|
|
3
|
+
import { a as _, c as v, d as y, i as b, l as x, n as S, o as C, r as w, s as T, t as E, u as D } from "./core-JHktdqjt.js";
|
|
4
|
+
export { u as ViewNode, g as addStore, o as batch, n as compose, i as createAtom, T as createDebug, t as createEffect, p as createMarkup, w as createPortal, E as createRef, y as createRoot, b as forEach, v as getDebug, m as getNearestViewNode, d as getRootElement, c as getStore, _ as hideIf, S as html, h as onCleanup, l as onEffect, f as onMount, e as peek, s as render, x as setLogFilter, D as setLogLevel, C 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
|
|
3
|
-
|
|
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;
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { m as e } from "./context-B5blupD2.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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
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"}
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -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
|
|
10
|
-
|
|
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;
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { m as e } from "./context-B5blupD2.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
|
|
7
|
-
|
|
10
|
+
function r(t, n, r) {
|
|
11
|
+
return e(t, r == null ? n : {
|
|
12
|
+
...n,
|
|
13
|
+
key: r
|
|
14
|
+
});
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.js"],"sourcesContent":["import {
|
|
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"}
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
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;
|
package/dist/router/router.d.ts
CHANGED
|
@@ -1,166 +1,23 @@
|
|
|
1
1
|
import { Context } from "../core/context.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
export type Stringable = {
|
|
6
|
-
toString(): string;
|
|
7
|
-
};
|
|
8
|
-
export interface Match {
|
|
9
|
-
/**
|
|
10
|
-
* The path as it appears in the URL bar.
|
|
11
|
-
*/
|
|
12
|
-
path: string;
|
|
13
|
-
/**
|
|
14
|
-
* The pattern that this path was matched with.
|
|
15
|
-
*/
|
|
16
|
-
pattern: string;
|
|
17
|
-
/**
|
|
18
|
-
* Named route params parsed from `path`.
|
|
19
|
-
*/
|
|
20
|
-
params: Record<string, string>;
|
|
21
|
-
/**
|
|
22
|
-
* Query params parsed from `path`.
|
|
23
|
-
*/
|
|
24
|
-
query: Record<string, string>;
|
|
25
|
-
/**
|
|
26
|
-
* Freeform data you wish to store with this route.
|
|
27
|
-
* Merged `data` from all matched layers are available from `router.$match()`.
|
|
28
|
-
*/
|
|
29
|
-
data: Record<string, any>;
|
|
30
|
-
}
|
|
31
|
-
export interface RouteMatchContext extends Match {
|
|
32
|
-
/**
|
|
33
|
-
* Stores `value` at `key` in this context's state.
|
|
34
|
-
*/
|
|
35
|
-
setState<T>(key: any, value: T): void;
|
|
36
|
-
/**
|
|
37
|
-
* For each tuple in `entries`, stores `value` at `key` in this context's state.
|
|
38
|
-
*/
|
|
39
|
-
setState(entries: [key: any, value: any][]): void;
|
|
40
|
-
/**
|
|
41
|
-
* Redirects the user to a different route instead of matching the current one.
|
|
42
|
-
*/
|
|
43
|
-
redirect(path: string): void;
|
|
44
|
-
}
|
|
45
|
-
export interface Route {
|
|
46
|
-
/**
|
|
47
|
-
* The path or path fragment to match.
|
|
48
|
-
*/
|
|
49
|
-
path: string;
|
|
50
|
-
/**
|
|
51
|
-
* Path to redirect to when this route is matched, or a callback function that returns such path.
|
|
52
|
-
*/
|
|
53
|
-
redirect?: string | ((ctx: RouteRedirectContext) => string) | ((ctx: RouteRedirectContext) => Promise<string>);
|
|
54
|
-
/**
|
|
55
|
-
* View to display when this route is matched.
|
|
56
|
-
*/
|
|
57
|
-
view?: View<any>;
|
|
58
|
-
/**
|
|
59
|
-
* Subroutes.
|
|
60
|
-
*/
|
|
61
|
-
routes?: Route[];
|
|
62
|
-
/**
|
|
63
|
-
* Called after the match is identified but before it is acted on. Use this to set state, load data, etc.
|
|
64
|
-
*/
|
|
65
|
-
beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Arbitrary data you'd like to store on this route.
|
|
68
|
-
* This object will be available at `router.$match` while the route is active.
|
|
69
|
-
*
|
|
70
|
-
* In the case of nested routes, data from all layers will be merged into a single data object.
|
|
71
|
-
*/
|
|
72
|
-
data?: Record<string, any>;
|
|
73
|
-
}
|
|
74
|
-
export interface RouteMeta {
|
|
75
|
-
redirect?: string | ((ctx: RouteRedirectContext) => string) | ((ctx: RouteRedirectContext) => Promise<string>);
|
|
76
|
-
pattern?: string;
|
|
77
|
-
layers?: RouteLayer[];
|
|
78
|
-
beforeMatch?: {
|
|
79
|
-
fn: (ctx: RouteMatchContext) => void | Promise<void>;
|
|
80
|
-
layerId: number;
|
|
81
|
-
}[];
|
|
82
|
-
data?: Record<string, any>;
|
|
83
|
-
}
|
|
84
|
-
export interface RouteConfig {
|
|
85
|
-
pattern: string;
|
|
86
|
-
meta: RouteMeta;
|
|
87
|
-
}
|
|
88
|
-
export interface RouteLayer {
|
|
89
|
-
id: number;
|
|
90
|
-
view: View<{}>;
|
|
91
|
-
}
|
|
2
|
+
import { DollaPlugin } from "../core/index.js";
|
|
3
|
+
import { DynamicNode } from "../core/markup/nodes/dynamic.js";
|
|
4
|
+
import type { LazyLoader, LazyView, RouterOptions } from "./types.js";
|
|
92
5
|
/**
|
|
93
|
-
*
|
|
6
|
+
* Lazy loads a view when its route is first matched.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* {
|
|
10
|
+
* path: "/users",
|
|
11
|
+
* view: lazy(() => import("./views/users.js"))
|
|
12
|
+
* }
|
|
94
13
|
*/
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* Preserve existing query params (if any) when navigating. Defaults to false.
|
|
105
|
-
* If true, all existing query params are preserved and merged with new ones.
|
|
106
|
-
* If an array of strings is passed only those keys will be preserved, then merged with any new ones.
|
|
107
|
-
*/
|
|
108
|
-
preserveQuery?: boolean | string[];
|
|
109
|
-
}
|
|
110
|
-
export interface RouterOptions {
|
|
111
|
-
routes: Route[];
|
|
112
|
-
/**
|
|
113
|
-
* When true, the router will construct routes like "https://www.example.com/#/sub/route" which work without any backend intervention.
|
|
114
|
-
*/
|
|
115
|
-
hash?: boolean;
|
|
116
|
-
}
|
|
117
|
-
export declare const ROUTER: unique symbol;
|
|
118
|
-
export declare const MOUNT: unique symbol;
|
|
119
|
-
export declare const UNMOUNT: unique symbol;
|
|
120
|
-
export declare const ROOT_VIEW: unique symbol;
|
|
121
|
-
export declare class Router {
|
|
122
|
-
#private;
|
|
123
|
-
/**
|
|
124
|
-
* The current match object.
|
|
125
|
-
*/
|
|
126
|
-
readonly $match: Signal<Match | undefined>;
|
|
127
|
-
/**
|
|
128
|
-
* The currently matched route pattern, if any.
|
|
129
|
-
*/
|
|
130
|
-
readonly $pattern: Signal<string | undefined>;
|
|
131
|
-
/**
|
|
132
|
-
* The current URL path.
|
|
133
|
-
*/
|
|
134
|
-
readonly $path: Signal<string>;
|
|
135
|
-
/**
|
|
136
|
-
* The current named path params.
|
|
137
|
-
*/
|
|
138
|
-
readonly $params: Signal<Record<string, string>>;
|
|
139
|
-
/**
|
|
140
|
-
* The current query params.
|
|
141
|
-
*/
|
|
142
|
-
readonly $query: Signal<Record<string, string>>;
|
|
143
|
-
constructor(options: RouterOptions);
|
|
144
|
-
[MOUNT](parent: Element, context: Context): Promise<MarkupNode>;
|
|
145
|
-
[UNMOUNT](): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
148
|
-
*/
|
|
149
|
-
back(steps?: number): void;
|
|
150
|
-
/**
|
|
151
|
-
* Navigate forward. Pass a number of steps to hit the forward button that many times.
|
|
152
|
-
*/
|
|
153
|
-
forward(steps?: number): void;
|
|
154
|
-
/**
|
|
155
|
-
* Navigates to another route.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* router.go("/login"); // navigate to `/login`
|
|
159
|
-
* router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
160
|
-
*/
|
|
161
|
-
go(path: Stringable | Stringable[], options?: NavigateOptions): void;
|
|
162
|
-
/**
|
|
163
|
-
* Updates query params, keeping existing ones and applying new ones. Removes the query param if value is set to `null`.
|
|
164
|
-
*/
|
|
165
|
-
updateQuery(values: Record<string, Stringable | null>): void;
|
|
14
|
+
export declare function lazy(load: LazyLoader): LazyView;
|
|
15
|
+
export declare function createRouterPlugin(options: RouterOptions): DollaPlugin;
|
|
16
|
+
/**
|
|
17
|
+
* Displays the router's content.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Outlet(this: Context): DynamicNode;
|
|
20
|
+
export declare class RedirectError extends Error {
|
|
21
|
+
redirectPath: string;
|
|
22
|
+
constructor(redirectPath: string);
|
|
166
23
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Context, type Getter, type Setter } from "../core";
|
|
2
|
+
import type { Router } from "./types";
|
|
3
|
+
import { type HistoryAdapter, type Match } from "./utils";
|
|
4
|
+
export interface RouterStoreProps {
|
|
5
|
+
currentMatch: Getter<Match>;
|
|
6
|
+
setCurrentMatch: Setter<Match>;
|
|
7
|
+
progress: Getter<number>;
|
|
8
|
+
history: HistoryAdapter;
|
|
9
|
+
updateRoute: () => void;
|
|
10
|
+
guards: Set<() => boolean | Promise<boolean>>;
|
|
11
|
+
}
|
|
12
|
+
export declare function RouterStore(this: Context, { currentMatch, setCurrentMatch, progress, history, updateRoute, guards }: RouterStoreProps): Router;
|