@absolutejs/sync 1.11.0 → 1.12.1
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/engine/index.js +25 -4
- package/dist/engine/index.js.map +4 -4
- package/dist/engine/sandbox.d.ts +46 -0
- package/dist/index.js +29 -6
- package/dist/index.js.map +6 -6
- package/dist/testing.js +23 -3
- package/dist/testing.js.map +3 -3
- package/package.json +1 -1
package/dist/engine/index.js
CHANGED
|
@@ -1136,7 +1136,7 @@ var wrap = (source) => `
|
|
|
1136
1136
|
const userFn = (${source});
|
|
1137
1137
|
if (typeof userFn !== 'function') {
|
|
1138
1138
|
throw new Error(
|
|
1139
|
-
'sandboxedHandler must evaluate to (args, ctx, actions) => result; got ' +
|
|
1139
|
+
'sandboxedHandler must evaluate to (args, ctx, actions, unsafeHost) => result; got ' +
|
|
1140
1140
|
typeof userFn
|
|
1141
1141
|
);
|
|
1142
1142
|
}
|
|
@@ -1148,12 +1148,24 @@ var wrap = (source) => `
|
|
|
1148
1148
|
now: () => __dispatch(__callId, 'now'),
|
|
1149
1149
|
fetch: (url, init) => __dispatch(__callId, 'fetch', url, init)
|
|
1150
1150
|
};
|
|
1151
|
-
|
|
1151
|
+
// Escape hatch \u2014 host fns the mutation explicitly opted in to.
|
|
1152
|
+
// The Proxy means every property access is a host call; the
|
|
1153
|
+
// engine throws if the property name isn't declared in the
|
|
1154
|
+
// mutation's sandbox.unsafeHost map.
|
|
1155
|
+
const unsafeHost = new Proxy({}, {
|
|
1156
|
+
get: (_target, fnName) => {
|
|
1157
|
+
if (typeof fnName !== 'string') return undefined;
|
|
1158
|
+
return (...callArgs) =>
|
|
1159
|
+
__dispatch(__callId, 'unsafeHost', fnName, callArgs);
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
return userFn(args, ctx, actions, unsafeHost);
|
|
1152
1163
|
}
|
|
1153
1164
|
`;
|
|
1154
1165
|
var compile = async (source, config, bridgeFetch) => {
|
|
1155
1166
|
const { Reference, createIsolatedRunner, resolveIsolatePolicy } = await loadIsolatedJsc();
|
|
1156
1167
|
const callMap = new Map;
|
|
1168
|
+
const unsafeHost = config.unsafeHost;
|
|
1157
1169
|
const dispatch = new Reference((callId, op, ...rest) => {
|
|
1158
1170
|
const a = callMap.get(callId);
|
|
1159
1171
|
if (a === undefined) {
|
|
@@ -1172,6 +1184,14 @@ var compile = async (source, config, bridgeFetch) => {
|
|
|
1172
1184
|
return a.now();
|
|
1173
1185
|
case "fetch":
|
|
1174
1186
|
return runBridgeFetch(bridgeFetch, rest[0], rest[1]);
|
|
1187
|
+
case "unsafeHost": {
|
|
1188
|
+
const fnName = rest[0];
|
|
1189
|
+
const callArgs = rest[1] ?? [];
|
|
1190
|
+
if (unsafeHost === undefined || typeof unsafeHost[fnName] !== "function") {
|
|
1191
|
+
throw new Error(`sandboxedHandler called unsafeHost.${fnName}() but it was not declared in the mutation's sandbox.unsafeHost config. Declare it (and only the host fns you intend to expose) to opt in to the escape hatch.`);
|
|
1192
|
+
}
|
|
1193
|
+
return unsafeHost[fnName](...callArgs);
|
|
1194
|
+
}
|
|
1175
1195
|
default:
|
|
1176
1196
|
throw new Error(`unknown sandbox action op: ${String(op)}`);
|
|
1177
1197
|
}
|
|
@@ -2840,7 +2860,8 @@ var syncCdc = ({
|
|
|
2840
2860
|
headers: {
|
|
2841
2861
|
"cache-control": "no-cache, no-transform",
|
|
2842
2862
|
connection: "keep-alive",
|
|
2843
|
-
"content-type": "text/event-stream"
|
|
2863
|
+
"content-type": "text/event-stream",
|
|
2864
|
+
"x-accel-buffering": "no"
|
|
2844
2865
|
}
|
|
2845
2866
|
});
|
|
2846
2867
|
});
|
|
@@ -3140,5 +3161,5 @@ export {
|
|
|
3140
3161
|
CdcConsumerSlowError
|
|
3141
3162
|
};
|
|
3142
3163
|
|
|
3143
|
-
//# debugId=
|
|
3164
|
+
//# debugId=3473D89C765057E364756E2164756E21
|
|
3144
3165
|
//# sourceMappingURL=index.js.map
|