@jay-framework/stack-client-runtime 0.24.5 → 0.24.7
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/index.cjs +28 -5
- package/dist/index.d.ts +19 -2
- package/dist/index.js +29 -6
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -80,12 +80,12 @@ function makeSignals$2(obj) {
|
|
|
80
80
|
return signals;
|
|
81
81
|
}, {});
|
|
82
82
|
}
|
|
83
|
-
function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
83
|
+
function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey, freeRefNames) {
|
|
84
84
|
const interactiveConstructor = componentDef.comp;
|
|
85
85
|
const resolvedContexts = componentDef.contexts ?? [];
|
|
86
86
|
const clientDefaults = componentDef.clientDefaults;
|
|
87
87
|
const wrappedConstructor = (signalProps, refs, ...pluginResolvedContexts) => {
|
|
88
|
-
const instanceData = runtime.
|
|
88
|
+
const instanceData = runtime.findContext((_) => _ === HEADLESS_INSTANCES);
|
|
89
89
|
const resolvedKey = typeof coordinateKey === "function" ? coordinateKey(runtime.currentConstructionContext()?.dataIds ?? []) : coordinateKey;
|
|
90
90
|
const suffixKey = resolvedKey.includes("/") && resolvedKey.includes(":") ? resolvedKey.split("/").find((s) => s.includes(":")) ?? resolvedKey : resolvedKey;
|
|
91
91
|
const fastVS = instanceData?.viewStates?.[resolvedKey] ?? instanceData?.viewStates?.[suffixKey];
|
|
@@ -101,9 +101,10 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
101
101
|
resolvedFastVS = defaults.viewState;
|
|
102
102
|
resolvedCf = defaults.carryForward ?? {};
|
|
103
103
|
} else {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
if (instanceData)
|
|
105
|
+
console.warn(
|
|
106
|
+
`[Jay] Headless instance "${resolvedKey}" has no server data and no clientDefaults. Add .withClientDefaults() to the component definition to provide fallback values.`
|
|
107
|
+
);
|
|
107
108
|
resolvedFastVS = {};
|
|
108
109
|
resolvedCf = {};
|
|
109
110
|
}
|
|
@@ -115,6 +116,7 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
115
116
|
resolvedCf,
|
|
116
117
|
...pluginResolvedContexts
|
|
117
118
|
);
|
|
119
|
+
if (freeRefNames?.length) compCore.freeRefs = refs;
|
|
118
120
|
const originalRender = compCore.render;
|
|
119
121
|
const isHydrating = runtime.currentConstructionContext()?.isHydrating;
|
|
120
122
|
if (isHydrating) {
|
|
@@ -143,6 +145,26 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
143
145
|
};
|
|
144
146
|
return component.makeJayComponent(preRender, wrappedConstructor, ...resolvedContexts);
|
|
145
147
|
}
|
|
148
|
+
function makePassthroughHeadlessInstanceComponent(preRender, coordinateKey, freeRefNames) {
|
|
149
|
+
const passthroughDef = {
|
|
150
|
+
// Identity interactive constructor: reactively echo props as the interactive ViewState.
|
|
151
|
+
// Reading `signalProps.props()` INSIDE render registers a reactive dependency on the props
|
|
152
|
+
// signal (component.ts makePropsProxy `_props`), so a parent props update — e.g. a binding
|
|
153
|
+
// like `status="{currentStatus}"` — re-runs this render reaction and patches the element.
|
|
154
|
+
// The merged output ({ ...resolvedFastVS, ...signalProps.props() }) is the fast ViewState
|
|
155
|
+
// with live props overlaid. Returning a static `{}` here (the earlier form) read nothing
|
|
156
|
+
// reactively, so prop updates never re-rendered the region.
|
|
157
|
+
comp: (signalProps) => ({ render: () => signalProps.props() }),
|
|
158
|
+
// Echo props as ViewState when the region has no server data (mirrors the server passthrough).
|
|
159
|
+
clientDefaults: (props) => ({ viewState: props })
|
|
160
|
+
};
|
|
161
|
+
return makeHeadlessInstanceComponent(
|
|
162
|
+
preRender,
|
|
163
|
+
passthroughDef,
|
|
164
|
+
coordinateKey,
|
|
165
|
+
freeRefNames
|
|
166
|
+
);
|
|
167
|
+
}
|
|
146
168
|
function makeSignals$1(obj) {
|
|
147
169
|
return Object.keys(obj).reduce((signals, key) => {
|
|
148
170
|
signals[key] = component.createSignal(obj[key]);
|
|
@@ -866,5 +888,6 @@ exports.createStreamCaller = createStreamCaller;
|
|
|
866
888
|
exports.hydrateCompositeJayComponent = hydrateCompositeJayComponent;
|
|
867
889
|
exports.makeCompositeJayComponent = makeCompositeJayComponent;
|
|
868
890
|
exports.makeHeadlessInstanceComponent = makeHeadlessInstanceComponent;
|
|
891
|
+
exports.makePassthroughHeadlessInstanceComponent = makePassthroughHeadlessInstanceComponent;
|
|
869
892
|
exports.setActionCallerOptions = setActionCallerOptions;
|
|
870
893
|
exports.wrapWithAutomation = wrapWithAutomation;
|
package/dist/index.d.ts
CHANGED
|
@@ -80,7 +80,24 @@ interface HeadlessComponentDef {
|
|
|
80
80
|
carryForward?: any;
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
declare function makeHeadlessInstanceComponent<PropsT extends object, ViewState extends object, Refs extends object, JayElementT extends JayElement<ViewState, Refs>, CompCore extends JayComponentCore<PropsT, ViewState>>(preRender: PreRenderElement<ViewState, Refs, JayElementT>, componentDef: HeadlessComponentDef, coordinateKey: string | ((dataIds: string[]) => string)): (props: PropsT) => ConcreteJayComponent<PropsT, ViewState, Refs, CompCore, JayElementT>;
|
|
83
|
+
declare function makeHeadlessInstanceComponent<PropsT extends object, ViewState extends object, Refs extends object, JayElementT extends JayElement<ViewState, Refs>, CompCore extends JayComponentCore<PropsT, ViewState>>(preRender: PreRenderElement<ViewState, Refs, JayElementT>, componentDef: HeadlessComponentDef, coordinateKey: string | ((dataIds: string[]) => string), freeRefNames?: string[]): (props: PropsT) => ConcreteJayComponent<PropsT, ViewState, Refs, CompCore, JayElementT>;
|
|
84
|
+
/**
|
|
85
|
+
* DL#196 — client/hydrate twin of the server's `makePassthroughInstanceComponent`.
|
|
86
|
+
*
|
|
87
|
+
* A no-code (structural) region has a materialised template but no author `.ts` logic module, so
|
|
88
|
+
* there is nothing to import as the interactive constructor. This synthesises an identity instance:
|
|
89
|
+
* the interactive phase contributes no properties (`render: () => ({})`), so the merged output is
|
|
90
|
+
* exactly the fast ViewState resolved from the HEADLESS_INSTANCES context by coordinate; when no
|
|
91
|
+
* server data is present, `clientDefaults` echoes the incoming props — mirroring the server
|
|
92
|
+
* passthrough's per-phase prop echo. All the coordinate lookup, suffix fallback, and hydration
|
|
93
|
+
* gating is inherited from `makeHeadlessInstanceComponent`.
|
|
94
|
+
*
|
|
95
|
+
* DL deviation: DL#196 §Prior Art claimed "no new runtime". The server passthrough exists at load
|
|
96
|
+
* time, but the client/hydrate target imports each instance's logic and had no passthrough path — a
|
|
97
|
+
* no-code region needs this identity constructor to compile as a real instance. Kept minimal (a thin
|
|
98
|
+
* wrapper over the existing instance machinery). See DL#196 Implementation Results.
|
|
99
|
+
*/
|
|
100
|
+
declare function makePassthroughHeadlessInstanceComponent<PropsT extends object, ViewState extends object, Refs extends object, JayElementT extends JayElement<ViewState, Refs>, CompCore extends JayComponentCore<PropsT, ViewState>>(preRender: PreRenderElement<ViewState, Refs, JayElementT>, coordinateKey: string | ((dataIds: string[]) => string), freeRefNames?: string[]): (props: PropsT) => ConcreteJayComponent<PropsT, ViewState, Refs, CompCore, JayElementT>;
|
|
84
101
|
|
|
85
102
|
/**
|
|
86
103
|
* Client-side action caller for Jay Stack.
|
|
@@ -174,4 +191,4 @@ declare function createActionCaller<Input, Output>(actionName: string, method?:
|
|
|
174
191
|
*/
|
|
175
192
|
declare function createStreamCaller<Input, Chunk>(actionName: string, options?: CreateActionCallerOptions): (input: Input) => AsyncIterable<Chunk>;
|
|
176
193
|
|
|
177
|
-
export { type ActionCallerOptions, ActionError, type CompositePart, type CreateActionCallerOptions, HEADLESS_INSTANCES, type HeadlessComponentDef, type HeadlessInstancesData, type HttpMethod, createActionCaller, createStreamCaller, hydrateCompositeJayComponent, makeCompositeJayComponent, makeHeadlessInstanceComponent, setActionCallerOptions };
|
|
194
|
+
export { type ActionCallerOptions, ActionError, type CompositePart, type CreateActionCallerOptions, HEADLESS_INSTANCES, type HeadlessComponentDef, type HeadlessInstancesData, type HttpMethod, createActionCaller, createStreamCaller, hydrateCompositeJayComponent, makeCompositeJayComponent, makeHeadlessInstanceComponent, makePassthroughHeadlessInstanceComponent, setActionCallerOptions };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { makeJayComponent, createSignal, materializeViewState, COMPONENT_CONTEXT } from "@jay-framework/component";
|
|
5
|
-
import { createJayContext,
|
|
5
|
+
import { createJayContext, findContext, currentConstructionContext, useContext } from "@jay-framework/runtime";
|
|
6
6
|
function deepMergeViewStates$1(base, overlay, trackByMap, path = "") {
|
|
7
7
|
if (!base && !overlay) return {};
|
|
8
8
|
if (!base) return overlay || {};
|
|
@@ -78,12 +78,12 @@ function makeSignals$2(obj) {
|
|
|
78
78
|
return signals;
|
|
79
79
|
}, {});
|
|
80
80
|
}
|
|
81
|
-
function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
81
|
+
function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey, freeRefNames) {
|
|
82
82
|
const interactiveConstructor = componentDef.comp;
|
|
83
83
|
const resolvedContexts = componentDef.contexts ?? [];
|
|
84
84
|
const clientDefaults = componentDef.clientDefaults;
|
|
85
85
|
const wrappedConstructor = (signalProps, refs, ...pluginResolvedContexts) => {
|
|
86
|
-
const instanceData =
|
|
86
|
+
const instanceData = findContext((_) => _ === HEADLESS_INSTANCES);
|
|
87
87
|
const resolvedKey = typeof coordinateKey === "function" ? coordinateKey(currentConstructionContext()?.dataIds ?? []) : coordinateKey;
|
|
88
88
|
const suffixKey = resolvedKey.includes("/") && resolvedKey.includes(":") ? resolvedKey.split("/").find((s) => s.includes(":")) ?? resolvedKey : resolvedKey;
|
|
89
89
|
const fastVS = instanceData?.viewStates?.[resolvedKey] ?? instanceData?.viewStates?.[suffixKey];
|
|
@@ -99,9 +99,10 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
99
99
|
resolvedFastVS = defaults.viewState;
|
|
100
100
|
resolvedCf = defaults.carryForward ?? {};
|
|
101
101
|
} else {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (instanceData)
|
|
103
|
+
console.warn(
|
|
104
|
+
`[Jay] Headless instance "${resolvedKey}" has no server data and no clientDefaults. Add .withClientDefaults() to the component definition to provide fallback values.`
|
|
105
|
+
);
|
|
105
106
|
resolvedFastVS = {};
|
|
106
107
|
resolvedCf = {};
|
|
107
108
|
}
|
|
@@ -113,6 +114,7 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
113
114
|
resolvedCf,
|
|
114
115
|
...pluginResolvedContexts
|
|
115
116
|
);
|
|
117
|
+
if (freeRefNames?.length) compCore.freeRefs = refs;
|
|
116
118
|
const originalRender = compCore.render;
|
|
117
119
|
const isHydrating = currentConstructionContext()?.isHydrating;
|
|
118
120
|
if (isHydrating) {
|
|
@@ -141,6 +143,26 @@ function makeHeadlessInstanceComponent(preRender, componentDef, coordinateKey) {
|
|
|
141
143
|
};
|
|
142
144
|
return makeJayComponent(preRender, wrappedConstructor, ...resolvedContexts);
|
|
143
145
|
}
|
|
146
|
+
function makePassthroughHeadlessInstanceComponent(preRender, coordinateKey, freeRefNames) {
|
|
147
|
+
const passthroughDef = {
|
|
148
|
+
// Identity interactive constructor: reactively echo props as the interactive ViewState.
|
|
149
|
+
// Reading `signalProps.props()` INSIDE render registers a reactive dependency on the props
|
|
150
|
+
// signal (component.ts makePropsProxy `_props`), so a parent props update — e.g. a binding
|
|
151
|
+
// like `status="{currentStatus}"` — re-runs this render reaction and patches the element.
|
|
152
|
+
// The merged output ({ ...resolvedFastVS, ...signalProps.props() }) is the fast ViewState
|
|
153
|
+
// with live props overlaid. Returning a static `{}` here (the earlier form) read nothing
|
|
154
|
+
// reactively, so prop updates never re-rendered the region.
|
|
155
|
+
comp: (signalProps) => ({ render: () => signalProps.props() }),
|
|
156
|
+
// Echo props as ViewState when the region has no server data (mirrors the server passthrough).
|
|
157
|
+
clientDefaults: (props) => ({ viewState: props })
|
|
158
|
+
};
|
|
159
|
+
return makeHeadlessInstanceComponent(
|
|
160
|
+
preRender,
|
|
161
|
+
passthroughDef,
|
|
162
|
+
coordinateKey,
|
|
163
|
+
freeRefNames
|
|
164
|
+
);
|
|
165
|
+
}
|
|
144
166
|
function makeSignals$1(obj) {
|
|
145
167
|
return Object.keys(obj).reduce((signals, key) => {
|
|
146
168
|
signals[key] = createSignal(obj[key]);
|
|
@@ -865,6 +887,7 @@ export {
|
|
|
865
887
|
hydrateCompositeJayComponent,
|
|
866
888
|
makeCompositeJayComponent,
|
|
867
889
|
makeHeadlessInstanceComponent,
|
|
890
|
+
makePassthroughHeadlessInstanceComponent,
|
|
868
891
|
setActionCallerOptions,
|
|
869
892
|
wrapWithAutomation
|
|
870
893
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/stack-client-runtime",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"build:check-types": "tsc",
|
|
24
24
|
"clean": "rimraf dist",
|
|
25
25
|
"confirm": "npm run clean && npm run build && npm run build:check-types && npm run test",
|
|
26
|
-
"test": "
|
|
26
|
+
"test": "vitest run",
|
|
27
27
|
"test:watch": "vitest"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jay-framework/component": "^0.24.
|
|
31
|
-
"@jay-framework/fullstack-component": "^0.24.
|
|
32
|
-
"@jay-framework/runtime": "^0.24.
|
|
33
|
-
"@jay-framework/runtime-automation": "^0.24.
|
|
34
|
-
"@jay-framework/view-state-merge": "^0.24.
|
|
30
|
+
"@jay-framework/component": "^0.24.7",
|
|
31
|
+
"@jay-framework/fullstack-component": "^0.24.7",
|
|
32
|
+
"@jay-framework/runtime": "^0.24.7",
|
|
33
|
+
"@jay-framework/runtime-automation": "^0.24.7",
|
|
34
|
+
"@jay-framework/view-state-merge": "^0.24.7"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@jay-framework/dev-environment": "^0.24.
|
|
38
|
-
"@jay-framework/jay-cli": "^0.24.
|
|
37
|
+
"@jay-framework/dev-environment": "^0.24.7",
|
|
38
|
+
"@jay-framework/jay-cli": "^0.24.7",
|
|
39
39
|
"@types/express": "^5.0.2",
|
|
40
40
|
"@types/node": "^22.15.21",
|
|
41
41
|
"nodemon": "^3.0.3",
|