@rindo/core 4.18.1 → 4.18.2-dev.1733699480.1e6d201

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 (39) hide show
  1. package/cli/index.cjs +27 -12
  2. package/cli/index.js +27 -12
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/rindo.js +12 -12
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +2 -2
  12. package/internal/app-data/package.json +1 -1
  13. package/internal/client/index.js +56 -24
  14. package/internal/client/package.json +1 -1
  15. package/internal/client/patch-browser.js +1 -1
  16. package/internal/hydrate/index.js +54 -24
  17. package/internal/hydrate/package.json +1 -1
  18. package/internal/hydrate/runner.js +66 -58
  19. package/internal/package.json +1 -1
  20. package/internal/rindo-private.d.ts +4 -3
  21. package/internal/rindo-public-compiler.d.ts +3 -3
  22. package/internal/rindo-public-runtime.d.ts +2 -8
  23. package/internal/testing/index.js +53 -23
  24. package/internal/testing/package.json +1 -1
  25. package/mock-doc/index.cjs +66 -58
  26. package/mock-doc/index.d.ts +36 -30
  27. package/mock-doc/index.js +66 -58
  28. package/mock-doc/package.json +1 -1
  29. package/package.json +4 -5
  30. package/screenshot/index.js +1 -1
  31. package/screenshot/package.json +1 -1
  32. package/screenshot/pixel-match.js +4 -1
  33. package/sys/node/glob.js +1 -1
  34. package/sys/node/index.js +2 -2
  35. package/sys/node/package.json +1 -1
  36. package/sys/node/worker.js +1 -1
  37. package/testing/index.js +26 -5
  38. package/testing/mock-fetch.d.ts +4 -4
  39. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Rindo Hydrate Runner v4.18.1 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Hydrate Runner v4.18.2-dev.1733699480.1e6d201 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -12329,67 +12329,75 @@ var MockUListElement = class extends MockHTMLElement {
12329
12329
  super(ownerDocument, "ul");
12330
12330
  }
12331
12331
  };
12332
+ var CanvasRenderingContext = class {
12333
+ constructor(context, contextAttributes) {
12334
+ this.context = context;
12335
+ this.contextAttributes = contextAttributes;
12336
+ }
12337
+ fillRect() {
12338
+ return;
12339
+ }
12340
+ clearRect() {
12341
+ }
12342
+ getImageData(_, __, w, h) {
12343
+ return {
12344
+ data: new Array(w * h * 4)
12345
+ };
12346
+ }
12347
+ toDataURL() {
12348
+ return "data:,";
12349
+ }
12350
+ putImageData() {
12351
+ }
12352
+ createImageData() {
12353
+ return {};
12354
+ }
12355
+ setTransform() {
12356
+ }
12357
+ drawImage() {
12358
+ }
12359
+ save() {
12360
+ }
12361
+ fillText() {
12362
+ }
12363
+ restore() {
12364
+ }
12365
+ beginPath() {
12366
+ }
12367
+ moveTo() {
12368
+ }
12369
+ lineTo() {
12370
+ }
12371
+ closePath() {
12372
+ }
12373
+ stroke() {
12374
+ }
12375
+ translate() {
12376
+ }
12377
+ scale() {
12378
+ }
12379
+ rotate() {
12380
+ }
12381
+ arc() {
12382
+ }
12383
+ fill() {
12384
+ }
12385
+ measureText() {
12386
+ return { width: 0 };
12387
+ }
12388
+ transform() {
12389
+ }
12390
+ rect() {
12391
+ }
12392
+ clip() {
12393
+ }
12394
+ };
12332
12395
  var MockCanvasElement = class extends MockHTMLElement {
12333
12396
  constructor(ownerDocument) {
12334
12397
  super(ownerDocument, "canvas");
12335
12398
  }
12336
- getContext() {
12337
- return {
12338
- fillRect() {
12339
- return;
12340
- },
12341
- clearRect() {
12342
- },
12343
- getImageData: function(_, __, w, h) {
12344
- return {
12345
- data: new Array(w * h * 4)
12346
- };
12347
- },
12348
- putImageData() {
12349
- },
12350
- createImageData: function() {
12351
- return [];
12352
- },
12353
- setTransform() {
12354
- },
12355
- drawImage() {
12356
- },
12357
- save() {
12358
- },
12359
- fillText() {
12360
- },
12361
- restore() {
12362
- },
12363
- beginPath() {
12364
- },
12365
- moveTo() {
12366
- },
12367
- lineTo() {
12368
- },
12369
- closePath() {
12370
- },
12371
- stroke() {
12372
- },
12373
- translate() {
12374
- },
12375
- scale() {
12376
- },
12377
- rotate() {
12378
- },
12379
- arc() {
12380
- },
12381
- fill() {
12382
- },
12383
- measureText() {
12384
- return { width: 0 };
12385
- },
12386
- transform() {
12387
- },
12388
- rect() {
12389
- },
12390
- clip() {
12391
- }
12392
- };
12399
+ getContext(context, contextAttributes) {
12400
+ return new CanvasRenderingContext(context, contextAttributes);
12393
12401
  }
12394
12402
  };
12395
12403
  function fullUrl(elm, attrName) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/internal",
3
- "version": "4.18.1",
3
+ "version": "4.18.2-dev.1733699480.1e6d201",
4
4
  "description": "Rindo internals only to be imported by the Rindo Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -126,6 +126,7 @@ export interface BuildConditionals extends Partial<BuildFeatures> {
126
126
  cloneNodeFix?: boolean;
127
127
  hydratedAttribute?: boolean;
128
128
  hydratedClass?: boolean;
129
+ hydratedSelectorName?: string;
129
130
  initializeNextTick?: boolean;
130
131
  scriptDataOpts?: boolean;
131
132
  shadowDomShim?: boolean;
@@ -963,11 +964,11 @@ export interface HostElement extends HTMLElement {
963
964
  */
964
965
  ['s-sc']?: string;
965
966
  /**
966
- * Root Scope Id
967
- * The scope id of the root component when using scoped css encapsulation
967
+ * Scope Ids
968
+ * All the possible scope ids of this component when using scoped css encapsulation
968
969
  * or using shadow dom but the browser doesn't support it
969
970
  */
970
- ['s-rsc']?: string;
971
+ ['s-scs']?: string[];
971
972
  /**
972
973
  * Hot Module Replacement, dev mode only
973
974
  *
@@ -2370,9 +2370,9 @@ export interface ResolveModuleOptions {
2370
2370
  }
2371
2371
  export interface PrerenderStartOptions {
2372
2372
  buildId?: string;
2373
- hydrateAppFilePath: string;
2374
- componentGraph: BuildResultsComponentGraph;
2375
- srcIndexHtmlPath: string;
2373
+ hydrateAppFilePath?: string;
2374
+ componentGraph?: BuildResultsComponentGraph;
2375
+ srcIndexHtmlPath?: string;
2376
2376
  }
2377
2377
  export interface PrerenderResults {
2378
2378
  buildId: string;
@@ -795,7 +795,6 @@ export declare namespace JSXBase {
795
795
  cite?: string;
796
796
  }
797
797
  interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
798
- autoFocus?: boolean;
799
798
  disabled?: boolean;
800
799
  form?: string;
801
800
  formAction?: string;
@@ -922,8 +921,6 @@ export declare namespace JSXBase {
922
921
  autocapitalize?: string;
923
922
  autoComplete?: string;
924
923
  autocomplete?: string;
925
- autoFocus?: boolean;
926
- autofocus?: boolean | string;
927
924
  capture?: string;
928
925
  checked?: boolean;
929
926
  crossOrigin?: string;
@@ -980,8 +977,6 @@ export declare namespace JSXBase {
980
977
  popoverTarget?: string;
981
978
  }
982
979
  interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
983
- autoFocus?: boolean;
984
- autofocus?: boolean | string;
985
980
  challenge?: string;
986
981
  disabled?: boolean;
987
982
  form?: string;
@@ -1130,7 +1125,6 @@ export declare namespace JSXBase {
1130
1125
  type?: string;
1131
1126
  }
1132
1127
  interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
1133
- autoFocus?: boolean;
1134
1128
  disabled?: boolean;
1135
1129
  form?: string;
1136
1130
  multiple?: boolean;
@@ -1165,8 +1159,6 @@ export declare namespace JSXBase {
1165
1159
  interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
1166
1160
  autoComplete?: string;
1167
1161
  autocomplete?: string;
1168
- autoFocus?: boolean;
1169
- autofocus?: boolean | string;
1170
1162
  cols?: number;
1171
1163
  disabled?: boolean;
1172
1164
  form?: string;
@@ -1219,6 +1211,8 @@ export declare namespace JSXBase {
1219
1211
  interface HTMLAttributes<T = HTMLElement> extends DOMAttributes<T> {
1220
1212
  innerHTML?: string;
1221
1213
  accessKey?: string;
1214
+ autoFocus?: boolean;
1215
+ autofocus?: boolean | string;
1222
1216
  class?: string | {
1223
1217
  [className: string]: boolean;
1224
1218
  };
@@ -979,6 +979,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
979
979
  if ((import_app_data10.BUILD.shadowDom || import_app_data10.BUILD.scoped) && isDef(scopeId) && elm["s-si"] !== scopeId) {
980
980
  elm.classList.add(elm["s-si"] = scopeId);
981
981
  }
982
+ if (import_app_data10.BUILD.scoped) {
983
+ updateElementScopeIds(elm, parentElm);
984
+ }
982
985
  if (newVNode2.$children$) {
983
986
  for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
984
987
  childNode = createElm(oldParentVNode, newVNode2, i2, elm);
@@ -1340,22 +1343,33 @@ var nullifyVNodeRefs = (vNode) => {
1340
1343
  var insertBefore = (parent, newNode, reference) => {
1341
1344
  const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1342
1345
  if (import_app_data10.BUILD.scoped) {
1343
- setParentScopeIdAsClassName(newNode, parent);
1346
+ updateElementScopeIds(newNode, parent);
1344
1347
  }
1345
1348
  return inserted;
1346
1349
  };
1347
- var findParentScopeId = (element) => {
1348
- return element ? element["s-rsc"] || element["s-si"] || element["s-sc"] || findParentScopeId(element.parentElement) : void 0;
1350
+ var findScopeIds = (element) => {
1351
+ const scopeIds = [];
1352
+ if (element) {
1353
+ scopeIds.push(
1354
+ ...element["s-scs"] || [],
1355
+ element["s-si"],
1356
+ element["s-sc"],
1357
+ ...findScopeIds(element.parentElement)
1358
+ );
1359
+ }
1360
+ return scopeIds;
1349
1361
  };
1350
- var setParentScopeIdAsClassName = (element, parent) => {
1351
- var _a, _b, _c;
1352
- if (element && parent) {
1353
- const oldRootScopeId = element["s-rsc"];
1354
- const newRootScopeId = findParentScopeId(parent);
1355
- oldRootScopeId && ((_a = element.classList) == null ? void 0 : _a.contains(oldRootScopeId)) && element.classList.remove(oldRootScopeId);
1356
- if (newRootScopeId) {
1357
- element["s-rsc"] = newRootScopeId;
1358
- !((_b = element.classList) == null ? void 0 : _b.contains(newRootScopeId)) && ((_c = element.classList) == null ? void 0 : _c.add(newRootScopeId));
1362
+ var updateElementScopeIds = (element, parent, iterateChildNodes = false) => {
1363
+ var _a;
1364
+ if (element && parent && element.nodeType === 1 /* ElementNode */) {
1365
+ const scopeIds = new Set(findScopeIds(parent).filter(Boolean));
1366
+ if (scopeIds.size) {
1367
+ (_a = element.classList) == null ? void 0 : _a.add(...element["s-scs"] = [...scopeIds]);
1368
+ if (element["s-ol"] || iterateChildNodes) {
1369
+ for (const childNode of Array.from(element.childNodes)) {
1370
+ updateElementScopeIds(childNode, element, true);
1371
+ }
1372
+ }
1359
1373
  }
1360
1374
  }
1361
1375
  };
@@ -1510,6 +1524,11 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
1510
1524
  const elm = hostRef.$hostElement$;
1511
1525
  const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
1512
1526
  const instance = import_app_data11.BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1527
+ if (!instance) {
1528
+ throw new Error(
1529
+ `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Rindo runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://rindojs.web.app/docs/custom-elements#externalruntime`
1530
+ );
1531
+ }
1513
1532
  let maybePromise;
1514
1533
  if (isInitialLoad) {
1515
1534
  if (import_app_data11.BUILD.lazyLoad && import_app_data11.BUILD.hostListener) {
@@ -1740,7 +1759,10 @@ var emitLifecycleEvent = (elm, lifecycleName) => {
1740
1759
  });
1741
1760
  }
1742
1761
  };
1743
- var addHydratedFlag = (elm) => import_app_data11.BUILD.hydratedClass ? elm.classList.add("hydrated") : import_app_data11.BUILD.hydratedAttribute ? elm.setAttribute("hydrated", "") : void 0;
1762
+ var addHydratedFlag = (elm) => {
1763
+ var _a, _b;
1764
+ return import_app_data11.BUILD.hydratedClass ? elm.classList.add((_a = import_app_data11.BUILD.hydratedSelectorName) != null ? _a : "hydrated") : import_app_data11.BUILD.hydratedAttribute ? elm.setAttribute((_b = import_app_data11.BUILD.hydratedSelectorName) != null ? _b : "hydrated", "") : void 0;
1765
+ };
1744
1766
  var serverSideConnected = (elm) => {
1745
1767
  const children = elm.children;
1746
1768
  if (children != null) {
@@ -1944,16 +1966,18 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1944
1966
  hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1945
1967
  const bundleId = cmpMeta.$lazyBundleId$;
1946
1968
  if ((import_app_data14.BUILD.lazyLoad || import_app_data14.BUILD.hydrateClientSide) && bundleId) {
1947
- Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1948
- if (Cstr.then) {
1969
+ const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
1970
+ if (CstrImport && "then" in CstrImport) {
1949
1971
  const endLoad = uniqueTime(
1950
1972
  `st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`,
1951
1973
  `[Rindo] Load module for <${cmpMeta.$tagName$}>`
1952
1974
  );
1953
- Cstr = await Cstr;
1975
+ Cstr = await CstrImport;
1954
1976
  endLoad();
1977
+ } else {
1978
+ Cstr = CstrImport;
1955
1979
  }
1956
- if ((import_app_data14.BUILD.isDev || import_app_data14.BUILD.isDebug) && !Cstr) {
1980
+ if (!Cstr) {
1957
1981
  throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
1958
1982
  }
1959
1983
  if (import_app_data14.BUILD.member && !Cstr.isProxied) {
@@ -1982,12 +2006,16 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1982
2006
  fireConnectedCallback(hostRef.$lazyInstance$);
1983
2007
  } else {
1984
2008
  Cstr = elm.constructor;
1985
- customElements.whenDefined(cmpMeta.$tagName$).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
2009
+ const cmpTag = elm.localName;
2010
+ customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
1986
2011
  }
1987
- if (import_app_data14.BUILD.style && Cstr.style) {
2012
+ if (import_app_data14.BUILD.style && Cstr && Cstr.style) {
1988
2013
  let style = Cstr.style;
1989
2014
  if (import_app_data14.BUILD.mode && typeof style !== "string") {
1990
- style = style[hostRef.$modeName$ = computeMode(elm)];
2015
+ hostRef.$modeName$ = computeMode(elm);
2016
+ if (hostRef.$modeName$) {
2017
+ style = style[hostRef.$modeName$];
2018
+ }
1991
2019
  if (import_app_data14.BUILD.hydrateServerSide && hostRef.$modeName$) {
1992
2020
  elm.setAttribute("s-mode", hostRef.$modeName$);
1993
2021
  }
@@ -2155,7 +2183,7 @@ var patchCloneNode = (HostElementPrototype) => {
2155
2183
  "s-nr",
2156
2184
  "s-si",
2157
2185
  "s-rf",
2158
- "s-rsc"
2186
+ "s-scs"
2159
2187
  ];
2160
2188
  for (; i2 < srcNode.childNodes.length; i2++) {
2161
2189
  slotted = srcNode.childNodes[i2]["s-nr"];
@@ -2732,10 +2760,11 @@ var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =>
2732
2760
  }
2733
2761
  };
2734
2762
  var hostListenerProxy = (hostRef, methodName) => (ev) => {
2763
+ var _a;
2735
2764
  try {
2736
2765
  if (import_app_data20.BUILD.lazyLoad) {
2737
2766
  if (hostRef.$flags$ & 256 /* isListenReady */) {
2738
- hostRef.$lazyInstance$[methodName](ev);
2767
+ (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
2739
2768
  } else {
2740
2769
  (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2741
2770
  }
@@ -2750,7 +2779,8 @@ var getHostListenerTarget = (elm, flags) => {
2750
2779
  if (import_app_data20.BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
2751
2780
  if (import_app_data20.BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
2752
2781
  if (import_app_data20.BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
2753
- if (import_app_data20.BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */) return elm.parentElement;
2782
+ if (import_app_data20.BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
2783
+ return elm.parentElement;
2754
2784
  return elm;
2755
2785
  };
2756
2786
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/internal/testing",
3
- "version": "4.18.1",
3
+ "version": "4.18.2-dev.1733699480.1e6d201",
4
4
  "description": "Rindo internal testing platform to be imported by the Rindo Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Rindo Mock Doc (CommonJS) v4.18.1 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Mock Doc (CommonJS) v4.18.2-dev.1733699480.1e6d201 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  "use strict";
5
5
  var __defProp = Object.defineProperty;
@@ -8202,67 +8202,75 @@ var MockUListElement = class extends MockHTMLElement {
8202
8202
  super(ownerDocument, "ul");
8203
8203
  }
8204
8204
  };
8205
+ var CanvasRenderingContext = class {
8206
+ constructor(context, contextAttributes) {
8207
+ this.context = context;
8208
+ this.contextAttributes = contextAttributes;
8209
+ }
8210
+ fillRect() {
8211
+ return;
8212
+ }
8213
+ clearRect() {
8214
+ }
8215
+ getImageData(_, __, w, h) {
8216
+ return {
8217
+ data: new Array(w * h * 4)
8218
+ };
8219
+ }
8220
+ toDataURL() {
8221
+ return "data:,";
8222
+ }
8223
+ putImageData() {
8224
+ }
8225
+ createImageData() {
8226
+ return {};
8227
+ }
8228
+ setTransform() {
8229
+ }
8230
+ drawImage() {
8231
+ }
8232
+ save() {
8233
+ }
8234
+ fillText() {
8235
+ }
8236
+ restore() {
8237
+ }
8238
+ beginPath() {
8239
+ }
8240
+ moveTo() {
8241
+ }
8242
+ lineTo() {
8243
+ }
8244
+ closePath() {
8245
+ }
8246
+ stroke() {
8247
+ }
8248
+ translate() {
8249
+ }
8250
+ scale() {
8251
+ }
8252
+ rotate() {
8253
+ }
8254
+ arc() {
8255
+ }
8256
+ fill() {
8257
+ }
8258
+ measureText() {
8259
+ return { width: 0 };
8260
+ }
8261
+ transform() {
8262
+ }
8263
+ rect() {
8264
+ }
8265
+ clip() {
8266
+ }
8267
+ };
8205
8268
  var MockCanvasElement = class extends MockHTMLElement {
8206
8269
  constructor(ownerDocument) {
8207
8270
  super(ownerDocument, "canvas");
8208
8271
  }
8209
- getContext() {
8210
- return {
8211
- fillRect() {
8212
- return;
8213
- },
8214
- clearRect() {
8215
- },
8216
- getImageData: function(_, __, w, h) {
8217
- return {
8218
- data: new Array(w * h * 4)
8219
- };
8220
- },
8221
- putImageData() {
8222
- },
8223
- createImageData: function() {
8224
- return [];
8225
- },
8226
- setTransform() {
8227
- },
8228
- drawImage() {
8229
- },
8230
- save() {
8231
- },
8232
- fillText() {
8233
- },
8234
- restore() {
8235
- },
8236
- beginPath() {
8237
- },
8238
- moveTo() {
8239
- },
8240
- lineTo() {
8241
- },
8242
- closePath() {
8243
- },
8244
- stroke() {
8245
- },
8246
- translate() {
8247
- },
8248
- scale() {
8249
- },
8250
- rotate() {
8251
- },
8252
- arc() {
8253
- },
8254
- fill() {
8255
- },
8256
- measureText() {
8257
- return { width: 0 };
8258
- },
8259
- transform() {
8260
- },
8261
- rect() {
8262
- },
8263
- clip() {
8264
- }
8265
- };
8272
+ getContext(context, contextAttributes) {
8273
+ return new CanvasRenderingContext(context, contextAttributes);
8266
8274
  }
8267
8275
  };
8268
8276
  function fullUrl(elm, attrName) {
@@ -312,38 +312,44 @@ declare class MockTitleElement extends MockHTMLElement {
312
312
  declare class MockUListElement extends MockHTMLElement {
313
313
  constructor(ownerDocument: any);
314
314
  }
315
+ type CanvasContext = '2d' | 'webgl' | 'webgl2' | 'bitmaprenderer';
316
+ declare class CanvasRenderingContext {
317
+ context: CanvasContext;
318
+ contextAttributes: WebGLContextAttributes;
319
+ constructor(context: CanvasContext, contextAttributes?: WebGLContextAttributes);
320
+ fillRect(): void;
321
+ clearRect(): void;
322
+ getImageData(_: number, __: number, w: number, h: number): {
323
+ data: any[];
324
+ };
325
+ toDataURL(): string;
326
+ putImageData(): void;
327
+ createImageData(): ImageData;
328
+ setTransform(): void;
329
+ drawImage(): void;
330
+ save(): void;
331
+ fillText(): void;
332
+ restore(): void;
333
+ beginPath(): void;
334
+ moveTo(): void;
335
+ lineTo(): void;
336
+ closePath(): void;
337
+ stroke(): void;
338
+ translate(): void;
339
+ scale(): void;
340
+ rotate(): void;
341
+ arc(): void;
342
+ fill(): void;
343
+ measureText(): {
344
+ width: number;
345
+ };
346
+ transform(): void;
347
+ rect(): void;
348
+ clip(): void;
349
+ }
315
350
  declare class MockCanvasElement extends MockHTMLElement {
316
351
  constructor(ownerDocument: any);
317
- getContext(): {
318
- fillRect(): void;
319
- clearRect(): void;
320
- getImageData: (_: number, __: number, w: number, h: number) => {
321
- data: any[];
322
- };
323
- putImageData(): void;
324
- createImageData: () => any[];
325
- setTransform(): void;
326
- drawImage(): void;
327
- save(): void;
328
- fillText(): void;
329
- restore(): void;
330
- beginPath(): void;
331
- moveTo(): void;
332
- lineTo(): void;
333
- closePath(): void;
334
- stroke(): void;
335
- translate(): void;
336
- scale(): void;
337
- rotate(): void;
338
- arc(): void;
339
- fill(): void;
340
- measureText(): {
341
- width: number;
342
- };
343
- transform(): void;
344
- rect(): void;
345
- clip(): void;
346
- };
352
+ getContext(context: CanvasContext, contextAttributes?: WebGLContextAttributes): CanvasRenderingContext;
347
353
  }
348
354
  declare class MockEvent {
349
355
  bubbles: boolean;