@barqjs/compiler 0.2.0-next.0 → 0.2.0-next.1

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/docs/README.md CHANGED
@@ -8,7 +8,6 @@ exists and how to silence it.
8
8
  - [BARQ002](BARQ002.md), warning: An accessor is used as a condition, which is always true.
9
9
  - [BARQ003](BARQ003.md), warning: A property is read from an accessor instead of from its value.
10
10
  - [BARQ004](BARQ004.md), note: A `<For>` row reads a field once, which goes stale if `each` holds store objects.
11
- - [BARQ005](BARQ005.md), warning: A destructured prop is used as a value, or called where it may not be a function.
12
11
  - [BARQ008](BARQ008.md), warning: A `barq-ignore-next-line` comment silences nothing on the next line.
13
12
  - [BARQ009](BARQ009.md), warning: A `barq-ignore-next-line` comment is malformed and silences nothing.
14
13
  - [BARQ010](BARQ010.md), warning: JSX is passed to a prop the component reads as a value, which throws.
@@ -31,21 +30,28 @@ exists and how to silence it.
31
30
  - [BARQ027](BARQ027.md), error: A `bind:` or a form `action` is written for a custom renderer.
32
31
  - [BARQ028](BARQ028.md), error: A module compiled for a custom renderer is also asked for `ssr`, `hydratable` or `interp`.
33
32
  - [BARQ029](BARQ029.md), warning: Two renderers claim the same intrinsic tag.
33
+ - [BARQ030](BARQ030.md), error: A prop is assigned, and props are read-only.
34
+ - [BARQ031](BARQ031.md), error: A props pattern binds a name that cannot be kept reactive.
35
+ - [BARQ032](BARQ032.md), warning: A shorthand that cannot be split is merged with one of its longhands.
36
+ - [BARQ033](BARQ033.md), note: Two conditions on one property are written in the order the stylesheet reverses.
37
+ - [BARQ034](BARQ034.md), error: A tag names a prop whose default is a string, which is not a component.
34
38
 
35
39
  When each code is reported:
36
40
 
37
- - BARQ001, BARQ002, BARQ003, BARQ005, BARQ011 and BARQ018 to BARQ021: when the
41
+ - BARQ001, BARQ002, BARQ003, BARQ011 and BARQ018 to BARQ021: when the
38
42
  `diagnostics` option is on. It defaults to on in development builds, and
39
43
  `barq({ compiler: { diagnostics: true } })` runs them in a production build.
40
44
  - BARQ004 and BARQ010: in development builds only.
41
- - BARQ012 to BARQ017 and BARQ022 to BARQ029: in every build, so they can fail CI.
45
+ - BARQ012 to BARQ017 and BARQ022 to BARQ034: in every build, so they can fail CI.
42
46
  BARQ013 also needs the route table, which file-based routing provides.
43
47
  - BARQ008 and BARQ009: in every build, about your own suppression comments.
44
48
 
45
- [BARQ006](BARQ006.md) and BARQ007 were removed and are not reported. BARQ006 has a page
46
- because a suppression comment may still name it. BARQ007 announced a fallback from the
47
- server renderer to the DOM renderer, and there is no such fallback any more. A comment
48
- that names either code is reported as [BARQ009](BARQ009.md).
49
+ [BARQ005](BARQ005.md), [BARQ006](BARQ006.md) and BARQ007 were removed and are not
50
+ reported. BARQ005 and BARQ006 have a page because a suppression comment may still name
51
+ them. BARQ005 warned about a destructured prop used as a value, which is correct code now
52
+ that destructuring props is supported. BARQ007 announced a fallback from the server
53
+ renderer to the DOM renderer, and there is no such fallback any more. A comment that names
54
+ any of the three is reported as [BARQ009](BARQ009.md).
49
55
 
50
56
  ## Codes are stable
51
57
 
@@ -116,12 +122,14 @@ The checks report only what they can prove from one file, so silence is not a gu
116
122
  - **Files without JSX.** The accessor and props rules run on `.jsx` and `.tsx` files.
117
123
  - **A reassigned name.** A `let` that is assigned again is not treated as an
118
124
  accessor.
119
- - **A component only ever passed as a value.** BARQ005 needs to know that a function is
120
- a component, which it learns from a JSX tag, an export, or a route option such as
121
- `component`. A function that is only passed to another function is not reported.
122
- - **A prop's value.** Every prop is a function you call, whether or not the caller passes
123
- anything that changes, so BARQ018 counts a prop only where the same file renders the
124
- component with a value that changes.
125
+ - **A function that is not a component.** BARQ030 and BARQ031 are about a component's
126
+ props, and a component is a function with a capitalised name that holds JSX or is
127
+ written as a tag, a default export that holds JSX, or a function written inline at a
128
+ route option such as `component`. A function with a lowercase name is not one, so its
129
+ parameter is not reported.
130
+ - **A prop's value.** Every prop can change as far as the component can tell, whether or
131
+ not the caller passes anything that changes, so BARQ018 counts a prop only where the
132
+ same file renders the component with a value that changes.
125
133
  - **A helper function.** BARQ019 sees a write written in the component body or in the
126
134
  computation itself, not one inside a function the body calls.
127
135
  - **A row whose `keyed` is not written out.** With `<For keyed={KEYED}>` or
package/index.d.ts CHANGED
@@ -19,6 +19,22 @@ export interface BoundaryEntry {
19
19
 
20
20
  export declare function diagnosticCodes(): Array<JsCode>
21
21
 
22
+ export declare function gatherAtoms(sheets: Array<string>): GatheredAtoms
23
+
24
+ /**
25
+ * Every atom of a build's stylesheets in one sheet, each written once and in
26
+ * one tier order, and the sheets without them.
27
+ *
28
+ * The bundler's stylesheets are per chunk and the tier order is per sheet, so
29
+ * an atom two chunks share is written twice and the later copy can win a pair
30
+ * the order was meant to settle. `sheets[i]` of the result is `sheets[i]` of
31
+ * the input with its atoms removed; `atoms` goes where every page loads it.
32
+ */
33
+ export interface GatheredAtoms {
34
+ atoms: string
35
+ sheets: Array<string>
36
+ }
37
+
22
38
  /**
23
39
  * One entry of `intrinsics`: lowercase tags a renderer claims, so a JSX tree
24
40
  * rooted at one of them builds through that renderer wherever it is written.
@@ -76,6 +92,21 @@ export interface JsDiagnostic {
76
92
  end: number
77
93
  /** path of the docs page for this code, relative to the package root */
78
94
  docs?: string
95
+ /**
96
+ * The edits that repair it, when the repair is one spelling: apply every
97
+ * one, last first, and the finding is gone.
98
+ */
99
+ fix?: Array<JsEdit>
100
+ }
101
+
102
+ /**
103
+ * One replacement in the original source. `pos` and `end` are UTF-16 offsets,
104
+ * and equal for an insertion.
105
+ */
106
+ export interface JsEdit {
107
+ pos: number
108
+ end: number
109
+ text: string
79
110
  }
80
111
 
81
112
  /** A dev-mode label: which JSX, in which component, produced a hoisted template. */
@@ -403,6 +434,16 @@ export interface TransformOptions {
403
434
  */
404
435
  serverFns?: boolean
405
436
  dev?: boolean
437
+ /**
438
+ * Carry names and positions from the source into the output, for the
439
+ * runtime's development findings: a signal, memo, effect or store is named
440
+ * after the binding it is declared as, a binding effect after the element
441
+ * and attribute it writes, and each of them and every component call
442
+ * carries `file:line:col`, the file relative to `root`. Positions need a
443
+ * `filename`.
444
+ * @default the value of `dev`
445
+ */
446
+ sourceNames?: boolean
406
447
  templates?: boolean
407
448
  ssr?: boolean
408
449
  /**
@@ -414,7 +455,7 @@ export interface TransformOptions {
414
455
  */
415
456
  interp?: boolean
416
457
  /**
417
- * Run the source-level diagnostic rules (D1, D3). Defaults to `dev`: they
458
+ * Run the source-level diagnostic rules (D1). Defaults to `dev`: they
418
459
  * are advice about reactivity, they are delivered through the dev channels,
419
460
  * and a production build should not pay for analysis nobody reads. Set it
420
461
  * explicitly to run them in CI.
package/index.js CHANGED
@@ -80,6 +80,7 @@ const binding = load();
80
80
  // exports by scanning for this shape, so `import { transform }` needs it.
81
81
 
82
82
  module.exports.diagnosticCodes = binding.diagnosticCodes;
83
+ module.exports.gatherAtoms = binding.gatherAtoms;
83
84
  module.exports.layerOrder = binding.layerOrder;
84
85
  module.exports.middlewareSplit = binding.middlewareSplit;
85
86
  module.exports.opcodes = binding.opcodes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barqjs/compiler",
3
- "version": "0.2.0-next.0",
3
+ "version": "0.2.0-next.1",
4
4
  "description": "The barq compiler, in Rust: JSX to cloned DOM templates, compiled styles, file routes and diagnostics with stable codes",
5
5
  "keywords": [
6
6
  "barq",
@@ -24,7 +24,8 @@
24
24
  "files": [
25
25
  "index.js",
26
26
  "index.d.ts",
27
- "docs"
27
+ "docs",
28
+ "skills"
28
29
  ],
29
30
  "type": "commonjs",
30
31
  "sideEffects": false,
@@ -46,24 +47,24 @@
46
47
  "artifacts": "napi artifacts"
47
48
  },
48
49
  "devDependencies": {
49
- "@barqjs/core": "0.2.0-next.0",
50
- "@barqjs/router": "0.2.0-next.0",
51
- "@barqjs/server": "0.2.0-next.0",
52
- "@barqjs/start": "0.2.0-next.0",
53
- "@barqjs/universal": "0.2.0-next.0",
54
- "@barqjs/web": "0.2.0-next.0",
55
- "@happy-dom/global-registrator": "^21.0.1",
56
- "@napi-rs/cli": "^3.10.8",
57
- "@types/bun": "^1.4.3"
50
+ "@barqjs/core": "0.2.0-next.1",
51
+ "@barqjs/router": "0.2.0-next.1",
52
+ "@barqjs/server": "0.2.0-next.1",
53
+ "@barqjs/start": "0.2.0-next.1",
54
+ "@barqjs/universal": "0.2.0-next.1",
55
+ "@barqjs/web": "0.2.0-next.1",
56
+ "@happy-dom/global-registrator": "^21.0.4",
57
+ "@napi-rs/cli": "^3.10.12",
58
+ "@types/bun": "^1.4.4"
58
59
  },
59
60
  "optionalDependencies": {
60
- "@barqjs/compiler-darwin-arm64": "0.2.0-next.0",
61
- "@barqjs/compiler-darwin-x64": "0.2.0-next.0",
62
- "@barqjs/compiler-linux-arm64-gnu": "0.2.0-next.0",
63
- "@barqjs/compiler-linux-x64-gnu": "0.2.0-next.0",
64
- "@barqjs/compiler-linux-x64-musl": "0.2.0-next.0",
65
- "@barqjs/compiler-win32-arm64-msvc": "0.2.0-next.0",
66
- "@barqjs/compiler-win32-x64-msvc": "0.2.0-next.0"
61
+ "@barqjs/compiler-darwin-arm64": "0.2.0-next.1",
62
+ "@barqjs/compiler-darwin-x64": "0.2.0-next.1",
63
+ "@barqjs/compiler-linux-arm64-gnu": "0.2.0-next.1",
64
+ "@barqjs/compiler-linux-x64-gnu": "0.2.0-next.1",
65
+ "@barqjs/compiler-linux-x64-musl": "0.2.0-next.1",
66
+ "@barqjs/compiler-win32-arm64-msvc": "0.2.0-next.1",
67
+ "@barqjs/compiler-win32-x64-msvc": "0.2.0-next.1"
67
68
  },
68
69
  "engines": {
69
70
  "node": ">=20.17.0"