@wc-bindable/marko 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 +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm install @wc-bindable/marko marko
|
|
|
15
15
|
|
|
16
16
|
## API
|
|
17
17
|
|
|
18
|
-
### `wcBindable(el, onUpdate): unbind`
|
|
18
|
+
### `wcBindable(el, onUpdate, options?): unbind`
|
|
19
19
|
|
|
20
20
|
| Parameter | Type | Description |
|
|
21
21
|
|---|---|---|
|
|
@@ -71,6 +71,23 @@ $ const TAG = "my-input";
|
|
|
71
71
|
<${TAG} key="input"/>
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
## Late-defined elements
|
|
75
|
+
|
|
76
|
+
`bind()` is called with `syncOn: "define"` by default, so an element whose custom element
|
|
77
|
+
definition arrives *after* this adapter runs — import-map autoloading, a CDN
|
|
78
|
+
`<script type="module">`, a code-split route — still binds once the definition lands. Nothing
|
|
79
|
+
has to re-run, and no re-render is needed.
|
|
80
|
+
|
|
81
|
+
Before this default, a not-yet-upgraded element was skipped permanently and silently: discovery
|
|
82
|
+
failed, the adapter returned early, and because the element keeps its identity across upgrade
|
|
83
|
+
nothing ever noticed. Opt back into that behavior with `syncOn: "call"`.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
wcBindable(el, onUpdate, { syncOn: "call" });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See [SPEC.md § Deferring Discovery Until Definition](../../SPEC.md#deferring-discovery-until-definition).
|
|
90
|
+
|
|
74
91
|
## Specification
|
|
75
92
|
|
|
76
93
|
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,4 +1,15 @@
|
|
|
1
|
+
import { type BindOptions } from "@wc-bindable/core";
|
|
1
2
|
export type UnbindFn = () => void;
|
|
2
3
|
export type OnUpdate = (name: string, value: unknown) => void;
|
|
3
|
-
export
|
|
4
|
+
export interface WcBindableOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Forwarded to `bind()`. Defaults to `"define"` so an element whose
|
|
7
|
+
* definition arrives after this call still binds — see SPEC.md
|
|
8
|
+
* § Deferring Discovery Until Definition. Pass `"call"` to opt back into
|
|
9
|
+
* the historical behavior, where a not-yet-upgraded element is skipped
|
|
10
|
+
* permanently.
|
|
11
|
+
*/
|
|
12
|
+
syncOn?: BindOptions["syncOn"];
|
|
13
|
+
}
|
|
14
|
+
export declare function wcBindable(el: HTMLElement, onUpdate: OnUpdate, options?: WcBindableOptions): UnbindFn;
|
|
4
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,wBAAgB,UAAU,CACxB,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,iBAAsB,GAC9B,QAAQ,CAMV"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { bind
|
|
2
|
-
export function wcBindable(el, onUpdate) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { bind } from "@wc-bindable/core";
|
|
2
|
+
export function wcBindable(el, onUpdate, options = {}) {
|
|
3
|
+
// No `isWcBindable()` gate: bind() already returns a no-op cleanup for a
|
|
4
|
+
// non-bindable target, and the gate is precisely what defeated
|
|
5
|
+
// `syncOn: "define"` — it fails for a not-yet-upgraded custom element,
|
|
6
|
+
// and nothing re-runs this call on upgrade.
|
|
7
|
+
return bind(el, onUpdate, { syncOn: options.syncOn ?? "define" });
|
|
6
8
|
}
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,mBAAmB,CAAC;AAiB3D,MAAM,UAAU,UAAU,CACxB,EAAe,EACf,QAAkB,EAClB,UAA6B,EAAE;IAE/B,yEAAyE;IACzE,+DAA+D;IAC/D,uEAAuE;IACvE,4CAA4C;IAC5C,OAAO,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wc-bindable/marko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Marko adapter for wc-bindable protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test:integration": "vitest run --config vitest.integration.config.ts integration"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@wc-bindable/core": "^0.
|
|
27
|
+
"@wc-bindable/core": "^0.9.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"marko": ">=5"
|