@immediately-run/sandpack-client 2.19.8

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.
Files changed (49) hide show
  1. package/README.md +26 -0
  2. package/dist/.ir-build-stamp.json +6 -0
  3. package/dist/base-DBh7xJX9.mjs +48 -0
  4. package/dist/base-DelKLlDk.js +50 -0
  5. package/dist/clients/base.d.ts +34 -0
  6. package/dist/clients/event-emitter.d.ts +10 -0
  7. package/dist/clients/iframe-factory.d.ts +27 -0
  8. package/dist/clients/index.d.ts +4 -0
  9. package/dist/clients/node/client.utils.d.ts +7 -0
  10. package/dist/clients/node/iframe.utils.d.ts +3 -0
  11. package/dist/clients/node/index.d.ts +49 -0
  12. package/dist/clients/node/index.js +631 -0
  13. package/dist/clients/node/index.mjs +629 -0
  14. package/dist/clients/node/inject-scripts/historyListener.d.ts +5 -0
  15. package/dist/clients/node/inject-scripts/index.d.ts +1 -0
  16. package/dist/clients/node/inject-scripts/resize.d.ts +5 -0
  17. package/dist/clients/node/taskManager.d.ts +20 -0
  18. package/dist/clients/node/types.d.ts +63 -0
  19. package/dist/clients/runtime/file-resolver-protocol.d.ts +17 -0
  20. package/dist/clients/runtime/iframe-protocol.d.ts +17 -0
  21. package/dist/clients/runtime/immutable-fetch-protocol.d.ts +39 -0
  22. package/dist/clients/runtime/index.d.ts +76 -0
  23. package/dist/clients/runtime/index.js +1046 -0
  24. package/dist/clients/runtime/index.mjs +1044 -0
  25. package/dist/clients/runtime/mime.d.ts +1 -0
  26. package/dist/clients/runtime/types.d.ts +129 -0
  27. package/dist/clients/runtime/utils.d.ts +8 -0
  28. package/dist/clients/static/index.d.ts +25 -0
  29. package/dist/clients/static/utils.d.ts +5 -0
  30. package/dist/consoleHook-DQVWjDRE.mjs +230 -0
  31. package/dist/consoleHook-znXctRzh.js +236 -0
  32. package/dist/fs/SandpackFS.d.ts +116 -0
  33. package/dist/iframe-factory-BcC-S_XQ.js +54 -0
  34. package/dist/iframe-factory-DybmkzJZ.mjs +51 -0
  35. package/dist/index--fILWAw8.js +210 -0
  36. package/dist/index-rbhm_KmF.mjs +208 -0
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.js +53 -0
  39. package/dist/index.mjs +40 -0
  40. package/dist/inject-scripts/consoleHook.d.ts +6 -0
  41. package/dist/types-BFONOA2L.mjs +531 -0
  42. package/dist/types-BIIEoWr6.js +534 -0
  43. package/dist/types.d.ts +348 -0
  44. package/dist/utils-BiVyytui.js +262 -0
  45. package/dist/utils-DG1HA4RZ.mjs +250 -0
  46. package/dist/utils.d.ts +18 -0
  47. package/dist/utils.js +13 -0
  48. package/dist/utils.mjs +2 -0
  49. package/package.json +82 -0
@@ -0,0 +1 @@
1
+ export declare const EXTENSIONS_MAP: Map<string, string>;
@@ -0,0 +1,129 @@
1
+ import type { BaseSandpackMessage, BundlerState, ClientStatus, NpmRegistry, ReactDevToolsMode, SandboxTestMessage, SandpackErrorMessage, SandpackLogLevel, SandpackMessageConsoleMethods, SandpackTemplate } from "../..";
2
+ export type SandpackRuntimeMessage = BaseSandpackMessage & ({
3
+ type: "initialized";
4
+ } | {
5
+ type: "start";
6
+ firstLoad?: boolean;
7
+ } | {
8
+ type: "status";
9
+ status: ClientStatus;
10
+ } | {
11
+ type: "state";
12
+ state: BundlerState;
13
+ } | {
14
+ type: "success";
15
+ } | ({
16
+ type: "action";
17
+ action: "show-error";
18
+ } & SandpackErrorMessage) | {
19
+ type: "action";
20
+ action: "notification";
21
+ notificationType: "error";
22
+ title: string;
23
+ } | {
24
+ type: "done";
25
+ compilatonError: boolean;
26
+ } | {
27
+ type: "urlchange";
28
+ url: string;
29
+ back: boolean;
30
+ forward: boolean;
31
+ } | {
32
+ type: "resize";
33
+ height: number;
34
+ } | {
35
+ type: "transpiler-context";
36
+ data: Record<string, Record<string, unknown>>;
37
+ } | {
38
+ type: "compile";
39
+ version: number;
40
+ isInitializationCompile?: boolean;
41
+ externalResources: string[];
42
+ hasFileResolver: boolean;
43
+ disableDependencyPreprocessing?: boolean;
44
+ experimental_enableServiceWorker?: boolean;
45
+ experimental_stableServiceWorkerId?: string;
46
+ template?: string | SandpackTemplate;
47
+ showOpenInCodeSandbox: boolean;
48
+ showErrorScreen: boolean;
49
+ showLoadingScreen: boolean;
50
+ skipEval: boolean;
51
+ clearConsoleDisabled?: boolean;
52
+ reactDevTools?: ReactDevToolsMode;
53
+ logLevel?: SandpackLogLevel;
54
+ customNpmRegistries?: NpmRegistry[];
55
+ teamId?: string;
56
+ sandboxId?: string;
57
+ } | {
58
+ type: "refresh";
59
+ } | {
60
+ type: "urlback";
61
+ } | {
62
+ type: "urlforward";
63
+ } | {
64
+ type: "get-transpiler-context";
65
+ } | {
66
+ type: "get-modules";
67
+ } | {
68
+ type: "fs-change";
69
+ paths: string[];
70
+ } | {
71
+ type: "mount-add";
72
+ mount: {
73
+ path: string;
74
+ type: string;
75
+ id?: string;
76
+ };
77
+ } | {
78
+ type: "mount-remove";
79
+ id?: string;
80
+ path?: string;
81
+ } | {
82
+ type: "all-modules";
83
+ data: Array<{
84
+ path: string;
85
+ code: string;
86
+ }>;
87
+ } | {
88
+ type: "activate-react-devtools";
89
+ } | {
90
+ type: "console";
91
+ log: Array<{
92
+ method: SandpackMessageConsoleMethods;
93
+ id: string;
94
+ data: string[];
95
+ }>;
96
+ } | SandboxTestMessage | {
97
+ type: "sign-in";
98
+ teamId: string;
99
+ } | {
100
+ type: "sign-out";
101
+ } | {
102
+ type: "dependencies";
103
+ data: {
104
+ state: "downloading_manifest";
105
+ } | {
106
+ state: "downloaded_module";
107
+ name: string;
108
+ total: number;
109
+ progress: number;
110
+ } | {
111
+ state: "starting";
112
+ };
113
+ });
114
+ export declare const CHANNEL_NAME = "$CSB_RELAY";
115
+ export interface IPreviewRequestMessage {
116
+ $channel: typeof CHANNEL_NAME;
117
+ $type: "preview/request";
118
+ id: string;
119
+ method: string;
120
+ url: string;
121
+ }
122
+ export interface IPreviewResponseMessage {
123
+ $channel: typeof CHANNEL_NAME;
124
+ $type: "preview/response";
125
+ id: string;
126
+ status: number;
127
+ headers: Record<string, string>;
128
+ body: string | Uint8Array;
129
+ }
@@ -0,0 +1,8 @@
1
+ type Dependencies = Record<string, string>;
2
+ interface PackageJSON {
3
+ dependencies?: Dependencies;
4
+ devDependencies?: Dependencies;
5
+ }
6
+ export declare function getTemplate(pkg: PackageJSON | null, modules: any): string | undefined;
7
+ export declare function getExtension(filepath: string): string;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ClientOptions, ListenerFunction, SandboxSetup, UnsubscribeFunction } from "../..";
2
+ import { SandpackClient } from "../base";
3
+ import type { SandpackNodeMessage } from "../node/types";
4
+ export declare class SandpackStatic extends SandpackClient {
5
+ private emitter;
6
+ private previewController;
7
+ iframe: HTMLIFrameElement;
8
+ selector: string;
9
+ element: Element;
10
+ constructor(selector: string | HTMLIFrameElement, sandboxSetup: SandboxSetup, options?: ClientOptions);
11
+ private injectContentIntoHead;
12
+ private injectProtocolScript;
13
+ private injectExternalResources;
14
+ private injectScriptIntoHead;
15
+ updateSandbox(setup?: SandboxSetup, _isInitializationCompile?: boolean): void;
16
+ private updateSandboxAsync;
17
+ private compile;
18
+ private eventListener;
19
+ /**
20
+ * Bundler communication
21
+ */
22
+ dispatch(message: SandpackNodeMessage): void;
23
+ listen(listener: ListenerFunction): UnsubscribeFunction;
24
+ destroy(): void;
25
+ }
@@ -0,0 +1,5 @@
1
+ import type { FileContent } from "static-browser-server";
2
+ export declare const insertHtmlAfterRegex: (regex: RegExp, content: string, insertable: string) => string | void;
3
+ export declare const writeBuffer: (content: string | Uint8Array) => Uint8Array;
4
+ export declare const readBuffer: (content: string | Uint8Array) => string;
5
+ export declare const validateHtml: (content: FileContent) => FileContent;
@@ -0,0 +1,230 @@
1
+ import { invariant } from 'outvariant';
2
+ import { c as createError } from './utils-DG1HA4RZ.mjs';
3
+ import './types-BFONOA2L.mjs';
4
+
5
+ var EventEmitter = /** @class */ (function () {
6
+ function EventEmitter() {
7
+ this.listeners = {};
8
+ this.listenersCount = 0;
9
+ this.channelId = Math.floor(Math.random() * 1000000);
10
+ this.listeners = [];
11
+ }
12
+ EventEmitter.prototype.cleanup = function () {
13
+ this.listeners = {};
14
+ this.listenersCount = 0;
15
+ };
16
+ EventEmitter.prototype.dispatch = function (message) {
17
+ Object.values(this.listeners).forEach(function (listener) { return listener(message); });
18
+ };
19
+ EventEmitter.prototype.listener = function (listener) {
20
+ var _this = this;
21
+ if (typeof listener !== "function") {
22
+ return function () {
23
+ return;
24
+ };
25
+ }
26
+ var listenerId = this.listenersCount;
27
+ this.listeners[listenerId] = listener;
28
+ this.listenersCount++;
29
+ return function () {
30
+ delete _this.listeners[listenerId];
31
+ };
32
+ };
33
+ return EventEmitter;
34
+ }());
35
+
36
+ function isCommand(char) {
37
+ return /[a-zA-Z.]/.test(char);
38
+ }
39
+ function isAlpha(char) {
40
+ return /[a-zA-Z]/.test(char);
41
+ }
42
+ function isWhitespace(char) {
43
+ return /\s/.test(char);
44
+ }
45
+ function isOperator(char) {
46
+ return /[&|]/.test(char);
47
+ }
48
+ function isArgument(char) {
49
+ return /-/.test(char);
50
+ }
51
+ function isString(char) {
52
+ return /["']/.test(char);
53
+ }
54
+ function isEnvVar(char) {
55
+ return isAlpha(char) && char === char.toUpperCase();
56
+ }
57
+ var TokenType;
58
+ (function (TokenType) {
59
+ TokenType["OR"] = "OR";
60
+ TokenType["AND"] = "AND";
61
+ TokenType["PIPE"] = "PIPE";
62
+ TokenType["Command"] = "Command";
63
+ TokenType["Argument"] = "Argument";
64
+ TokenType["String"] = "String";
65
+ TokenType["EnvVar"] = "EnvVar";
66
+ })(TokenType || (TokenType = {}));
67
+ var operators = new Map([
68
+ ["&&", { type: TokenType.AND }],
69
+ ["||", { type: TokenType.OR }],
70
+ ["|", { type: TokenType.PIPE }],
71
+ ["-", { type: TokenType.Argument }],
72
+ ]);
73
+ function tokenize(input) {
74
+ var current = 0;
75
+ var tokens = [];
76
+ function parseCommand() {
77
+ var value = "";
78
+ while (isCommand(input[current]) && current < input.length) {
79
+ value += input[current];
80
+ current++;
81
+ }
82
+ return { type: TokenType.Command, value: value };
83
+ }
84
+ function parseOperator() {
85
+ var value = "";
86
+ while (isOperator(input[current]) && current < input.length) {
87
+ value += input[current];
88
+ current++;
89
+ }
90
+ return operators.get(value);
91
+ }
92
+ function parseArgument() {
93
+ var value = "";
94
+ while ((isArgument(input[current]) || isAlpha(input[current])) &&
95
+ current < input.length) {
96
+ value += input[current];
97
+ current++;
98
+ }
99
+ return { type: TokenType.Argument, value: value };
100
+ }
101
+ function parseString() {
102
+ var openCloseQuote = input[current];
103
+ var value = input[current];
104
+ current++;
105
+ while (input[current] !== openCloseQuote && current < input.length) {
106
+ value += input[current];
107
+ current++;
108
+ }
109
+ value += input[current];
110
+ current++;
111
+ return { type: TokenType.String, value: value };
112
+ }
113
+ function parseEnvVars() {
114
+ var value = {};
115
+ var parseSingleEnv = function () {
116
+ var key = "";
117
+ var pair = "";
118
+ while (input[current] !== "=" && current < input.length) {
119
+ key += input[current];
120
+ current++;
121
+ }
122
+ // Skip equal
123
+ if (input[current] === "=") {
124
+ current++;
125
+ }
126
+ while (input[current] !== " " && current < input.length) {
127
+ pair += input[current];
128
+ current++;
129
+ }
130
+ value[key] = pair;
131
+ };
132
+ while (isEnvVar(input[current]) && current < input.length) {
133
+ parseSingleEnv();
134
+ current++;
135
+ }
136
+ return { type: TokenType.EnvVar, value: value };
137
+ }
138
+ while (current < input.length) {
139
+ var currentChar = input[current];
140
+ if (isWhitespace(currentChar)) {
141
+ current++;
142
+ continue;
143
+ }
144
+ switch (true) {
145
+ case isEnvVar(currentChar):
146
+ tokens.push(parseEnvVars());
147
+ break;
148
+ case isCommand(currentChar):
149
+ tokens.push(parseCommand());
150
+ break;
151
+ case isOperator(currentChar):
152
+ tokens.push(parseOperator());
153
+ break;
154
+ case isArgument(currentChar):
155
+ tokens.push(parseArgument());
156
+ break;
157
+ case isString(currentChar):
158
+ tokens.push(parseString());
159
+ break;
160
+ default:
161
+ throw new Error("Unknown character: ".concat(currentChar));
162
+ }
163
+ }
164
+ return tokens;
165
+ }
166
+
167
+ var counter = 0;
168
+ function generateRandomId() {
169
+ var now = Date.now();
170
+ var randomNumber = Math.round(Math.random() * 10000);
171
+ var count = (counter += 1);
172
+ return (+"".concat(now).concat(randomNumber).concat(count)).toString(16);
173
+ }
174
+ /**
175
+ * Figure out which script it must run to start a server
176
+ */
177
+ var findStartScriptPackageJson = function (packageJson) {
178
+ var scripts = {};
179
+ // TODO: support postinstall
180
+ var possibleKeys = ["dev", "start"];
181
+ try {
182
+ scripts = JSON.parse(packageJson).scripts;
183
+ }
184
+ catch (e) {
185
+ throw createError("Could not parse package.json file: " + e.message);
186
+ }
187
+ invariant(scripts, "Failed to start. Please provide a `start` or `dev` script on the package.json");
188
+ var _loop_1 = function (index) {
189
+ if (possibleKeys[index] in scripts) {
190
+ var script = possibleKeys[index];
191
+ var candidate = scripts[script];
192
+ var env_1 = {};
193
+ var command_1 = "";
194
+ var args_1 = [];
195
+ tokenize(candidate).forEach(function (item) {
196
+ var commandNotFoundYet = command_1 === "";
197
+ if (item.type === TokenType.EnvVar) {
198
+ env_1 = item.value;
199
+ }
200
+ if (item.type === TokenType.Command && commandNotFoundYet) {
201
+ command_1 = item.value;
202
+ }
203
+ if (item.type === TokenType.Argument ||
204
+ (!commandNotFoundYet && item.type === TokenType.Command)) {
205
+ args_1.push(item.value);
206
+ }
207
+ // TODO: support TokenType.AND, TokenType.OR, TokenType.PIPE
208
+ });
209
+ return { value: [command_1, args_1, { env: env_1 }] };
210
+ }
211
+ };
212
+ for (var index = 0; index < possibleKeys.length; index++) {
213
+ var state_1 = _loop_1(index);
214
+ if (typeof state_1 === "object")
215
+ return state_1.value;
216
+ }
217
+ throw createError("Failed to start. Please provide a `start` or `dev` script on the package.json");
218
+ };
219
+ var getMessageFromError = function (error) {
220
+ if (typeof error === "string")
221
+ return error;
222
+ if (typeof error === "object" && "message" in error) {
223
+ return error.message;
224
+ }
225
+ return createError("The server could not be reached. Make sure that the node script is running and that a port has been started.");
226
+ };
227
+
228
+ var consoleHook = "function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,\"default\")?t.default:t}var r,e,n,a={},o={},i={},u={},s={},f={};function c(){return n||(n=1,f.__esModule=!0,f.update=f.state=void 0,f.update=function(t){f.state=t}),f}var l,d,p={},h={};function m(){return d||(d=1,function(t){var r=p&&p.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};t.__esModule=!0;var e=r((l||(l=1,function(t){var r=h&&h.__assign||function(){return r=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},r.apply(this,arguments)};t.__esModule=!0,t.initialState=void 0,t.initialState={timings:{},count:{}};var e=function(){return\"undefined\"!=typeof performance&&performance.now?performance.now():Date.now()};t.default=function(n,a){var o,i,u;switch(void 0===n&&(n=t.initialState),a.type){case\"COUNT\":var s=n.count[a.name]||0;return r(r({},n),{count:r(r({},n.count),(o={},o[a.name]=s+1,o))});case\"TIME_START\":return r(r({},n),{timings:r(r({},n.timings),(i={},i[a.name]={start:e()},i))});case\"TIME_END\":var f=n.timings[a.name],c=e(),l=c-f.start;return r(r({},n),{timings:r(r({},n.timings),(u={},u[a.name]=r(r({},f),{end:c,time:l}),u))});default:return n}}}(h)),h)),n=c();t.default=function(t){(0,n.update)((0,e.default)(n.state,t))}}(p)),p}var y,v,_={};function b(){return y||(y=1,_.__esModule=!0,_.timeEnd=_.timeStart=_.count=void 0,_.count=function(t){return{type:\"COUNT\",name:t}},_.timeStart=function(t){return{type:\"TIME_START\",name:t}},_.timeEnd=function(t){return{type:\"TIME_END\",name:t}}),_}var g,M,S,T={},O={};var w,A,j,z,E={},k={},C={},D={},I={};var N,R,x,P,V={},B={};function L(){return R||(R=1,function(t){t.__esModule=!0;var r=\"@t\",e=/^#*@(t|r)$/,n=\"__console_feed_remaining__\",a=(0,eval)(\"this\"),o=\"function\"==typeof ArrayBuffer,i=\"function\"==typeof Map,u=\"function\"==typeof Set,s=[\"Int8Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"Int16Array\",\"Uint16Array\",\"Int32Array\",\"Uint32Array\",\"Float32Array\",\"Float64Array\"],f=Array.prototype.slice,c={serialize:function(t){return JSON.stringify(t)},deserialize:function(t){return JSON.parse(t)}},l=function(){function t(t,r,e){this.references=t,this.transforms=r,this.transformsMap=this._makeTransformsMap(),this.circularCandidates=[],this.circularCandidatesDescrs=[],this.circularRefCount=0,this.limit=null!=e?e:1/0}return t._createRefMark=function(t){var r=Object.create(null);return r[\"@r\"]=t,r},t.prototype._createCircularCandidate=function(t,r,e){this.circularCandidates.push(t),this.circularCandidatesDescrs.push({parent:r,key:e,refIdx:-1})},t.prototype._applyTransform=function(t,e,n,a){var o=Object.create(null),i=a.toSerializable(t);return\"object\"==typeof i&&this._createCircularCandidate(t,e,n),o[r]=a.type,o.data=this._handleValue(function(){return i},e,n),o},t.prototype._handleArray=function(t){for(var r=[],e=Math.min(t.length,this.limit),a=t.length-e,o=function(e){r[e]=i._handleValue(function(){return t[e]},r,e)},i=this,u=0;u<e;u++)o(u);return r[e]=n+a,r},t.prototype._handlePlainObject=function(t){var r,a,o=Object.create(null),i=0,u=0,s=function(r){if(Reflect.has(t,r)){if(i>=f.limit)return u++,\"continue\";var n=e.test(r)?\"#\".concat(r):r;o[n]=f._handleValue(function(){return t[r]},o,n),i++,u++}},f=this;for(var c in t)s(c);var l=u-i,d=null===(a=null===(r=null==t?void 0:t.__proto__)||void 0===r?void 0:r.constructor)||void 0===a?void 0:a.name;return d&&\"Object\"!==d&&(o.constructor={name:d}),l&&(o[n]=l),o},t.prototype._handleObject=function(t,r,e){return this._createCircularCandidate(t,r,e),Array.isArray(t)?this._handleArray(t):this._handlePlainObject(t)},t.prototype._ensureCircularReference=function(r){var e=this.circularCandidates.indexOf(r);if(e>-1){var n=this.circularCandidatesDescrs[e];return-1===n.refIdx&&(n.refIdx=n.parent?++this.circularRefCount:0),t._createRefMark(n.refIdx)}return null},t.prototype._handleValue=function(t,r,e){try{var n=t(),a=typeof n,o=\"object\"===a&&null!==n;if(o){var i=this._ensureCircularReference(n);if(i)return i}var u=this._findTransform(a,n);return u?this._applyTransform(n,r,e,u):o?this._handleObject(n,r,e):n}catch(t){try{return this._handleValue(function(){return t instanceof Error?t:new Error(t)},r,e)}catch(t){return null}}},t.prototype._makeTransformsMap=function(){if(i){var t=new Map;return this.transforms.forEach(function(r){r.lookup&&t.set(r.lookup,r)}),t}},t.prototype._findTransform=function(t,r){if(i&&r&&r.constructor&&(null==(a=this.transformsMap.get(r.constructor))?void 0:a.shouldTransform(t,r)))return a;for(var e=0,n=this.transforms;e<n.length;e++){var a;if((a=n[e]).shouldTransform(t,r))return a}},t.prototype.transform=function(){for(var r=this,e=[this._handleValue(function(){return r.references},null,null)],n=0,a=this.circularCandidatesDescrs;n<a.length;n++){var o=a[n];o.refIdx>0&&(e[o.refIdx]=o.parent[o.key],o.parent[o.key]=t._createRefMark(o.refIdx))}return e},t}(),d=function(){function t(t,r){this.activeTransformsStack=[],this.visitedRefs=Object.create(null),this.references=t,this.transformMap=r}return t.prototype._handlePlainObject=function(t){var r=Object.create(null);for(var n in\"constructor\"in t&&(t.constructor&&\"string\"==typeof t.constructor.name||(t.constructor={name:\"Object\"})),t)t.hasOwnProperty(n)&&(this._handleValue(t[n],t,n),e.test(n)&&(r[n.substring(1)]=t[n],delete t[n]));for(var a in r)t[a]=r[a]},t.prototype._handleTransformedObject=function(t,e,n){var a=t[r],o=this.transformMap[a];if(!o)throw new Error(\"Can't find transform for \\\"\".concat(a,'\" type.'));this.activeTransformsStack.push(t),this._handleValue(t.data,t,\"data\"),this.activeTransformsStack.pop(),e[n]=o.fromSerializable(t.data)},t.prototype._handleCircularSelfRefDuringTransform=function(t,r,e){var n=this.references;Object.defineProperty(r,e,{val:void 0,configurable:!0,enumerable:!0,get:function(){return void 0===this.val&&(this.val=n[t]),this.val},set:function(t){this.val=t}})},t.prototype._handleCircularRef=function(t,r,e){this.activeTransformsStack.includes(this.references[t])?this._handleCircularSelfRefDuringTransform(t,r,e):(this.visitedRefs[t]||(this.visitedRefs[t]=!0,this._handleValue(this.references[t],this.references,t)),r[e]=this.references[t])},t.prototype._handleValue=function(t,e,n){if(\"object\"==typeof t&&null!==t){var a=t[\"@r\"];if(void 0!==a)this._handleCircularRef(a,e,n);else if(t[r])this._handleTransformedObject(t,e,n);else if(Array.isArray(t))for(var o=0;o<t.length;o++)this._handleValue(t[o],t,o);else this._handlePlainObject(t)}},t.prototype.transform=function(){return this.visitedRefs[0]=!0,this._handleValue(this.references[0],this.references,0),this.references[0]},t}(),p=[{type:\"[[NaN]]\",shouldTransform:function(t,r){return\"number\"===t&&isNaN(r)},toSerializable:function(){return\"\"},fromSerializable:function(){return NaN}},{type:\"[[undefined]]\",shouldTransform:function(t){return\"undefined\"===t},toSerializable:function(){return\"\"},fromSerializable:function(){}},{type:\"[[Date]]\",lookup:Date,shouldTransform:function(t,r){return r instanceof Date},toSerializable:function(t){return t.getTime()},fromSerializable:function(t){var r=new Date;return r.setTime(t),r}},{type:\"[[RegExp]]\",lookup:RegExp,shouldTransform:function(t,r){return r instanceof RegExp},toSerializable:function(t){var r={src:t.source,flags:\"\"};return t.globalThis&&(r.flags+=\"g\"),t.ignoreCase&&(r.flags+=\"i\"),t.multiline&&(r.flags+=\"m\"),r},fromSerializable:function(t){return new RegExp(t.src,t.flags)}},{type:\"[[Error]]\",lookup:Error,shouldTransform:function(t,r){return r instanceof Error},toSerializable:function(t){var r,e;return t.stack||null===(e=(r=Error).captureStackTrace)||void 0===e||e.call(r,t),{name:t.name,message:t.message,stack:t.stack}},fromSerializable:function(t){var r=new(a[t.name]||Error)(t.message);return r.stack=t.stack,r}},{type:\"[[ArrayBuffer]]\",lookup:o&&ArrayBuffer,shouldTransform:function(t,r){return o&&r instanceof ArrayBuffer},toSerializable:function(t){var r=new Int8Array(t);return f.call(r)},fromSerializable:function(t){if(o){var r=new ArrayBuffer(t.length);return new Int8Array(r).set(t),r}return t}},{type:\"[[TypedArray]]\",shouldTransform:function(t,r){if(o)return ArrayBuffer.isView(r)&&!(r instanceof DataView);for(var e=0,n=s;e<n.length;e++){var i=n[e];if(\"function\"==typeof a[i]&&r instanceof a[i])return!0}return!1},toSerializable:function(t){return{ctorName:t.constructor.name,arr:f.call(t)}},fromSerializable:function(t){return\"function\"==typeof a[t.ctorName]?new a[t.ctorName](t.arr):t.arr}},{type:\"[[Map]]\",lookup:i&&Map,shouldTransform:function(t,r){return i&&r instanceof Map},toSerializable:function(t){var r=[];return t.forEach(function(t,e){r.push(e),r.push(t)}),r},fromSerializable:function(t){if(i){for(var r=new Map,e=0;e<t.length;e+=2)r.set(t[e],t[e+1]);return r}for(var n=[],a=0;a<t.length;a+=2)n.push([t[e],t[e+1]]);return n}},{type:\"[[Set]]\",lookup:u&&Set,shouldTransform:function(t,r){return u&&r instanceof Set},toSerializable:function(t){var r=[];return t.forEach(function(t){r.push(t)}),r},fromSerializable:function(t){if(u){for(var r=new Set,e=0;e<t.length;e++)r.add(t[e]);return r}return t}}],h=function(){function t(t){this.transforms=[],this.transformsMap=Object.create(null),this.serializer=t||c,this.addTransforms(p)}return t.prototype.addTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r];if(this.transformsMap[n.type])throw new Error('Transform with type \"'.concat(n.type,'\" was already added.'));this.transforms.push(n),this.transformsMap[n.type]=n}return this},t.prototype.removeTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r],a=this.transforms.indexOf(n);a>-1&&this.transforms.splice(a,1),delete this.transformsMap[n.type]}return this},t.prototype.encode=function(t,r){var e=new l(t,this.transforms,r).transform();return this.serializer.serialize(e)},t.prototype.decode=function(t){var r=this.serializer.deserialize(t);return new d(r,this.transformsMap).transform()},t}();t.default=h}(B)),B}function H(){if(x)return E;x=1;var t=E&&E.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};E.__esModule=!0,E.Decode=E.Encode=void 0;var r,e,n=t((w||(w=1,(r=k).__esModule=!0,function(t){t[t.infinity=0]=\"infinity\",t[t.minusInfinity=1]=\"minusInfinity\",t[t.minusZero=2]=\"minusZero\"}(e||(e={})),r.default={type:\"Arithmetic\",lookup:Number,shouldTransform:function(t,r){return\"number\"===t&&(r===1/0||r===-1/0||function(t){return 1/t==-1/0}(r))},toSerializable:function(t){return t===1/0?e.infinity:t===-1/0?e.minusInfinity:e.minusZero},fromSerializable:function(t){return t===e.infinity?1/0:t===e.minusInfinity?-1/0:t===e.minusZero?-0:t}}),k)),a=t(function(){return A||(A=1,(t=C).__esModule=!0,t.default={type:\"BigInt\",shouldTransform:function(t,r){return\"bigint\"==typeof r},toSerializable:function(t){return\"\".concat(t,\"n\")},fromSerializable:function(t){return BigInt(t.slice(0,-1))}}),C;var t}()),o=t(function(){return j||(j=1,(t=D).__esModule=!0,t.default={type:\"Function\",lookup:Function,shouldTransform:function(t,r){return\"function\"==typeof r},toSerializable:function(t){var r=\"\";try{r=t.toString().substring(r.indexOf(\"{\")+1,r.lastIndexOf(\"}\"))}catch(t){}return{name:t.name,body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){try{var r=function(){};return\"string\"==typeof t.name&&Object.defineProperty(r,\"name\",{value:t.name,writable:!1}),\"string\"==typeof t.body&&Object.defineProperty(r,\"body\",{value:t.body,writable:!1}),\"string\"==typeof t.proto&&(r.constructor={name:t.proto}),r}catch(r){return t}}}),D;var t}()),i=t((z||(z=1,function(t){var r;function e(t){for(var r={},e=0,n=t.attributes;e<n.length;e++){var a=n[e];r[a.name]=a.value}return r}t.__esModule=!0,t.default={type:\"HTMLElement\",shouldTransform:function(t,r){return r&&r.children&&\"string\"==typeof r.innerHTML&&\"string\"==typeof r.tagName},toSerializable:function(t){return{tagName:t.tagName.toLowerCase(),attributes:e(t),innerHTML:t.innerHTML}},fromSerializable:function(t){try{var e=(r||(r=document.implementation.createHTMLDocument(\"sandbox\"))).createElement(t.tagName);e.innerHTML=t.innerHTML;for(var n=0,a=Object.keys(t.attributes);n<a.length;n++){var o=a[n];try{e.setAttribute(o,t.attributes[o])}catch(t){}}return e}catch(r){return t}}}}(I)),I)),u=t(function(){return N||(N=1,r=V&&V.__assign||function(){return r=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},r.apply(this,arguments)},(t=V).__esModule=!0,t.default={type:\"Map\",lookup:Map,shouldTransform:function(t,r){return r&&r.constructor&&\"Map\"===r.constructor.name},toSerializable:function(t){var r={};return t.forEach(function(t,e){var n=\"object\"==typeof e?JSON.stringify(e):e;r[n]=t}),{name:\"Map\",body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){var e=t.body,n=r({},e);return\"string\"==typeof t.proto&&(n.constructor={name:t.proto}),n}}),V;var t,r}()),s=t(L()),f=[i.default,o.default,n.default,u.default,a.default],c=new s.default;return c.addTransforms(f),E.Encode=function(t,r){return JSON.parse(c.encode(t,r))},E.Decode=function(t){var r=c.decode(JSON.stringify(t));return r.data.pop(),r},E}var U=t((P||(P=1,function(t){var n=a&&a.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};t.__esModule=!0;var f=n((r||(r=1,function(t){t.__esModule=!0,t.default=[\"log\",\"debug\",\"info\",\"warn\",\"error\",\"table\",\"clear\",\"time\",\"timeEnd\",\"count\",\"assert\",\"command\",\"result\",\"dir\"]}(o)),o)),l=n((S||(S=1,function(t){var r=i&&i.__assign||function(){return r=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},r.apply(this,arguments)},n=i&&i.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e);var a=Object.getOwnPropertyDescriptor(r,e);a&&!(\"get\"in a?!r.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return r[e]}}),Object.defineProperty(t,n,a)}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),a=i&&i.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,\"default\",{enumerable:!0,value:r})}:function(t,r){t.default=r}),o=i&&i.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var e in t)\"default\"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&n(r,t,e);return a(r,t),r},f=i&&i.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return t.concat(n||Array.prototype.slice.call(r))},l=i&&i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};t.__esModule=!0;var d=l(function(){return e||(e=1,(t=u).__esModule=!0,t.default=function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+\"-\"+t()+\"-\"+t()+\"-\"+t()+\"-\"+t()+\"-\"+Date.now()}),u;var t}()),p=o(function(){if(v)return s;v=1;var t=s&&s.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};s.__esModule=!0,s.stop=s.start=void 0;var r=c(),e=t(m()),n=b();return s.start=function(t){(0,e.default)((0,n.timeStart)(t))},s.stop=function(t){var a=null===r.state||void 0===r.state?void 0:r.state.timings[t];if(a&&!a.end){(0,e.default)((0,n.timeEnd)(t));var o=r.state.timings[t].time;return{method:\"log\",data:[\"\".concat(t,\": \").concat(o,\"ms\")]}}return{method:\"warn\",data:[\"Timer '\".concat(t,\"' does not exist\")]}},s}()),h=o(function(){if(g)return T;g=1;var t=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};T.__esModule=!0,T.increment=void 0;var r=c(),e=t(m()),n=b();return T.increment=function(t){(0,e.default)((0,n.count)(t));var a=r.state.count[t];return{method:\"log\",data:[\"\".concat(t,\": \").concat(a)]}},T}()),y=o(function(){if(M)return O;M=1;var t=O&&O.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return t.concat(n||Array.prototype.slice.call(r))};return O.__esModule=!0,O.test=void 0,O.test=function(r){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return!r&&(0===e.length&&e.push(\"console.assert\"),{method:\"error\",data:t([\"Assertion failed:\"],e,!0)})},O}());t.default=function(t,e,n){var a=n||(0,d.default)();switch(t){case\"clear\":return{method:t,id:a};case\"count\":return!!(o=\"string\"==typeof e[0]?e[0]:\"default\")&&r(r({},h.increment(o)),{id:a});case\"time\":case\"timeEnd\":var o;return!!(o=\"string\"==typeof e[0]?e[0]:\"default\")&&(\"time\"===t?(p.start(o),!1):r(r({},p.stop(o)),{id:a}));case\"assert\":if(0!==e.length){var i=y.test.apply(y,f([e[0]],e.slice(1),!1));if(i)return r(r({},i),{id:a})}return!1;case\"error\":return{method:t,id:a,data:e.map(function(t){try{return t.stack||t}catch(r){return t}})};default:return{method:t,id:a,data:e}}}}(i)),i)),d=H();t.default=function(t,r,e,n){void 0===e&&(e=!0);for(var a=t,o={pointers:{},src:{npm:\"https://npmjs.com/package/console-feed\",github:\"https://github.com/samdenty/console-feed\"}},i=function(t){var i=a[t];a[t]=function(){i.apply(this,arguments);var a=[].slice.call(arguments);setTimeout(function(){var o=(0,l.default)(t,a);if(o){var i=o;e&&(i=(0,d.Encode)(o,n)),r(i,o)}})},o.pointers[t]=i},u=0,s=f.default;u<s.length;u++)i(s[u]);return a.feed=o,a}}(a)),a)),J=H();U(window.console,function(t){var r=J.Encode(t);parent.postMessage({type:\"console\",codesandbox:!0,log:Array.isArray(r)?r[0]:r,channelId:scope.channelId},\"*\")});\n";
229
+
230
+ export { EventEmitter as E, getMessageFromError as a, consoleHook as c, findStartScriptPackageJson as f, generateRandomId as g };