jq79 0.4.16 → 0.4.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jq79",
3
- "version": "0.4.16",
3
+ "version": "0.4.17",
4
4
  "description": "Mini reactive component library: single-file components, Svelte-style setup scripts, fine-grained proxy reactivity. Single-file build, zero dependencies.",
5
5
  "keywords": [
6
6
  "reactive",
package/src/jq79.ts CHANGED
@@ -7,6 +7,14 @@ import { transformSetupScript, transformFactoryScript, parsePropsPattern, parseF
7
7
 
8
8
  export { $, $$, $create } from "./dom"
9
9
  export { $reactive } from "./reactive"
10
+
11
+ // the package version, substituted at build time (tsup/vitest `define`, read
12
+ // from package.json - releases bump it there and nowhere else). The typeof
13
+ // guard is what keeps the raw source runnable: tests and any bundler that
14
+ // doesn't define it see a bare identifier, not a ReferenceError
15
+ declare const __JQ79_VERSION__: string
16
+ const VERSION = typeof __JQ79_VERSION__ === "string" ? __JQ79_VERSION__ : "0.0.0-dev"
17
+
10
18
  type TemplateNode = {
11
19
  tag: string
12
20
  attrs: Record<string, string>
@@ -1775,6 +1783,10 @@ const fetchComponent = async (url: string): Promise<Component79> => {
1775
1783
  // jq79.detach() // detach, keeping state - mount() re-attaches
1776
1784
  // .destroy() // dispose effects and remove styles
1777
1785
  export class Component79 {
1786
+ // the version of jq79 this class came from, so a page can tell which build it
1787
+ // loaded (a CDN <script> pins nothing on its own)
1788
+ static readonly version: string = VERSION
1789
+
1778
1790
  template: TemplateNode[]
1779
1791
  scripts: TagBlock[]
1780
1792
  styles: TagBlock[]