@squiz/render-runtime-lib 1.2.1-alpha.63 → 1.2.1-alpha.70

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.
@@ -0,0 +1,17 @@
1
+ -- CreateTable
2
+ CREATE TABLE "component" (
3
+ "name" VARCHAR(128) NOT NULL,
4
+
5
+ CONSTRAINT "component_pkey" PRIMARY KEY ("name")
6
+ );
7
+
8
+ -- CreateTable
9
+ CREATE TABLE "component_version" (
10
+ "component_name" VARCHAR(128) NOT NULL,
11
+ "version" VARCHAR(128) NOT NULL,
12
+
13
+ CONSTRAINT "component_version_pkey" PRIMARY KEY ("component_name","version")
14
+ );
15
+
16
+ -- AddForeignKey
17
+ ALTER TABLE "component_version" ADD CONSTRAINT "component_version_component_name_fkey" FOREIGN KEY ("component_name") REFERENCES "component"("name") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -1,6 +1,17 @@
1
1
  import { ExecuteComponentTask } from '@squiz/component-lib';
2
+ declare type ComponentReturn = string | object;
2
3
  export declare class ComponentFixture {
3
- static fixtureDirectory: string;
4
+ static fixtureRootDirectory: string | undefined;
5
+ protected static getFixtureRootDirectory(): string;
6
+ static setupFullComponentDirectory(returnObj: ComponentReturn): Promise<{
7
+ fixtureDirectory: string;
8
+ version: string;
9
+ componentName: string;
10
+ }>;
4
11
  static new(returnObj: string | object): Promise<ExecuteComponentTask>;
5
12
  static updateComponent(component: ExecuteComponentTask, output: string | object): Promise<ExecuteComponentTask>;
13
+ private static createFixtureDirectory;
14
+ private static createVersionDirectory;
15
+ private static createManifest;
6
16
  }
17
+ export {};
@@ -1,2 +1,4 @@
1
+ import supertest from 'supertest';
1
2
  import { type RenderRuntimeConfig } from '../../';
2
- export declare const testConfig: RenderRuntimeConfig;
3
+ export declare function getTestConfig(port: number): RenderRuntimeConfig;
4
+ export declare function getTestServer(): supertest.SuperTest<supertest.Test>;
@@ -0,0 +1,2 @@
1
+ export * from './helpers/fixtures';
2
+ export * from './helpers/stack';
@@ -0,0 +1 @@
1
+ export declare function getManifestPath(componentName: string, version: string, isInProductionMode: boolean): Promise<string>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isInProductionMode(): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  import { type Express } from 'express';
2
- export declare function setupApp(): Express;
2
+ import { ConnectionManager } from '@squiz/component-db-lib';
3
+ export declare function setupApp(db?: ConnectionManager): Express;
@@ -0,0 +1 @@
1
+ export declare function definitionRouteTests(rootUrl: string, accessingUrl: string): void;
@@ -0,0 +1 @@
1
+ export declare function renderRouteTests(rootUrl: string, accessingUrl: string): void;
@@ -0,0 +1 @@
1
+ export declare function staticRouteTests(url: string): void;
@@ -1,15 +1,17 @@
1
1
  /// <reference types="node" />
2
2
  import { type Server } from 'http';
3
+ import { ConnectionManager } from '@squiz/component-db-lib';
3
4
  export interface WebserverConfig {
4
5
  port?: number;
5
6
  rootUrl: string;
7
+ shouldRunMigrations: boolean;
6
8
  }
7
9
  export declare class Webserver {
8
10
  private static singleton;
9
11
  private static config;
10
12
  static get(): Server;
11
13
  static getConfig(): WebserverConfig;
12
- static start(config: WebserverConfig): Promise<Server>;
14
+ static start(config: WebserverConfig, db?: ConnectionManager): Promise<Server>;
13
15
  static stop(): void;
14
16
  private static mergeConfig;
15
17
  }
@@ -102,6 +102,8 @@ const thisErrorCaptureStackTrace = Error.captureStackTrace;
102
102
 
103
103
  const thisSymbolToString = Symbol.prototype.toString;
104
104
  const thisSymbolToStringTag = Symbol.toStringTag;
105
+ const thisSymbolIterator = Symbol.iterator;
106
+ const thisSymbolNodeJSUtilInspectCustom = Symbol.for('nodejs.util.inspect.custom');
105
107
 
106
108
  /**
107
109
  * VMError.
@@ -348,7 +350,11 @@ function createBridge(otherInit, registerProxy) {
348
350
  constructor(object) {
349
351
  // Note: object@other(unsafe) throws@this(unsafe)
350
352
  super();
351
- this.object = object;
353
+ this.objectWrapper = () => object;
354
+ }
355
+
356
+ getObject() {
357
+ return this.objectWrapper();
352
358
  }
353
359
 
354
360
  getFactory() {
@@ -408,7 +414,7 @@ function createBridge(otherInit, registerProxy) {
408
414
 
409
415
  get(target, key, receiver) {
410
416
  // Note: target@this(unsafe) key@prim receiver@this(unsafe) throws@this(unsafe)
411
- const object = this.object; // @other(unsafe)
417
+ const object = this.getObject(); // @other(unsafe)
412
418
  switch (key) {
413
419
  case 'constructor': {
414
420
  const desc = otherSafeGetOwnPropertyDescriptor(object, key);
@@ -447,7 +453,7 @@ function createBridge(otherInit, registerProxy) {
447
453
 
448
454
  set(target, key, value, receiver) {
449
455
  // Note: target@this(unsafe) key@prim value@this(unsafe) receiver@this(unsafe) throws@this(unsafe)
450
- const object = this.object; // @other(unsafe)
456
+ const object = this.getObject(); // @other(unsafe)
451
457
  if (key === '__proto__' && !thisOtherHasOwnProperty(object, key)) {
452
458
  return this.setPrototypeOf(target, value);
453
459
  }
@@ -471,7 +477,7 @@ function createBridge(otherInit, registerProxy) {
471
477
 
472
478
  apply(target, context, args) {
473
479
  // Note: target@this(unsafe) context@this(unsafe) args@this(safe-array) throws@this(unsafe)
474
- const object = this.object; // @other(unsafe)
480
+ const object = this.getObject(); // @other(unsafe)
475
481
  let ret; // @other(unsafe)
476
482
  try {
477
483
  context = otherFromThis(context);
@@ -485,7 +491,7 @@ function createBridge(otherInit, registerProxy) {
485
491
 
486
492
  construct(target, args, newTarget) {
487
493
  // Note: target@this(unsafe) args@this(safe-array) newTarget@this(unsafe) throws@this(unsafe)
488
- const object = this.object; // @other(unsafe)
494
+ const object = this.getObject(); // @other(unsafe)
489
495
  let ret; // @other(unsafe)
490
496
  try {
491
497
  args = otherFromThisArguments(args);
@@ -498,14 +504,14 @@ function createBridge(otherInit, registerProxy) {
498
504
 
499
505
  getOwnPropertyDescriptorDesc(target, prop, desc) {
500
506
  // Note: target@this(unsafe) prop@prim desc@other{safe} throws@this(unsafe)
501
- const object = this.object; // @other(unsafe)
507
+ const object = this.getObject(); // @other(unsafe)
502
508
  if (desc && typeof object === 'function' && (prop === 'arguments' || prop === 'caller' || prop === 'callee')) desc.value = null;
503
509
  return desc;
504
510
  }
505
511
 
506
512
  getOwnPropertyDescriptor(target, prop) {
507
513
  // Note: target@this(unsafe) prop@prim throws@this(unsafe)
508
- const object = this.object; // @other(unsafe)
514
+ const object = this.getObject(); // @other(unsafe)
509
515
  let desc; // @other(safe)
510
516
  try {
511
517
  desc = otherSafeGetOwnPropertyDescriptor(object, prop);
@@ -551,7 +557,7 @@ function createBridge(otherInit, registerProxy) {
551
557
 
552
558
  defineProperty(target, prop, desc) {
553
559
  // Note: target@this(unsafe) prop@prim desc@this(unsafe) throws@this(unsafe)
554
- const object = this.object; // @other(unsafe)
560
+ const object = this.getObject(); // @other(unsafe)
555
561
  if (!thisReflectSetPrototypeOf(desc, null)) throw thisUnexpected();
556
562
 
557
563
  desc = this.definePropertyDesc(target, prop, desc);
@@ -604,7 +610,7 @@ function createBridge(otherInit, registerProxy) {
604
610
 
605
611
  deleteProperty(target, prop) {
606
612
  // Note: target@this(unsafe) prop@prim throws@this(unsafe)
607
- const object = this.object; // @other(unsafe)
613
+ const object = this.getObject(); // @other(unsafe)
608
614
  try {
609
615
  return otherReflectDeleteProperty(object, prop) === true;
610
616
  } catch (e) { // @other(unsafe)
@@ -614,7 +620,7 @@ function createBridge(otherInit, registerProxy) {
614
620
 
615
621
  has(target, key) {
616
622
  // Note: target@this(unsafe) key@prim throws@this(unsafe)
617
- const object = this.object; // @other(unsafe)
623
+ const object = this.getObject(); // @other(unsafe)
618
624
  try {
619
625
  return otherReflectHas(object, key) === true;
620
626
  } catch (e) { // @other(unsafe)
@@ -624,7 +630,7 @@ function createBridge(otherInit, registerProxy) {
624
630
 
625
631
  isExtensible(target) {
626
632
  // Note: target@this(unsafe) throws@this(unsafe)
627
- const object = this.object; // @other(unsafe)
633
+ const object = this.getObject(); // @other(unsafe)
628
634
  try {
629
635
  if (otherReflectIsExtensible(object)) return true;
630
636
  } catch (e) { // @other(unsafe)
@@ -638,7 +644,7 @@ function createBridge(otherInit, registerProxy) {
638
644
 
639
645
  ownKeys(target) {
640
646
  // Note: target@this(unsafe) throws@this(unsafe)
641
- const object = this.object; // @other(unsafe)
647
+ const object = this.getObject(); // @other(unsafe)
642
648
  let res; // @other(unsafe)
643
649
  try {
644
650
  res = otherReflectOwnKeys(object);
@@ -650,7 +656,7 @@ function createBridge(otherInit, registerProxy) {
650
656
 
651
657
  preventExtensions(target) {
652
658
  // Note: target@this(unsafe) throws@this(unsafe)
653
- const object = this.object; // @other(unsafe)
659
+ const object = this.getObject(); // @other(unsafe)
654
660
  try {
655
661
  if (!otherReflectPreventExtensions(object)) return false;
656
662
  } catch (e) { // @other(unsafe)
@@ -664,7 +670,7 @@ function createBridge(otherInit, registerProxy) {
664
670
 
665
671
  enumerate(target) {
666
672
  // Note: target@this(unsafe) throws@this(unsafe)
667
- const object = this.object; // @other(unsafe)
673
+ const object = this.getObject(); // @other(unsafe)
668
674
  let res; // @other(unsafe)
669
675
  try {
670
676
  res = otherReflectEnumerate(object);
@@ -676,6 +682,10 @@ function createBridge(otherInit, registerProxy) {
676
682
 
677
683
  }
678
684
 
685
+ BaseHandler.prototype[thisSymbolNodeJSUtilInspectCustom] = undefined;
686
+ BaseHandler.prototype[thisSymbolToStringTag] = 'VM2 Wrapper';
687
+ BaseHandler.prototype[thisSymbolIterator] = undefined;
688
+
679
689
  function defaultFactory(object) {
680
690
  // Note: other@other(unsafe) returns@this(unsafe) throws@this(unsafe)
681
691
  return new BaseHandler(object);
@@ -773,7 +783,7 @@ function createBridge(otherInit, registerProxy) {
773
783
 
774
784
  get(target, key, receiver) {
775
785
  // Note: target@this(unsafe) key@prim receiver@this(unsafe) throws@this(unsafe)
776
- const object = this.object; // @other(unsafe)
786
+ const object = this.getObject(); // @other(unsafe)
777
787
  const mock = this.mock;
778
788
  if (thisReflectApply(thisObjectHasOwnProperty, mock, key) && !thisOtherHasOwnProperty(object, key)) {
779
789
  return mock[key];
@@ -330,6 +330,8 @@ function process() {
330
330
  return this;
331
331
  }
332
332
 
333
+ const baseUptime = localProcess.uptime();
334
+
333
335
  // FIXME wrong class structure
334
336
  global.process = {
335
337
  __proto__: process.prototype,
@@ -354,6 +356,9 @@ global.process = {
354
356
  hrtime: function hrtime(time) {
355
357
  return localProcess.hrtime(time);
356
358
  },
359
+ uptime: function uptime() {
360
+ return localProcess.uptime() - baseUptime;
361
+ },
357
362
  cwd: function cwd() {
358
363
  return localProcess.cwd();
359
364
  },
@@ -51,7 +51,10 @@ const {
51
51
  AsyncGeneratorFunction
52
52
  } = data;
53
53
 
54
- const localWeakMapGet = LocalWeakMap.prototype.get;
54
+ const {
55
+ get: localWeakMapGet,
56
+ set: localWeakMapSet
57
+ } = LocalWeakMap.prototype;
55
58
 
56
59
  function localUnexpected() {
57
60
  return new VMError('Should not happen');
@@ -282,8 +285,8 @@ if (typeof OriginalCallSite === 'function') {
282
285
  }
283
286
  return value(error, sst);
284
287
  };
285
- wrappedPrepareStackTrace.set(value, newWrapped);
286
- wrappedPrepareStackTrace.set(newWrapped, newWrapped);
288
+ localReflectApply(localWeakMapSet, wrappedPrepareStackTrace, [value, newWrapped]);
289
+ localReflectApply(localWeakMapSet, wrappedPrepareStackTrace, [newWrapped, newWrapped]);
287
290
  currentPrepareStackTrace = newWrapped;
288
291
  }
289
292
  })) throw localUnexpected();
@@ -51,6 +51,10 @@ function transformer(args, body, isAsync, isGenerator, filename) {
51
51
  let argsOffset;
52
52
  if (args === null) {
53
53
  code = body;
54
+ // Note: Keywords are not allows to contain u escapes
55
+ if (!/\b(?:catch|import|async)\b/.test(code)) {
56
+ return {__proto__: null, code, hasAsync: false};
57
+ }
54
58
  } else {
55
59
  code = isAsync ? '(async function' : '(function';
56
60
  if (isGenerator) code += '*';