octane 0.2.13 → 0.2.15
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/dist/cjs/constants.cjs +7 -7
- package/dist/cjs/dom-binding-claims.cjs +28 -0
- package/dist/cjs/dom-binding-handoff.cjs +2 -2
- package/dist/cjs/dom-bindings.cjs +105 -13
- package/dist/cjs/runtime.cjs +311 -55
- package/dist/cjs/server/streamed-signals.cjs +3 -2
- package/dist/cjs/signals/control-binding.cjs +33 -9
- package/dist/cjs/signals/control-handoff.cjs +39 -0
- package/dist/cjs/stream-protocol.cjs +6 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/compile.js +86 -24
- package/dist/compiler/dom-binding-program.js +30 -3
- package/dist/compiler/dom-bindings.js +115 -34
- package/dist/compiler/volar.js +58 -17
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/dom-binding-claims.d.ts +1 -0
- package/dist/dom-binding-claims.js +4 -0
- package/dist/dom-binding-handoff.d.ts +6 -4
- package/dist/dom-binding-handoff.js +1 -1
- package/dist/dom-binding-program.d.ts +2 -1
- package/dist/dom-binding-program.js +16 -1
- package/dist/dom-bindings.d.ts +5 -2
- package/dist/dom-bindings.js +105 -13
- package/dist/runtime.d.ts +34 -3
- package/dist/runtime.js +314 -55
- package/dist/server/streamed-signals.js +3 -2
- package/dist/signals/control-binding.d.ts +9 -5
- package/dist/signals/control-binding.js +38 -6
- package/dist/signals/control-handoff.d.ts +26 -0
- package/dist/signals/control-handoff.js +12 -0
- package/dist/signals/index.d.ts +1 -0
- package/dist/stream-protocol.d.ts +4 -0
- package/dist/stream-protocol.js +4 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SignalControlBinding } from './control-handoff.js';
|
|
2
|
+
import { type SignalHandle, type SignalOwner } from './types.js';
|
|
2
3
|
type SignalControl = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
3
4
|
type ControlChannel = 'value' | 'checked';
|
|
4
5
|
export interface BindingControlPrepared {
|
|
@@ -15,17 +16,20 @@ export interface BindingControlLease {
|
|
|
15
16
|
prepare(value: unknown): BindingControlPrepared;
|
|
16
17
|
preview(value: unknown): BindingControlPreview;
|
|
17
18
|
prepareCurrent(): BindingControlPrepared;
|
|
19
|
+
active(): boolean;
|
|
20
|
+
composing(): boolean;
|
|
18
21
|
dispose(): void;
|
|
19
22
|
}
|
|
20
23
|
/** @internal Optional compiled-control capability; captures, but never creates, an owner. */
|
|
21
|
-
export declare function __createBindingControls(): {
|
|
24
|
+
export declare function __createBindingControls(owner?: SignalOwner | null): {
|
|
22
25
|
claim(element: Element, channel: ControlChannel, notify: () => void): BindingControlLease;
|
|
23
26
|
};
|
|
24
27
|
/**
|
|
25
28
|
* Bind one native property on externally owned DOM without creating a renderer.
|
|
26
29
|
* Writable signals adopt captured early edits and receive native input; other
|
|
27
|
-
* handles only project.
|
|
30
|
+
* handles only project. The callable cleanup may be offered to hydrateRoot in
|
|
31
|
+
* controlLeases; declined or suspended presentation keeps this binding active.
|
|
28
32
|
*/
|
|
29
|
-
export declare function bindSignalControl(control: SignalControl, channel: 'value', handle$: SignalHandle<string | readonly string[]>):
|
|
30
|
-
export declare function bindSignalControl(control: HTMLInputElement, channel: 'checked', handle$: SignalHandle<boolean>):
|
|
33
|
+
export declare function bindSignalControl(control: SignalControl, channel: 'value', handle$: SignalHandle<string | readonly string[]>): SignalControlBinding;
|
|
34
|
+
export declare function bindSignalControl(control: HTMLInputElement, channel: 'checked', handle$: SignalHandle<boolean>): SignalControlBinding;
|
|
31
35
|
export {};
|
|
@@ -8,14 +8,22 @@ import {
|
|
|
8
8
|
registerHydrationControlSignalWriter
|
|
9
9
|
} from "./early-values.js";
|
|
10
10
|
import { isSignalHandle, isWritableSignal } from "./handle-protocol.js";
|
|
11
|
+
import {
|
|
12
|
+
CONTROL_BINDINGS,
|
|
13
|
+
CONTROL_HANDOFF
|
|
14
|
+
} from "./control-handoff.js";
|
|
11
15
|
import { captureSignalOwner, currentSignalOwner } from "./owner-context.js";
|
|
12
16
|
import {
|
|
13
17
|
forwardNativeTransitionConsumer,
|
|
14
18
|
NATIVE_TRANSITION_CONSUMER
|
|
15
19
|
} from "./read-protocol.js";
|
|
16
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
SIGNAL_BINDING_IDENTITY,
|
|
22
|
+
SIGNAL_BINDING_READ,
|
|
23
|
+
SIGNAL_BINDING_SUBSCRIBE,
|
|
24
|
+
SIGNAL_OWNER_RESOLVE
|
|
25
|
+
} from "./types.js";
|
|
17
26
|
import { withoutSignalCandidate } from "./transition-state.js";
|
|
18
|
-
const CONTROL_BINDINGS = /* @__PURE__ */ new WeakMap();
|
|
19
27
|
const RADIO_WRITERS = /* @__PURE__ */ new WeakMap();
|
|
20
28
|
function controlString(value) {
|
|
21
29
|
return typeof value === "string" ? value : typeof value === "function" || typeof value === "symbol" ? "" : String(value);
|
|
@@ -34,8 +42,7 @@ function publishRadioInput(input) {
|
|
|
34
42
|
for (const [write, checked] of edits) if (!checked) write(false);
|
|
35
43
|
for (const [write, checked] of edits) if (checked) write(true);
|
|
36
44
|
}
|
|
37
|
-
function __createBindingControls() {
|
|
38
|
-
const owner = currentSignalOwner();
|
|
45
|
+
function __createBindingControls(owner = currentSignalOwner()) {
|
|
39
46
|
const run = owner === null ? (callback) => callback() : captureSignalOwner(owner);
|
|
40
47
|
return {
|
|
41
48
|
claim(element, channel, notify) {
|
|
@@ -284,11 +291,16 @@ function __createBindingControls() {
|
|
|
284
291
|
prepare,
|
|
285
292
|
preview: (value) => prepare(value, true),
|
|
286
293
|
prepareCurrent: () => prepare(raw),
|
|
294
|
+
active: () => !disposed,
|
|
295
|
+
composing: () => composing,
|
|
287
296
|
dispose
|
|
288
297
|
};
|
|
289
298
|
}
|
|
290
299
|
};
|
|
291
300
|
}
|
|
301
|
+
function controlSignalOwner(owner, document) {
|
|
302
|
+
return owner !== null && "documentOwner" in owner ? document ? owner.documentOwner : owner.instanceOwner : owner;
|
|
303
|
+
}
|
|
292
304
|
function bindSignalControl(control, channel, handle$) {
|
|
293
305
|
if (!isSignalHandle(handle$))
|
|
294
306
|
throw new TypeError("A signal control requires a native value/checked property and a signal.");
|
|
@@ -296,6 +308,7 @@ function bindSignalControl(control, channel, handle$) {
|
|
|
296
308
|
let dirty = false;
|
|
297
309
|
let disposed = false;
|
|
298
310
|
let lease;
|
|
311
|
+
let handoff;
|
|
299
312
|
const dispose = () => {
|
|
300
313
|
disposed = true;
|
|
301
314
|
lease.dispose();
|
|
@@ -343,9 +356,28 @@ function bindSignalControl(control, channel, handle$) {
|
|
|
343
356
|
};
|
|
344
357
|
}
|
|
345
358
|
};
|
|
346
|
-
|
|
359
|
+
const owner = currentSignalOwner();
|
|
360
|
+
lease = __createBindingControls(owner).claim(control, channel, refresh);
|
|
347
361
|
refresh();
|
|
348
|
-
return dispose
|
|
362
|
+
return Object.assign(dispose, {
|
|
363
|
+
[CONTROL_HANDOFF]() {
|
|
364
|
+
return handoff ??= {
|
|
365
|
+
control,
|
|
366
|
+
channel,
|
|
367
|
+
active: () => !disposed && lease.active(),
|
|
368
|
+
matches(handle) {
|
|
369
|
+
if (disposed || !lease.active() || handle !== handle$) return false;
|
|
370
|
+
if (!(SIGNAL_OWNER_RESOLVE in handle$)) return true;
|
|
371
|
+
const document = handle$[SIGNAL_BINDING_IDENTITY]().scope === "document";
|
|
372
|
+
return owner !== null && controlSignalOwner(owner, document) === controlSignalOwner(currentSignalOwner(), document) && !disposed && lease.active();
|
|
373
|
+
},
|
|
374
|
+
composing: lease.composing,
|
|
375
|
+
// dispose revokes authority before invoking fallible subscription
|
|
376
|
+
// cleanup; a later call cannot release the renderer's replacement.
|
|
377
|
+
retire: dispose
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
});
|
|
349
381
|
}
|
|
350
382
|
export {
|
|
351
383
|
__createBindingControls,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SignalHandle } from './types.js';
|
|
2
|
+
/** Renderer-independent capability shared by early views and later presentation. */
|
|
3
|
+
export declare const BINDING_HANDOFF: unique symbol;
|
|
4
|
+
/** Explicit, renderer-independent ownership of one standalone native control. */
|
|
5
|
+
export declare const CONTROL_HANDOFF: unique symbol;
|
|
6
|
+
/** @internal One claim registry for writable and readonly native control leases. */
|
|
7
|
+
export declare const CONTROL_BINDINGS: WeakMap<Element, Set<"value" | "checked">>;
|
|
8
|
+
/** @internal Readonly projections also own the property, even without an input writer. */
|
|
9
|
+
export declare function hasSignalControlBinding(control: Element, channel: 'value' | 'checked'): boolean;
|
|
10
|
+
/** @internal A root may consume this capability only with its accepted presentation. */
|
|
11
|
+
export interface ControlHandoff {
|
|
12
|
+
readonly control: Element;
|
|
13
|
+
readonly channel: 'value' | 'checked';
|
|
14
|
+
active(): boolean;
|
|
15
|
+
/** Called within the prospective renderer's signal owner, without changing authority. */
|
|
16
|
+
matches(handle: SignalHandle<unknown>): boolean;
|
|
17
|
+
composing(): boolean;
|
|
18
|
+
retire(): void;
|
|
19
|
+
owner?: object;
|
|
20
|
+
}
|
|
21
|
+
/** Callable cleanup which can also be offered explicitly to hydrateRoot's controlLeases. */
|
|
22
|
+
export interface SignalControlBinding {
|
|
23
|
+
(): void;
|
|
24
|
+
/** @internal Merely requesting the capability never transfers the control. */
|
|
25
|
+
[CONTROL_HANDOFF](): ControlHandoff;
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const BINDING_HANDOFF = /* @__PURE__ */ Symbol.for("octane.binding-handoff");
|
|
2
|
+
const CONTROL_HANDOFF = /* @__PURE__ */ Symbol.for("octane.control-handoff");
|
|
3
|
+
const CONTROL_BINDINGS = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function hasSignalControlBinding(control, channel) {
|
|
5
|
+
return CONTROL_BINDINGS.get(control)?.has(channel) ?? false;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
BINDING_HANDOFF,
|
|
9
|
+
CONTROL_BINDINGS,
|
|
10
|
+
CONTROL_HANDOFF,
|
|
11
|
+
hasSignalControlBinding
|
|
12
|
+
};
|
package/dist/signals/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Stable scoped signals. This entry does not import a renderer. */
|
|
2
2
|
export { createScope } from './engine.js';
|
|
3
3
|
export { bindSignalControl } from './control-binding.js';
|
|
4
|
+
export type { SignalControlBinding } from './control-handoff.js';
|
|
4
5
|
export { enableSignalDocument as __enableSignalDocument } from './document-owner.js';
|
|
5
6
|
export { createResource, query } from './requests.js';
|
|
6
7
|
export { ActionUncertainError, action$, isActionUncertain, optimistic$ } from './actions.js';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** Sentinel <template> attribute marking a pending streamed boundary. */
|
|
2
2
|
export declare const STREAM_BOUNDARY_ATTR = "data-oct-b";
|
|
3
|
+
/** Renderer-owned JSON script carrying resolved SSR Suspense values. */
|
|
4
|
+
export declare const SUSPENSE_SCRIPT_ATTR = "data-octane-suspense";
|
|
5
|
+
/** Renderer-owned executable/data scripts emitted by the streaming protocol. */
|
|
6
|
+
export declare const STREAM_SCRIPT_ATTR = "data-octane-stream";
|
|
3
7
|
/** Render-unique token stamped on deferred-hydration owners in a streamed shell. */
|
|
4
8
|
export declare const HYDRATE_STREAM_TOKEN_ATTR = "data-octane-stream-token";
|
|
5
9
|
/** Find a physical hydration range's close without trusting malformed comment input. */
|
package/dist/stream-protocol.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isBindingOpenComment } from "./dom-binding-protocol.js";
|
|
2
2
|
const STREAM_BOUNDARY_ATTR = "data-oct-b";
|
|
3
|
+
const SUSPENSE_SCRIPT_ATTR = "data-octane-suspense";
|
|
4
|
+
const STREAM_SCRIPT_ATTR = "data-octane-stream";
|
|
3
5
|
const HYDRATE_STREAM_TOKEN_ATTR = "data-octane-stream-token";
|
|
4
6
|
function hydrationMarkerMultiplicity(data, open) {
|
|
5
7
|
const marker = open ? "[" : "]";
|
|
@@ -64,6 +66,8 @@ function isRendererStreamBoundaryTemplate(node, expectedToken) {
|
|
|
64
66
|
export {
|
|
65
67
|
HYDRATE_STREAM_TOKEN_ATTR,
|
|
66
68
|
STREAM_BOUNDARY_ATTR,
|
|
69
|
+
STREAM_SCRIPT_ATTR,
|
|
70
|
+
SUSPENSE_SCRIPT_ATTR,
|
|
67
71
|
isRendererStreamBoundaryTemplate,
|
|
68
72
|
isRendererStreamToken,
|
|
69
73
|
rendererRangeClose,
|
package/dist/version.js
CHANGED