@wc-bindable/solid 0.8.0 → 0.10.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 +20 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ function App() {
|
|
|
45
45
|
|
|
46
46
|
## API
|
|
47
47
|
|
|
48
|
-
### `createWcBindable()`
|
|
48
|
+
### `createWcBindable(initialValues?, options?)`
|
|
49
49
|
|
|
50
50
|
**Returns:** `[values, directive]`
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ function App() {
|
|
|
54
54
|
| `values` | `Accessor<Record<string, unknown>>` | Signal with the latest property values |
|
|
55
55
|
| `directive` | `(el: HTMLElement) => void` | Pass to `ref` to bind the element |
|
|
56
56
|
|
|
57
|
-
### `wcBindable(el, accessor)`
|
|
57
|
+
### `wcBindable(el, accessor, options?)`
|
|
58
58
|
|
|
59
59
|
Solid directive for use with `use:wcBindable`.
|
|
60
60
|
|
|
@@ -63,6 +63,24 @@ Solid directive for use with `use:wcBindable`.
|
|
|
63
63
|
| `el` | `HTMLElement` | The target element (provided by Solid) |
|
|
64
64
|
| `accessor` | `Accessor<(name, value) => void>` | Callback invoked on property changes |
|
|
65
65
|
|
|
66
|
+
## Late-defined elements
|
|
67
|
+
|
|
68
|
+
`bind()` is called with `syncOn: "define"` by default, so an element whose custom element
|
|
69
|
+
definition arrives *after* this adapter runs — import-map autoloading, a CDN
|
|
70
|
+
`<script type="module">`, a code-split route — still binds once the definition lands. Nothing
|
|
71
|
+
has to re-run, and no re-render is needed.
|
|
72
|
+
|
|
73
|
+
Before this default, a not-yet-upgraded element was skipped permanently and silently: discovery
|
|
74
|
+
failed, the adapter returned early, and because the element keeps its identity across upgrade
|
|
75
|
+
nothing ever noticed. Opt back into that behavior with `syncOn: "call"`.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
wcBindable(el, () => onUpdate, { syncOn: "call" });
|
|
79
|
+
const [values, directive] = createWcBindable({ value: "" }, { syncOn: "call" });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
See [SPEC.md § Deferring Discovery Until Definition](../../SPEC.md#deferring-discovery-until-definition).
|
|
83
|
+
|
|
66
84
|
## Specification
|
|
67
85
|
|
|
68
86
|
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,5 +1,16 @@
|
|
|
1
1
|
import { type Accessor } from "solid-js";
|
|
2
|
-
|
|
2
|
+
import { type BindOptions } from "@wc-bindable/core";
|
|
3
|
+
export interface WcBindableOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Forwarded to `bind()`. Defaults to `"define"` so an element whose
|
|
6
|
+
* definition arrives after the directive runs still binds — see SPEC.md
|
|
7
|
+
* § Deferring Discovery Until Definition. Pass `"call"` to opt back into
|
|
8
|
+
* the historical behavior, where a not-yet-upgraded element is skipped
|
|
9
|
+
* permanently.
|
|
10
|
+
*/
|
|
11
|
+
syncOn?: BindOptions["syncOn"];
|
|
12
|
+
}
|
|
13
|
+
export type WcBindableDirective = (el: HTMLElement, accessor: Accessor<(name: string, value: unknown) => void>, options?: WcBindableOptions) => void;
|
|
3
14
|
export declare const wcBindable: WcBindableDirective;
|
|
4
|
-
export declare function createWcBindable<V extends object = Record<string, unknown>>(initialValues?: Partial<V
|
|
15
|
+
export declare function createWcBindable<V extends object = Record<string, unknown>>(initialValues?: Partial<V>, options?: WcBindableOptions): readonly [Accessor<V>, (el: HTMLElement) => void];
|
|
5
16
|
//# 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":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,EAC1D,OAAO,CAAC,EAAE,iBAAiB,KACxB,IAAI,CAAC;AAEV,eAAO,MAAM,UAAU,EAAE,mBAUxB,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,aAAa,GAAE,OAAO,CAAC,CAAC,CAAM,EAAE,OAAO,GAAE,iBAAsB,+BAGxC,WAAW,WAOnC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { createSignal, onCleanup } from "solid-js";
|
|
2
|
-
import { bind
|
|
3
|
-
export const wcBindable = (el, accessor) => {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { bind } from "@wc-bindable/core";
|
|
3
|
+
export const wcBindable = (el, accessor, options = {}) => {
|
|
4
|
+
// No `isWcBindable()` gate: bind() already returns a no-op cleanup for a
|
|
5
|
+
// non-bindable target, and the gate is precisely what defeated
|
|
6
|
+
// `syncOn: "define"` — it fails for a not-yet-upgraded custom element,
|
|
7
|
+
// and the directive body does not run again to notice the upgrade.
|
|
6
8
|
const unbind = bind(el, (name, value) => {
|
|
7
9
|
accessor()(name, value);
|
|
8
|
-
});
|
|
10
|
+
}, { syncOn: options.syncOn ?? "define" });
|
|
9
11
|
onCleanup(unbind);
|
|
10
12
|
};
|
|
11
|
-
export function createWcBindable(initialValues = {}) {
|
|
13
|
+
export function createWcBindable(initialValues = {}, options = {}) {
|
|
12
14
|
const [values, setValues] = createSignal(initialValues);
|
|
13
15
|
const directive = (el) => {
|
|
14
16
|
wcBindable(el, () => (name, value) => {
|
|
15
17
|
setValues((prev) => ({ ...prev, [name]: value }));
|
|
16
|
-
});
|
|
18
|
+
}, options);
|
|
17
19
|
};
|
|
18
20
|
return [values, directive];
|
|
19
21
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAiB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAiB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,IAAI,EAAoB,MAAM,mBAAmB,CAAC;AAmB3D,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IAC5E,yEAAyE;IACzE,+DAA+D;IAC/D,uEAAuE;IACvE,mEAAmE;IACnE,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAC;IAE3C,SAAS,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAE9B,gBAA4B,EAAE,EAAE,UAA6B,EAAE;IAC/D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,YAAY,CAAI,aAAkB,CAAC,CAAC;IAEhE,MAAM,SAAS,GAAG,CAAC,EAAe,EAAE,EAAE;QACpC,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACnC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,SAAS,CAAU,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wc-bindable/solid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Solid 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.10.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"solid-js": ">=1"
|