@immediately-run/sandpack-client 2.21.1 → 2.22.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/.ir-build-stamp.json +3 -3
- package/dist/clients/node/index.js +2 -2
- package/dist/clients/node/index.mjs +2 -2
- package/dist/clients/runtime/gestureGate.d.ts +19 -0
- package/dist/clients/runtime/iframe-protocol.d.ts +1 -1
- package/dist/clients/runtime/index.d.ts +33 -1
- package/dist/clients/runtime/index.js +297 -21
- package/dist/clients/runtime/index.mjs +296 -22
- package/dist/clients/runtime/initialization-guard.d.ts +64 -0
- package/dist/{consoleHook-BYuGaxe8.mjs → consoleHook-DT9Wd42J.mjs} +1 -1
- package/dist/{consoleHook-BRSVCdB0.js → consoleHook-vrsBdedj.js} +1 -1
- package/dist/{index-CetxPB1x.mjs → index-CSAGdFtt.mjs} +2 -2
- package/dist/{index-dX5nvjo5.js → index-Dnq1i5aM.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{types-KEkDKvIe.js → types-B3g_70H8.js} +34 -7
- package/dist/{types-BgalzxpH.mjs → types-DRg992RB.mjs} +34 -7
- package/dist/types.d.ts +19 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ var GUARDED_WRITE_METHODS = [
|
|
|
43
43
|
* (roadmap R3-110).
|
|
44
44
|
*
|
|
45
45
|
* This is a module-level function (not a class method) and its **only** reference
|
|
46
|
-
* is behind the `if (IS_DEV)` branch in
|
|
46
|
+
* is behind the `if (IS_DEV)` branch in {@link ensureGuard} — so once a consumer's
|
|
47
47
|
* production build folds `IS_DEV` to `false`, the branch and this whole function
|
|
48
48
|
* tree-shake away (a class method would be retained). No-op in production.
|
|
49
49
|
*/
|
|
@@ -71,6 +71,35 @@ function installOutOfBandGuard(fsContext) {
|
|
|
71
71
|
_loop_1(method);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The true raw write methods per bound context, captured once and shared by every
|
|
76
|
+
* SandpackFS instance that adopts that context. Without this, a second instance's
|
|
77
|
+
* constructor captures the first instance's wrapper as its "raw" method — because the
|
|
78
|
+
* guard has already replaced `fsContext.fs.promises` entries — so SandpackFS's own
|
|
79
|
+
* writes trip the guard once per prior adoption (the R3-614 stacking bug).
|
|
80
|
+
*/
|
|
81
|
+
var RAW = new WeakMap();
|
|
82
|
+
/**
|
|
83
|
+
* Return the context's raw write methods, capturing them and installing the out-of-band
|
|
84
|
+
* guard exactly once per context (see {@link installOutOfBandGuard}). Reads `RAW` first,
|
|
85
|
+
* so adopting the same context any number of times never re-wraps, never re-captures a
|
|
86
|
+
* wrapper as raw, and never disarms a sibling instance.
|
|
87
|
+
*/
|
|
88
|
+
function ensureGuard(fsContext) {
|
|
89
|
+
var existing = RAW.get(fsContext);
|
|
90
|
+
if (existing)
|
|
91
|
+
return existing;
|
|
92
|
+
var p = fsContext.fs.promises;
|
|
93
|
+
var raw = {
|
|
94
|
+
writeFile: p.writeFile.bind(p),
|
|
95
|
+
unlink: p.unlink.bind(p),
|
|
96
|
+
mkdir: p.mkdir.bind(p),
|
|
97
|
+
};
|
|
98
|
+
RAW.set(fsContext, raw);
|
|
99
|
+
if (IS_DEV)
|
|
100
|
+
installOutOfBandGuard(fsContext);
|
|
101
|
+
return raw;
|
|
102
|
+
}
|
|
74
103
|
var mountCounter = 0;
|
|
75
104
|
var normalize = function (path) {
|
|
76
105
|
return path.startsWith("/") ? path : "/".concat(path);
|
|
@@ -117,12 +146,10 @@ var SandpackFS = /** @class */ (function () {
|
|
|
117
146
|
* unmount in {@link dispose}. Unset for an adopted context, whose lifecycle
|
|
118
147
|
* belongs to the caller. */
|
|
119
148
|
this.ownedMountPoint = undefined;
|
|
120
|
-
var
|
|
121
|
-
this.rawWriteFile =
|
|
122
|
-
this.rawUnlink =
|
|
123
|
-
this.rawMkdir =
|
|
124
|
-
if (IS_DEV)
|
|
125
|
-
installOutOfBandGuard(fsContext);
|
|
149
|
+
var raw = ensureGuard(fsContext);
|
|
150
|
+
this.rawWriteFile = raw.writeFile;
|
|
151
|
+
this.rawUnlink = raw.unlink;
|
|
152
|
+
this.rawMkdir = raw.mkdir;
|
|
126
153
|
}
|
|
127
154
|
/**
|
|
128
155
|
* Create the `MessagePort` shared with the child iframe, wiring the iframe's
|
package/dist/types.d.ts
CHANGED
|
@@ -37,6 +37,18 @@ export interface ClientOptions {
|
|
|
37
37
|
* `allow-same-origin`). Required for the runtime client to transpile.
|
|
38
38
|
*/
|
|
39
39
|
babelWorkerURL?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Called when the client REFUSES to register a frame because it booted from a
|
|
42
|
+
* navigation the client did not perform (R3-353 — a sandboxed frame may always
|
|
43
|
+
* navigate itself, and the browsing context survives, so a page the app chose
|
|
44
|
+
* could otherwise post `initialized` and be handed this frame's grants).
|
|
45
|
+
*
|
|
46
|
+
* By the time this fires the frame has been blanked and the client destroyed:
|
|
47
|
+
* nothing was connected and no fs port was minted. The host's job is to surface
|
|
48
|
+
* it (and/or re-create the frame from a clean state), not to decide whether to
|
|
49
|
+
* allow it — that decision has already been made, fail-closed.
|
|
50
|
+
*/
|
|
51
|
+
onUnexpectedNavigation?: () => void;
|
|
40
52
|
/**
|
|
41
53
|
* Level of logging to do in the bundler
|
|
42
54
|
*/
|
|
@@ -239,7 +251,13 @@ export type ClientStatus = "initializing" | "installing-dependencies" | "transpi
|
|
|
239
251
|
export type SandpackMessageConsoleMethods = "log" | "debug" | "info" | "warn" | "error" | "table" | "clear" | "time" | "timeEnd" | "count" | "assert";
|
|
240
252
|
export interface BaseSandpackMessage {
|
|
241
253
|
type: string;
|
|
242
|
-
|
|
254
|
+
/**
|
|
255
|
+
* The sender's channel id. Newer peers mint it as a crypto-random hex STRING
|
|
256
|
+
* (R3-367 — 64 bits); ids older peers minted as numbers still flow, because
|
|
257
|
+
* each side compares the value it itself sent. Correlation only — never an
|
|
258
|
+
* authenticator (the evt.source check in IFrameProtocol is).
|
|
259
|
+
*/
|
|
260
|
+
$id?: string | number;
|
|
243
261
|
codesandbox?: boolean;
|
|
244
262
|
/**
|
|
245
263
|
* Transferable objects (e.g. a `MessagePort`) to hand to the iframe alongside
|