@bquery/bquery 1.4.0 → 1.5.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 (127) hide show
  1. package/README.md +139 -120
  2. package/dist/component/component.d.ts.map +1 -1
  3. package/dist/component/index.d.ts +2 -0
  4. package/dist/component/index.d.ts.map +1 -1
  5. package/dist/component/library.d.ts +34 -0
  6. package/dist/component/library.d.ts.map +1 -0
  7. package/dist/component/types.d.ts +10 -6
  8. package/dist/component/types.d.ts.map +1 -1
  9. package/dist/component-CY5MVoYN.js +531 -0
  10. package/dist/component-CY5MVoYN.js.map +1 -0
  11. package/dist/component.es.mjs +6 -184
  12. package/dist/config-DRmZZno3.js +40 -0
  13. package/dist/config-DRmZZno3.js.map +1 -0
  14. package/dist/core-CK2Mfpf4.js +648 -0
  15. package/dist/core-CK2Mfpf4.js.map +1 -0
  16. package/dist/core-DPdbItcq.js +112 -0
  17. package/dist/core-DPdbItcq.js.map +1 -0
  18. package/dist/core.es.mjs +45 -1261
  19. package/dist/full.d.ts +6 -6
  20. package/dist/full.d.ts.map +1 -1
  21. package/dist/full.es.mjs +98 -92
  22. package/dist/full.iife.js +173 -3
  23. package/dist/full.iife.js.map +1 -1
  24. package/dist/full.umd.js +173 -3
  25. package/dist/full.umd.js.map +1 -1
  26. package/dist/index.es.mjs +143 -139
  27. package/dist/motion/transition.d.ts +1 -1
  28. package/dist/motion/transition.d.ts.map +1 -1
  29. package/dist/motion/types.d.ts +11 -1
  30. package/dist/motion/types.d.ts.map +1 -1
  31. package/dist/motion-C5DRdPnO.js +415 -0
  32. package/dist/motion-C5DRdPnO.js.map +1 -0
  33. package/dist/motion.es.mjs +25 -361
  34. package/dist/object-qGpWr6-J.js +38 -0
  35. package/dist/object-qGpWr6-J.js.map +1 -0
  36. package/dist/platform/announcer.d.ts +59 -0
  37. package/dist/platform/announcer.d.ts.map +1 -0
  38. package/dist/platform/config.d.ts +92 -0
  39. package/dist/platform/config.d.ts.map +1 -0
  40. package/dist/platform/cookies.d.ts +45 -0
  41. package/dist/platform/cookies.d.ts.map +1 -0
  42. package/dist/platform/index.d.ts +8 -0
  43. package/dist/platform/index.d.ts.map +1 -1
  44. package/dist/platform/meta.d.ts +62 -0
  45. package/dist/platform/meta.d.ts.map +1 -0
  46. package/dist/platform-B7JhGBc7.js +361 -0
  47. package/dist/platform-B7JhGBc7.js.map +1 -0
  48. package/dist/platform.es.mjs +11 -248
  49. package/dist/reactive/async-data.d.ts +114 -0
  50. package/dist/reactive/async-data.d.ts.map +1 -0
  51. package/dist/reactive/index.d.ts +2 -2
  52. package/dist/reactive/index.d.ts.map +1 -1
  53. package/dist/reactive/signal.d.ts +2 -0
  54. package/dist/reactive/signal.d.ts.map +1 -1
  55. package/dist/reactive-BDya-ia8.js +253 -0
  56. package/dist/reactive-BDya-ia8.js.map +1 -0
  57. package/dist/reactive.es.mjs +18 -34
  58. package/dist/router-CijiICxt.js +188 -0
  59. package/dist/router-CijiICxt.js.map +1 -0
  60. package/dist/router.es.mjs +11 -200
  61. package/dist/sanitize-jyJ2ryE2.js +302 -0
  62. package/dist/sanitize-jyJ2ryE2.js.map +1 -0
  63. package/dist/security/constants.d.ts.map +1 -1
  64. package/dist/security.es.mjs +10 -56
  65. package/dist/store-CPK9E62U.js +262 -0
  66. package/dist/store-CPK9E62U.js.map +1 -0
  67. package/dist/store.es.mjs +12 -25
  68. package/dist/view-Cdi0g-qo.js +396 -0
  69. package/dist/view-Cdi0g-qo.js.map +1 -0
  70. package/dist/view.es.mjs +10 -430
  71. package/package.json +15 -11
  72. package/src/component/component.ts +319 -289
  73. package/src/component/index.ts +42 -40
  74. package/src/component/library.ts +504 -0
  75. package/src/component/types.ts +91 -85
  76. package/src/core/collection.ts +628 -628
  77. package/src/core/element.ts +774 -774
  78. package/src/core/index.ts +48 -48
  79. package/src/core/utils/function.ts +151 -151
  80. package/src/full.ts +223 -187
  81. package/src/motion/animate.ts +113 -113
  82. package/src/motion/flip.ts +176 -176
  83. package/src/motion/scroll.ts +57 -57
  84. package/src/motion/spring.ts +150 -150
  85. package/src/motion/timeline.ts +246 -246
  86. package/src/motion/transition.ts +53 -7
  87. package/src/motion/types.ts +208 -198
  88. package/src/platform/announcer.ts +208 -0
  89. package/src/platform/config.ts +163 -0
  90. package/src/platform/cookies.ts +165 -0
  91. package/src/platform/index.ts +39 -18
  92. package/src/platform/meta.ts +168 -0
  93. package/src/platform/storage.ts +215 -215
  94. package/src/reactive/async-data.ts +486 -0
  95. package/src/reactive/core.ts +114 -114
  96. package/src/reactive/effect.ts +54 -54
  97. package/src/reactive/index.ts +37 -23
  98. package/src/reactive/internals.ts +122 -122
  99. package/src/reactive/signal.ts +29 -20
  100. package/src/security/constants.ts +211 -209
  101. package/src/security/sanitize-core.ts +364 -364
  102. package/src/view/evaluate.ts +290 -290
  103. package/dist/batch-x7b2eZST.js +0 -13
  104. package/dist/batch-x7b2eZST.js.map +0 -1
  105. package/dist/component.es.mjs.map +0 -1
  106. package/dist/core-BhpuvPhy.js +0 -170
  107. package/dist/core-BhpuvPhy.js.map +0 -1
  108. package/dist/core.es.mjs.map +0 -1
  109. package/dist/full.es.mjs.map +0 -1
  110. package/dist/index.es.mjs.map +0 -1
  111. package/dist/motion.es.mjs.map +0 -1
  112. package/dist/persisted-DHoi3uEs.js +0 -278
  113. package/dist/persisted-DHoi3uEs.js.map +0 -1
  114. package/dist/platform.es.mjs.map +0 -1
  115. package/dist/reactive.es.mjs.map +0 -1
  116. package/dist/router.es.mjs.map +0 -1
  117. package/dist/sanitize-Cxvxa-DX.js +0 -283
  118. package/dist/sanitize-Cxvxa-DX.js.map +0 -1
  119. package/dist/security.es.mjs.map +0 -1
  120. package/dist/store.es.mjs.map +0 -1
  121. package/dist/type-guards-BdKlYYlS.js +0 -32
  122. package/dist/type-guards-BdKlYYlS.js.map +0 -1
  123. package/dist/untrack-DNnnqdlR.js +0 -6
  124. package/dist/untrack-DNnnqdlR.js.map +0 -1
  125. package/dist/view.es.mjs.map +0 -1
  126. package/dist/watch-DXXv3iAI.js +0 -58
  127. package/dist/watch-DXXv3iAI.js.map +0 -1
@@ -1,186 +1,8 @@
1
- import { s as h } from "./sanitize-Cxvxa-DX.js";
2
- const p = (e, r) => {
3
- const { type: s } = r;
4
- if (s === String) return e;
5
- if (s === Number)
6
- return Number(e);
7
- if (s === Boolean) {
8
- const c = e.trim().toLowerCase();
9
- return c === "" || c === "true" || c === "1" ? !0 : c === "false" || c === "0" ? !1 : !!e;
10
- }
11
- if (s === Object || s === Array)
12
- try {
13
- return JSON.parse(e);
14
- } catch {
15
- return e;
16
- }
17
- if (typeof s == "function") {
18
- const c = s, t = s;
19
- if (r.construct === !0)
20
- return Reflect.construct(t, [e]);
21
- if (r.construct === !1)
22
- return c(e);
23
- const o = s.prototype !== void 0 && s.prototype !== null, u = (o ? Object.getOwnPropertyNames(s.prototype) : []).length > 1, n = o && s.prototype.constructor !== s, l = /^class\s/.test(Function.prototype.toString.call(s));
24
- if (u || n || l)
25
- try {
26
- return Reflect.construct(t, [e]);
27
- } catch {
28
- return c(e);
29
- }
30
- try {
31
- const a = c(e);
32
- if (a === void 0 && o)
33
- try {
34
- return Reflect.construct(t, [e]);
35
- } catch {
36
- return a;
37
- }
38
- return a;
39
- } catch (a) {
40
- if (a instanceof TypeError && /cannot be invoked without 'new'|is not a function/i.test(a.message))
41
- return Reflect.construct(t, [e]);
42
- throw a;
43
- }
44
- }
45
- return e;
46
- }, d = (e, r) => {
47
- class s extends HTMLElement {
48
- constructor() {
49
- super(), this.state = { ...r.state ?? {} }, this.props = {}, this.missingRequiredProps = /* @__PURE__ */ new Set(), this.hasMounted = !1, this.attachShadow({ mode: "open" }), this.syncProps();
50
- }
51
- /**
52
- * Returns the list of attributes to observe for changes.
53
- */
54
- static get observedAttributes() {
55
- return Object.keys(r.props ?? {});
56
- }
57
- /**
58
- * Called when the element is added to the DOM.
59
- */
60
- connectedCallback() {
61
- try {
62
- if (this.missingRequiredProps.size > 0)
63
- return;
64
- this.mount();
65
- } catch (t) {
66
- this.handleError(t);
67
- }
68
- }
69
- /**
70
- * Performs the initial mount of the component.
71
- * Called when the element is connected and all required props are present.
72
- * @internal
73
- */
74
- mount() {
75
- this.hasMounted || (r.beforeMount?.call(this), r.connected?.call(this), this.render(), this.hasMounted = !0);
76
- }
77
- /**
78
- * Called when the element is removed from the DOM.
79
- */
80
- disconnectedCallback() {
81
- try {
82
- r.disconnected?.call(this);
83
- } catch (t) {
84
- this.handleError(t);
85
- }
86
- }
87
- /**
88
- * Called when an observed attribute changes.
89
- */
90
- attributeChangedCallback(t, o, i) {
91
- try {
92
- this.syncProps(), this.hasMounted ? this.render(!0) : this.isConnected && this.missingRequiredProps.size === 0 && this.mount();
93
- } catch (u) {
94
- this.handleError(u);
95
- }
96
- }
97
- /**
98
- * Handles errors during component lifecycle.
99
- * @internal
100
- */
101
- handleError(t) {
102
- r.onError ? r.onError.call(this, t) : console.error(`bQuery component error in <${e}>:`, t);
103
- }
104
- /**
105
- * Updates a state property and triggers a re-render.
106
- *
107
- * @param key - The state property key
108
- * @param value - The new value
109
- */
110
- setState(t, o) {
111
- this.state[t] = o, this.render(!0);
112
- }
113
- /**
114
- * Gets a state property value.
115
- *
116
- * @param key - The state property key
117
- * @returns The current value
118
- */
119
- getState(t) {
120
- return this.state[t];
121
- }
122
- /**
123
- * Synchronizes props from attributes.
124
- * @internal
125
- */
126
- syncProps() {
127
- const t = r.props ?? {};
128
- for (const [o, i] of Object.entries(t)) {
129
- const u = this.getAttribute(o);
130
- let n;
131
- if (u == null ? i.required && i.default === void 0 ? (this.missingRequiredProps.add(o), n = void 0) : n = i.default ?? void 0 : (this.missingRequiredProps.has(o) && this.missingRequiredProps.delete(o), n = p(u, i)), i.validator && n !== void 0 && !i.validator(n))
132
- throw new Error(
133
- `bQuery component: validation failed for prop "${o}" with value ${JSON.stringify(n)}`
134
- );
135
- this.props[o] = n;
136
- }
137
- }
138
- /**
139
- * Renders the component to its shadow root.
140
- * @internal
141
- */
142
- render(t = !1) {
143
- try {
144
- if (t && r.beforeUpdate && r.beforeUpdate.call(this, this.props) === !1)
145
- return;
146
- const o = (n, l) => {
147
- this.dispatchEvent(new CustomEvent(n, { detail: l, bubbles: !0, composed: !0 }));
148
- };
149
- if (!this.shadowRoot) return;
150
- const i = r.render({
151
- props: this.props,
152
- state: this.state,
153
- emit: o
154
- }), u = h(i);
155
- if (this.shadowRoot.innerHTML = u, r.styles) {
156
- const n = document.createElement("style");
157
- n.textContent = r.styles, this.shadowRoot.prepend(n);
158
- }
159
- t && r.updated?.call(this);
160
- } catch (o) {
161
- this.handleError(o);
162
- }
163
- }
164
- }
165
- return s;
166
- }, b = (e, r) => {
167
- const s = d(e, r);
168
- customElements.get(e) || customElements.define(e, s);
169
- }, E = (e, ...r) => e.reduce((s, c, t) => `${s}${c}${r[t] ?? ""}`, ""), g = (e, ...r) => {
170
- const s = {
171
- "&": "&amp;",
172
- "<": "&lt;",
173
- ">": "&gt;",
174
- '"': "&quot;",
175
- "'": "&#x27;",
176
- "`": "&#x60;"
177
- }, c = (t) => String(t ?? "").replace(/[&<>"'`]/g, (i) => s[i]);
178
- return e.reduce((t, o, i) => `${t}${o}${c(r[i])}`, "");
179
- };
1
+ import { a as t, i as o, n as a, r as n, t as s } from "./component-CY5MVoYN.js";
180
2
  export {
181
- b as component,
182
- d as defineComponent,
183
- E as html,
184
- g as safeHtml
3
+ o as component,
4
+ t as defineComponent,
5
+ a as html,
6
+ s as registerDefaultComponents,
7
+ n as safeHtml
185
8
  };
186
- //# sourceMappingURL=component.es.mjs.map
@@ -0,0 +1,40 @@
1
+ import { i as o, r as f } from "./object-qGpWr6-J.js";
2
+ var s = {
3
+ fetch: {
4
+ headers: {},
5
+ parseAs: "json"
6
+ },
7
+ cookies: {
8
+ path: "/",
9
+ sameSite: "Lax",
10
+ secure: !1
11
+ },
12
+ announcer: {
13
+ politeness: "polite",
14
+ atomic: !0,
15
+ delay: 16,
16
+ clearDelay: 1e3
17
+ },
18
+ pageMeta: {},
19
+ transitions: {
20
+ skipOnReducedMotion: !1,
21
+ classes: [],
22
+ types: []
23
+ },
24
+ components: { prefix: "bq" }
25
+ }, r = (e) => {
26
+ if (typeof Headers < "u" && e instanceof Headers) return new Headers(e);
27
+ if (Array.isArray(e)) return e.map((n) => r(n));
28
+ if (f(e)) {
29
+ const n = {};
30
+ for (const [a, i] of Object.entries(e)) n[a] = r(i);
31
+ return n;
32
+ }
33
+ return e;
34
+ }, t = r(s), d = (e) => (t = r(o(s, t, e)), c()), c = () => r(t);
35
+ export {
36
+ c as n,
37
+ d as t
38
+ };
39
+
40
+ //# sourceMappingURL=config-DRmZZno3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-DRmZZno3.js","names":[],"sources":["../src/platform/config.ts"],"sourcesContent":["/**\r\n * Global bQuery configuration helpers.\r\n *\r\n * @module bquery/platform\r\n */\r\n\r\nimport { isPlainObject, merge } from '../core/utils/object';\r\n\r\n/** Supported response parsing strategies for fetch composables. */\r\nexport type BqueryFetchParseAs = 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData' | 'response';\r\n\r\n/** Global fetch defaults used by useFetch(). */\r\nexport interface BqueryFetchConfig {\r\n /** Optional base URL prepended to relative request URLs. */\r\n baseUrl?: string;\r\n /** Default request headers. */\r\n headers?: HeadersInit;\r\n /** Default response parser. */\r\n parseAs?: BqueryFetchParseAs;\r\n}\r\n\r\n/** Global cookie defaults used by useCookie(). */\r\nexport interface BqueryCookieConfig {\r\n /** Default cookie path. */\r\n path?: string;\r\n /** Default SameSite mode. */\r\n sameSite?: 'Strict' | 'Lax' | 'None';\r\n /** Whether cookies should be marked secure by default. */\r\n secure?: boolean;\r\n}\r\n\r\n/** Global announcer defaults used by useAnnouncer(). */\r\nexport interface BqueryAnnouncerConfig {\r\n /** Default politeness level. */\r\n politeness?: 'polite' | 'assertive';\r\n /** Whether announcements should be treated atomically. */\r\n atomic?: boolean;\r\n /** Delay before writing the message into the live region. */\r\n delay?: number;\r\n /** Delay after which the live region is cleared automatically. */\r\n clearDelay?: number;\r\n}\r\n\r\n/** Global page meta defaults used by definePageMeta(). */\r\nexport interface BqueryPageMetaConfig {\r\n /** Optional title template function. */\r\n titleTemplate?: (title: string) => string;\r\n}\r\n\r\n/** Global motion defaults used by transition(). */\r\nexport interface BqueryTransitionConfig {\r\n /** Skip transitions when reduced motion is preferred. */\r\n skipOnReducedMotion?: boolean;\r\n /** Classes applied to the root element during transitions. */\r\n classes?: string[];\r\n /** Transition type identifiers added when supported by the browser. */\r\n types?: string[];\r\n}\r\n\r\n/** Global default component library configuration. */\r\nexport interface BqueryComponentLibraryConfig {\r\n /** Prefix used by registerDefaultComponents(). */\r\n prefix?: string;\r\n}\r\n\r\n/** Complete global bQuery configuration object. */\r\nexport interface BqueryConfig {\r\n /** Fetch composable defaults. */\r\n fetch?: BqueryFetchConfig;\r\n /** Cookie composable defaults. */\r\n cookies?: BqueryCookieConfig;\r\n /** Announcer composable defaults. */\r\n announcer?: BqueryAnnouncerConfig;\r\n /** Page metadata defaults. */\r\n pageMeta?: BqueryPageMetaConfig;\r\n /** View transition defaults. */\r\n transitions?: BqueryTransitionConfig;\r\n /** Default component library options. */\r\n components?: BqueryComponentLibraryConfig;\r\n}\r\n\r\nconst defaultConfig: BqueryConfig = {\r\n fetch: {\r\n headers: {},\r\n parseAs: 'json',\r\n },\r\n cookies: {\r\n path: '/',\r\n sameSite: 'Lax',\r\n secure: false,\r\n },\r\n announcer: {\r\n politeness: 'polite',\r\n atomic: true,\r\n delay: 16,\r\n clearDelay: 1000,\r\n },\r\n pageMeta: {},\r\n transitions: {\r\n skipOnReducedMotion: false,\r\n classes: [],\r\n types: [],\r\n },\r\n components: {\r\n prefix: 'bq',\r\n },\r\n};\r\n\r\nconst cloneConfigValue = <T>(value: T): T => {\r\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\r\n return new Headers(value) as T;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n return value.map((entry) => cloneConfigValue(entry)) as T;\r\n }\r\n\r\n if (isPlainObject(value)) {\r\n const result: Record<string, unknown> = {};\r\n for (const [key, entry] of Object.entries(value)) {\r\n result[key] = cloneConfigValue(entry);\r\n }\r\n return result as T;\r\n }\r\n\r\n return value;\r\n};\r\n\r\nlet currentConfig: BqueryConfig = cloneConfigValue(defaultConfig);\r\n\r\n/**\r\n * Define or extend the global bQuery configuration.\r\n *\r\n * @param config - Partial configuration values to merge into the current config\r\n * @returns The resolved configuration after merging\r\n *\r\n * @example\r\n * ```ts\r\n * defineBqueryConfig({\r\n * fetch: { baseUrl: 'https://api.example.com' },\r\n * components: { prefix: 'ui' },\r\n * });\r\n * ```\r\n */\r\nexport const defineBqueryConfig = (config: BqueryConfig): BqueryConfig => {\r\n currentConfig = cloneConfigValue(\r\n merge(\r\n defaultConfig as Record<string, unknown>,\r\n currentConfig as Record<string, unknown>,\r\n config as Record<string, unknown>\r\n ) as BqueryConfig\r\n );\r\n return getBqueryConfig();\r\n};\r\n\r\n/**\r\n * Get the currently resolved bQuery configuration.\r\n *\r\n * @returns A cloned snapshot of the active configuration\r\n */\r\nexport const getBqueryConfig = (): BqueryConfig => {\r\n return cloneConfigValue(currentConfig);\r\n};\r\n"],"mappings":";AAiFA,IAAM,IAA8B;AAAA,EAClC,OAAO;AAAA,IACL,SAAS,CAAA;AAAA,IACT,SAAS;AAAA;EAEX,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA;EAEV,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA;EAEd,UAAU,CAAA;AAAA,EACV,aAAa;AAAA,IACX,qBAAqB;AAAA,IACrB,SAAS,CAAA;AAAA,IACT,OAAO,CAAA;AAAA;EAET,YAAY,EACV,QAAQ,KAAA;GAIN,IAAA,CAAuB,MAAgB;AAC3C,MAAI,OAAO,UAAY,OAAe,aAAiB,QACrD,QAAO,IAAI,QAAQ,CAAA;AAGrB,MAAI,MAAM,QAAQ,CAAA,EAChB,QAAO,EAAM,IAAA,CAAK,MAAU,EAAiB,CAAA,CAAM;AAGrD,MAAI,EAAc,CAAA,GAAQ;AACxB,UAAM,IAAkC,CAAA;AACxC,eAAW,CAAC,GAAK,CAAA,KAAU,OAAO,QAAQ,CAAA,EACxC,CAAA,EAAO,CAAA,IAAO,EAAiB,CAAA;AAEjC,WAAO;AAAA;AAGT,SAAO;GAGL,IAA8B,EAAiB,CAAA,GAgBtC,IAAA,CAAsB,OACjC,IAAgB,EACd,EACE,GACA,GACA,CAAA,CACD,GAEI,EAAA,IAQI,IAAA,MACJ,EAAiB,CAAA"}