@builder.io/sdk-qwik 0.14.14 → 0.14.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.
@@ -4399,7 +4399,7 @@ function isFromTrustedHost(trustedHosts, e) {
4399
4399
  const url = new URL(e.origin), hostname = url.hostname;
4400
4400
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4401
4401
  }
4402
- const SDK_VERSION = "0.14.14";
4402
+ const SDK_VERSION = "0.14.15";
4403
4403
  const registry = {};
4404
4404
  function register(type, info) {
4405
4405
  let typeList = registry[type];
@@ -4397,7 +4397,7 @@ function isFromTrustedHost(trustedHosts, e) {
4397
4397
  const url = new URL(e.origin), hostname = url.hostname;
4398
4398
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4399
4399
  }
4400
- const SDK_VERSION = "0.14.14";
4400
+ const SDK_VERSION = "0.14.15";
4401
4401
  const registry = {};
4402
4402
  function register(type, info) {
4403
4403
  let typeList = registry[type];
@@ -7630,7 +7630,7 @@ function isFromTrustedHost(trustedHosts, e) {
7630
7630
  const url = new URL(e.origin), hostname = url.hostname;
7631
7631
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
7632
7632
  }
7633
- const SDK_VERSION = "0.14.14";
7633
+ const SDK_VERSION = "0.14.15";
7634
7634
  const registry = {};
7635
7635
  function register(type, info) {
7636
7636
  let typeList = registry[type];
@@ -7628,7 +7628,7 @@ function isFromTrustedHost(trustedHosts, e) {
7628
7628
  const url = new URL(e.origin), hostname = url.hostname;
7629
7629
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
7630
7630
  }
7631
- const SDK_VERSION = "0.14.14";
7631
+ const SDK_VERSION = "0.14.15";
7632
7632
  const registry = {};
7633
7633
  function register(type, info) {
7634
7634
  let typeList = registry[type];
@@ -289,15 +289,35 @@ if (typeof output === 'object' && output !== null) {
289
289
  output;
290
290
  `;
291
291
  };
292
+ let IVM_INSTANCE = null;
293
+ const getIvm = () => {
294
+ try {
295
+ if (IVM_INSTANCE)
296
+ ;
297
+ const dynRequiredIvm = nodeEvaluate.safeDynamicRequire("isolated-vm");
298
+ if (dynRequiredIvm)
299
+ return dynRequiredIvm;
300
+ } catch (error) {
301
+ logger.error("isolated-vm import error.", error);
302
+ }
303
+ throw new Error(`${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on Node server.
304
+
305
+ In certain Node environments, the SDK requires additional initialization steps. This can be achieved by
306
+ importing and calling \`initializeNodeRuntime()\` from "@builder.io/sdk-react/node/init". This must be done in
307
+ a server-only execution path within your application.
308
+
309
+ Please see the documentation for more information: https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments
310
+ `);
311
+ };
292
312
  const getIsolateContext = () => {
293
- const ivm = nodeEvaluate.safeDynamicRequire("isolated-vm");
313
+ const ivm = getIvm();
294
314
  const isolate = new ivm.Isolate({
295
315
  memoryLimit: 128
296
316
  });
297
317
  return isolate.createContextSync();
298
318
  };
299
319
  const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
300
- const ivm = nodeEvaluate.safeDynamicRequire("isolated-vm");
320
+ const ivm = getIvm();
301
321
  const state = fastClone({
302
322
  ...rootState,
303
323
  ...localState
@@ -4501,7 +4521,7 @@ function isFromTrustedHost(trustedHosts, e) {
4501
4521
  const url = new URL(e.origin), hostname = url.hostname;
4502
4522
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4503
4523
  }
4504
- const SDK_VERSION = "0.14.14";
4524
+ const SDK_VERSION = "0.14.15";
4505
4525
  const registry = {};
4506
4526
  function register(type, info) {
4507
4527
  let typeList = registry[type];
@@ -287,15 +287,35 @@ if (typeof output === 'object' && output !== null) {
287
287
  output;
288
288
  `;
289
289
  };
290
+ let IVM_INSTANCE = null;
291
+ const getIvm = () => {
292
+ try {
293
+ if (IVM_INSTANCE)
294
+ ;
295
+ const dynRequiredIvm = safeDynamicRequire("isolated-vm");
296
+ if (dynRequiredIvm)
297
+ return dynRequiredIvm;
298
+ } catch (error) {
299
+ logger.error("isolated-vm import error.", error);
300
+ }
301
+ throw new Error(`${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on Node server.
302
+
303
+ In certain Node environments, the SDK requires additional initialization steps. This can be achieved by
304
+ importing and calling \`initializeNodeRuntime()\` from "@builder.io/sdk-react/node/init". This must be done in
305
+ a server-only execution path within your application.
306
+
307
+ Please see the documentation for more information: https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments
308
+ `);
309
+ };
290
310
  const getIsolateContext = () => {
291
- const ivm = safeDynamicRequire("isolated-vm");
311
+ const ivm = getIvm();
292
312
  const isolate = new ivm.Isolate({
293
313
  memoryLimit: 128
294
314
  });
295
315
  return isolate.createContextSync();
296
316
  };
297
317
  const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
298
- const ivm = safeDynamicRequire("isolated-vm");
318
+ const ivm = getIvm();
299
319
  const state = fastClone({
300
320
  ...rootState,
301
321
  ...localState
@@ -4499,7 +4519,7 @@ function isFromTrustedHost(trustedHosts, e) {
4499
4519
  const url = new URL(e.origin), hostname = url.hostname;
4500
4520
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4501
4521
  }
4502
- const SDK_VERSION = "0.14.14";
4522
+ const SDK_VERSION = "0.14.15";
4503
4523
  const registry = {};
4504
4524
  function register(type, info) {
4505
4525
  let typeList = registry[type];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.14.14",
3
+ "version": "0.14.15",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.14.14";
1
+ export declare const SDK_VERSION = "0.14.15";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This function initializes the SDK on a Node server. It handles importing the
3
+ * `isolated-vm` package which is needed for dynamic bindings.
4
+ *
5
+ * NOTE: this function cannot be called on the client. You must call this function
6
+ * from a server-only location, such as:
7
+ * - The NextJS Pages router's `_document.tsx`
8
+ * - Your Remix route's `loader`
9
+ */
10
+ export declare const initializeNodeRuntime: () => void;
@@ -1,2 +1,8 @@
1
1
  import type { ExecutorArgs } from '../helpers';
2
+ /**
3
+ * Set the `isolated-vm` instance to be used by the node runtime.
4
+ * This is useful for environments that are not able to rely on our
5
+ * `safeDynamicRequire` trick to import the `isolated-vm` package.
6
+ */
7
+ export declare const setIvm: (ivm: typeof import('isolated-vm')) => void;
2
8
  export declare const runInNode: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
@@ -131,9 +131,9 @@ export interface GetContentOptions {
131
131
  /**
132
132
  * Optional override of the `fetch` function. (Defaults to global `fetch`)
133
133
  */
134
- fetch?: typeof global.fetch;
134
+ fetch?: (input: string, init?: object) => Promise<any>;
135
135
  /**
136
- * Optional fetch options to be passed to the `fetch` function.
136
+ * Optional fetch options to be passed as the second argument to the `fetch` function.
137
137
  */
138
- fetchOptions?: RequestInit;
138
+ fetchOptions?: object;
139
139
  }
@@ -1,3 +1,4 @@
1
+ export declare const MSG_PREFIX = "[Builder.io]: ";
1
2
  export declare const logger: {
2
3
  log: (...message: any[]) => void;
3
4
  error: (...message: any[]) => void;