@wc-bindable/angular 0.8.0 → 0.9.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 +18 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ A standalone directive applied via the `wcBindable` attribute selector.
|
|
|
45
45
|
| `wcBindableChange` | `{ name: string; value: unknown }` | Emitted whenever a bindable property changes |
|
|
46
46
|
|
|
47
47
|
- Binds on `ngOnInit` and cleans up on `ngOnDestroy`.
|
|
48
|
-
- If the element does not implement `wc-bindable
|
|
48
|
+
- If the element does not implement `wc-bindable` — and is not a custom element still waiting for its definition — the directive is a no-op. See [Late-defined elements](#late-defined-elements).
|
|
49
49
|
|
|
50
50
|
## Design Notes
|
|
51
51
|
|
|
@@ -55,6 +55,23 @@ This directive uses `@Output()` with `EventEmitter` rather than the newer `outpu
|
|
|
55
55
|
- **Testability** — `@Output()` does not require an injection context, so the directive can be instantiated directly in unit tests.
|
|
56
56
|
- **Stability** — `EventEmitter` is a long-established, stable Angular API with no deprecation planned.
|
|
57
57
|
|
|
58
|
+
## Late-defined elements
|
|
59
|
+
|
|
60
|
+
`bind()` is called with `syncOn: "define"` by default, so an element whose custom element
|
|
61
|
+
definition arrives *after* this adapter runs — import-map autoloading, a CDN
|
|
62
|
+
`<script type="module">`, a code-split route — still binds once the definition lands. Nothing
|
|
63
|
+
has to re-run, and no re-render is needed.
|
|
64
|
+
|
|
65
|
+
Before this default, a not-yet-upgraded element was skipped permanently and silently: discovery
|
|
66
|
+
failed, the adapter returned early, and because the element keeps its identity across upgrade
|
|
67
|
+
nothing ever noticed. Opt back into that behavior with `syncOn: "call"`.
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<my-input wcBindable [wcBindableSyncOn]="'call'" (wcBindableChange)="onChange($event)"></my-input>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See [SPEC.md § Deferring Discovery Until Definition](../../SPEC.md#deferring-discovery-until-definition).
|
|
74
|
+
|
|
58
75
|
## Specification
|
|
59
76
|
|
|
60
77
|
The protocol contract this adapter implements lives in [SPEC.md](../../SPEC.md); the optional input/command invocation surface and the remote wire format live in [SPEC-extensions.md](../../SPEC-extensions.md). Runnable conformance vectors are in [CONFORMANCE.md](../../CONFORMANCE.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { ElementRef, EventEmitter, OnInit, OnDestroy } from "@angular/core";
|
|
2
|
+
import { type BindOptions } from "@wc-bindable/core";
|
|
2
3
|
export declare class WcBindableDirective implements OnInit, OnDestroy {
|
|
3
4
|
private el;
|
|
4
5
|
wcBindableChange: EventEmitter<{
|
|
5
6
|
name: string;
|
|
6
7
|
value: unknown;
|
|
7
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Forwarded to `bind()`. Defaults to `"define"` so an element whose
|
|
11
|
+
* definition arrives after `ngOnInit` still binds — see SPEC.md
|
|
12
|
+
* § Deferring Discovery Until Definition. Set `"call"` to opt back into
|
|
13
|
+
* the historical behavior, where a not-yet-upgraded element is skipped
|
|
14
|
+
* permanently.
|
|
15
|
+
*/
|
|
16
|
+
wcBindableSyncOn?: BindOptions["syncOn"];
|
|
8
17
|
private unbind?;
|
|
9
18
|
constructor(el: ElementRef<HTMLElement>);
|
|
10
19
|
ngOnInit(): void;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EAEZ,MAAM,EACN,SAAS,EAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,qBAIa,mBAAoB,YAAW,MAAM,EAAE,SAAS;IAc/C,OAAO,CAAC,EAAE;IAbZ,gBAAgB;cAA4B,MAAM;eAAS,OAAO;OAAM;IAElF;;;;;;OAMG;IACM,gBAAgB,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAElD,OAAO,CAAC,MAAM,CAAC,CAAa;gBAER,EAAE,EAAE,UAAU,CAAC,WAAW,CAAC;IAE/C,QAAQ;IAYR,WAAW;CAGZ"}
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { Directive, ElementRef, EventEmitter, Output, } from "@angular/core";
|
|
11
|
-
import { bind
|
|
10
|
+
import { Directive, ElementRef, EventEmitter, Input, Output, } from "@angular/core";
|
|
11
|
+
import { bind } from "@wc-bindable/core";
|
|
12
12
|
let WcBindableDirective = class WcBindableDirective {
|
|
13
13
|
constructor(el) {
|
|
14
14
|
this.el = el;
|
|
@@ -16,11 +16,13 @@ let WcBindableDirective = class WcBindableDirective {
|
|
|
16
16
|
}
|
|
17
17
|
ngOnInit() {
|
|
18
18
|
const element = this.el.nativeElement;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// No `isWcBindable()` gate: bind() already returns a no-op cleanup for
|
|
20
|
+
// a non-bindable target, and the gate is precisely what defeated
|
|
21
|
+
// `syncOn: "define"` — it fails for a not-yet-upgraded custom element,
|
|
22
|
+
// and ngOnInit does not run again to notice the upgrade.
|
|
21
23
|
this.unbind = bind(element, (name, value) => {
|
|
22
24
|
this.wcBindableChange.emit({ name, value });
|
|
23
|
-
});
|
|
25
|
+
}, { syncOn: this.wcBindableSyncOn ?? "define" });
|
|
24
26
|
}
|
|
25
27
|
ngOnDestroy() {
|
|
26
28
|
this.unbind?.();
|
|
@@ -30,6 +32,10 @@ __decorate([
|
|
|
30
32
|
Output(),
|
|
31
33
|
__metadata("design:type", Object)
|
|
32
34
|
], WcBindableDirective.prototype, "wcBindableChange", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Input(),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], WcBindableDirective.prototype, "wcBindableSyncOn", void 0);
|
|
33
39
|
WcBindableDirective = __decorate([
|
|
34
40
|
Directive({
|
|
35
41
|
selector: "[wcBindable]",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAoB,MAAM,mBAAmB,CAAC;AAMpD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAc9B,YAAoB,EAA2B;QAA3B,OAAE,GAAF,EAAE,CAAyB;QAbrC,qBAAgB,GAAG,IAAI,YAAY,EAAoC,CAAC;IAahC,CAAC;IAEnD,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QAEtC,uEAAuE;QACvE,iEAAiE;QACjE,uEAAuE;QACvE,yDAAyD;QACzD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC1C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,IAAI,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,WAAW;QACT,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAClB,CAAC;CACF,CAAA;AA9BW;IAAT,MAAM,EAAE;;6DAAyE;AASzE;IAAR,KAAK,EAAE;;6DAA0C;AAVvC,mBAAmB;IAJ/B,SAAS,CAAC;QACT,QAAQ,EAAE,cAAc;QACxB,UAAU,EAAE,IAAI;KACjB,CAAC;qCAewB,UAAU;GAdvB,mBAAmB,CA+B/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wc-bindable/angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Angular adapter for wc-bindable protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dev": "tsc --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@wc-bindable/core": "^0.
|
|
24
|
+
"@wc-bindable/core": "^0.9.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@angular/core": ">=17"
|