@metapages/metapage 0.11.7 → 0.11.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 (96) hide show
  1. package/dist/LICENSE +201 -0
  2. package/dist/README.md +16 -0
  3. package/dist/browser/metaframe/index.js +26 -0
  4. package/dist/browser/metaframe/index.js.map +1 -0
  5. package/dist/browser/metapage/index.js +46 -0
  6. package/dist/browser/metapage/index.js.map +1 -0
  7. package/dist/index.d.ts +7 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/{index.js → dist/index.js} +0 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/metapage/Constants.d.ts +6 -0
  12. package/dist/metapage/Constants.d.ts.map +1 -0
  13. package/dist/metapage/Constants.js +7 -0
  14. package/dist/metapage/Constants.js.map +1 -0
  15. package/dist/metapage/Metaframe.d.ts +73 -0
  16. package/dist/metapage/Metaframe.d.ts.map +1 -0
  17. package/dist/metapage/Metaframe.js +347 -0
  18. package/dist/metapage/Metaframe.js.map +1 -0
  19. package/dist/metapage/Metapage.d.ts +103 -0
  20. package/dist/metapage/Metapage.d.ts.map +1 -0
  21. package/dist/metapage/Metapage.js +789 -0
  22. package/dist/metapage/Metapage.js.map +1 -0
  23. package/dist/metapage/MetapageIFrameRpcClient.d.ts +64 -0
  24. package/dist/metapage/MetapageIFrameRpcClient.d.ts.map +1 -0
  25. package/dist/metapage/MetapageIFrameRpcClient.js +372 -0
  26. package/dist/metapage/MetapageIFrameRpcClient.js.map +1 -0
  27. package/dist/metapage/MetapageTools.d.ts +21 -0
  28. package/dist/metapage/MetapageTools.d.ts.map +1 -0
  29. package/dist/metapage/MetapageTools.js +218 -0
  30. package/dist/metapage/MetapageTools.js.map +1 -0
  31. package/dist/metapage/Shared.d.ts +15 -0
  32. package/dist/metapage/Shared.d.ts.map +1 -0
  33. package/dist/metapage/Shared.js +32 -0
  34. package/dist/metapage/Shared.js.map +1 -0
  35. package/dist/metapage/errors/MissingMetaframeJson.d.ts +10 -0
  36. package/dist/metapage/errors/MissingMetaframeJson.d.ts.map +1 -0
  37. package/dist/metapage/errors/MissingMetaframeJson.js +7 -0
  38. package/dist/metapage/errors/MissingMetaframeJson.js.map +1 -0
  39. package/dist/metapage/errors/RootMetapageError.d.ts +10 -0
  40. package/dist/metapage/errors/RootMetapageError.d.ts.map +1 -0
  41. package/dist/metapage/errors/RootMetapageError.js +7 -0
  42. package/dist/metapage/errors/RootMetapageError.js.map +1 -0
  43. package/dist/metapage/jsonrpc2.d.ts +35 -0
  44. package/dist/metapage/jsonrpc2.d.ts.map +1 -0
  45. package/dist/metapage/jsonrpc2.js +25 -0
  46. package/dist/metapage/jsonrpc2.js.map +1 -0
  47. package/dist/metapage/v0_0_1/all.d.ts +110 -0
  48. package/dist/metapage/v0_0_1/all.d.ts.map +1 -0
  49. package/dist/metapage/v0_0_1/all.js +16 -0
  50. package/dist/metapage/v0_0_1/all.js.map +1 -0
  51. package/dist/metapage/v0_1_0/all.d.ts +110 -0
  52. package/dist/metapage/v0_1_0/all.d.ts.map +1 -0
  53. package/dist/metapage/v0_1_0/all.js +16 -0
  54. package/dist/metapage/v0_1_0/all.js.map +1 -0
  55. package/dist/metapage/v0_2/all.d.ts +68 -0
  56. package/dist/metapage/v0_2/all.d.ts.map +1 -0
  57. package/dist/metapage/v0_2/all.js +3 -0
  58. package/dist/metapage/v0_2/all.js.map +1 -0
  59. package/dist/metapage/v0_3/JsonRpcMethods.d.ts +42 -0
  60. package/dist/metapage/v0_3/JsonRpcMethods.d.ts.map +1 -0
  61. package/dist/metapage/v0_3/JsonRpcMethods.js +20 -0
  62. package/dist/metapage/v0_3/JsonRpcMethods.js.map +1 -0
  63. package/dist/metapage/v0_3/all.d.ts +24 -0
  64. package/dist/metapage/v0_3/all.d.ts.map +1 -0
  65. package/dist/metapage/v0_3/all.js +2 -0
  66. package/dist/metapage/v0_3/all.js.map +1 -0
  67. package/dist/metapage/v0_4/core.d.ts +6 -0
  68. package/dist/metapage/v0_4/core.d.ts.map +1 -0
  69. package/dist/metapage/v0_4/core.js +2 -0
  70. package/dist/metapage/v0_4/core.js.map +1 -0
  71. package/dist/metapage/v0_4/events.d.ts +26 -0
  72. package/dist/metapage/v0_4/events.d.ts.map +1 -0
  73. package/dist/metapage/v0_4/events.js +12 -0
  74. package/dist/metapage/v0_4/events.js.map +1 -0
  75. package/dist/metapage/v0_4/index.d.ts +7 -0
  76. package/dist/metapage/v0_4/index.d.ts.map +1 -0
  77. package/dist/metapage/v0_4/index.js +7 -0
  78. package/dist/metapage/v0_4/index.js.map +1 -0
  79. package/dist/metapage/v0_4/jsonrpc.d.ts +43 -0
  80. package/dist/metapage/v0_4/jsonrpc.d.ts.map +1 -0
  81. package/dist/metapage/v0_4/jsonrpc.js +20 -0
  82. package/dist/metapage/v0_4/jsonrpc.js.map +1 -0
  83. package/dist/metapage/v0_4/metaframe.d.ts +84 -0
  84. package/dist/metapage/v0_4/metaframe.d.ts.map +1 -0
  85. package/dist/metapage/v0_4/metaframe.js +2 -0
  86. package/dist/metapage/v0_4/metaframe.js.map +1 -0
  87. package/dist/metapage/v0_4/metapage.d.ts +33 -0
  88. package/dist/metapage/v0_4/metapage.d.ts.map +1 -0
  89. package/dist/metapage/v0_4/metapage.js +2 -0
  90. package/dist/metapage/v0_4/metapage.js.map +1 -0
  91. package/dist/metapage/v0_4/versions.d.ts +14 -0
  92. package/dist/metapage/v0_4/versions.d.ts.map +1 -0
  93. package/dist/metapage/v0_4/versions.js +16 -0
  94. package/dist/metapage/v0_4/versions.js.map +1 -0
  95. package/dist/package.json +49 -0
  96. package/package.json +5 -5
package/dist/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # [Metapages](https://metapages.org/)
2
+
3
+ A *metapage* is a set of connected webpages (*metaframes*).
4
+
5
+ The [metaframe npm library](https://www.npmjs.com/package/metaframe) runs in the metaframed website (as an iframe), sending and recieving data on named pipes.
6
+
7
+ The [metapage npm library](https://www.npmjs.com/package/metapage) runs on the parent website, controlling the data streams between metaframes.
8
+
9
+ [Tests](https://metapages.org/tests/): All (non-deprecated) library version pairs are tested against every other before any changes are merged. We will make every effort to preserve backwards compatibility forever.
10
+
11
+ Documentation and examples: [https://metapages.org/](https://metapages.org/)
12
+
13
+ Simple example (two connected metaframes):
14
+
15
+ [https://app.metapages.org/#?url=https://metapages.org/metapages/dynamic-plot/](https://app.metapages.org/#?url=https://metapages.org/metapages/dynamic-plot/)
16
+ <iframe src="https://app.metapages.org/#?url=https://metapages.org/metapages/dynamic-plot/" frameBorder="0" style="width:600px;height:400px"></iframe>
@@ -0,0 +1,26 @@
1
+ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"UASB":[function(require,module,exports) {
2
+ "use strict";var e=Object.prototype.hasOwnProperty,t="~";function n(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,n,o,s,i){if("function"!=typeof o)throw new TypeError("The listener must be a function");var c=new r(o,s||e,i),f=t?t+n:n;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function i(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(t=!1)),i.prototype.eventNames=function(){var n,r,o=[];if(0===this._eventsCount)return o;for(r in n=this._events)e.call(n,r)&&o.push(t?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(n)):o},i.prototype.listeners=function(e){var n=t?t+e:e,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},i.prototype.listenerCount=function(e){var n=t?t+e:e,r=this._events[n];return r?r.fn?1:r.length:0},i.prototype.emit=function(e,n,r,o,s,i){var c=t?t+e:e;if(!this._events[c])return!1;var f,u,a=this._events[c],l=arguments.length;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,n),!0;case 3:return a.fn.call(a.context,n,r),!0;case 4:return a.fn.call(a.context,n,r,o),!0;case 5:return a.fn.call(a.context,n,r,o,s),!0;case 6:return a.fn.call(a.context,n,r,o,s,i),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];a.fn.apply(a.context,f)}else{var v,h=a.length;for(u=0;u<h;u++)switch(a[u].once&&this.removeListener(e,a[u].fn,void 0,!0),l){case 1:a[u].fn.call(a[u].context);break;case 2:a[u].fn.call(a[u].context,n);break;case 3:a[u].fn.call(a[u].context,n,r);break;case 4:a[u].fn.call(a[u].context,n,r,o);break;default:if(!f)for(v=1,f=new Array(l-1);v<l;v++)f[v-1]=arguments[v];a[u].fn.apply(a[u].context,f)}}return!0},i.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},i.prototype.removeListener=function(e,n,r,o){var i=t?t+e:e;if(!this._events[i])return this;if(!n)return s(this,i),this;var c=this._events[i];if(c.fn)c.fn!==n||o&&!c.once||r&&c.context!==r||s(this,i);else{for(var f=0,u=[],a=c.length;f<a;f++)(c[f].fn!==n||o&&!c[f].once||r&&c[f].context!==r)&&u.push(c[f]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},i.prototype.removeAllListeners=function(e){var r;return e?(r=t?t+e:e,this._events[r]&&s(this,r)):(this._events=new n,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=t,i.EventEmitter=i,"undefined"!=typeof module&&(module.exports=i);
3
+ },{}],"GPLR":[function(require,module,exports) {
4
+ "use strict";var e,r;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetapageVersionCurrent=exports.MetapageVersionsAll=exports.MetaframeVersionCurrent=exports.MetaframeVersionsAll=exports.VersionsMetapage=exports.VersionsMetaframe=void 0,exports.VersionsMetaframe=e,function(e){e.V0_3="0.3",e.V0_4="0.4",e.V0_5="0.5"}(e||(exports.VersionsMetaframe=e={})),exports.VersionsMetapage=r,function(e){e.V0_2="0.2",e.V0_3="0.3"}(r||(exports.VersionsMetapage=r={}));const s=Object.keys(e);exports.MetaframeVersionsAll=s;const t=e.V0_5;exports.MetaframeVersionCurrent=t;const o=Object.keys(r);exports.MetapageVersionsAll=o;const a=r.V0_3;exports.MetapageVersionCurrent=a;
5
+ },{}],"s3GQ":[function(require,module,exports) {
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"MetaframeVersionCurrent",{enumerable:!0,get:function(){return e.MetaframeVersionCurrent}}),Object.defineProperty(exports,"MetapageVersionCurrent",{enumerable:!0,get:function(){return e.MetapageVersionCurrent}}),Object.defineProperty(exports,"MetaframeVersionsAll",{enumerable:!0,get:function(){return e.MetaframeVersionsAll}}),Object.defineProperty(exports,"MetapageVersionsAll",{enumerable:!0,get:function(){return e.MetapageVersionsAll}});var e=require("./versions");
7
+ },{"./versions":"GPLR"}],"jX2q":[function(require,module,exports) {
8
+ "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetapageEvents=void 0,exports.MetapageEvents=e,function(e){e.Inputs="inputs",e.Outputs="outputs",e.State="state",e.Definition="definition",e.DefinitionUpdateRequest="definitionupdaterequest",e.Error="error",e.UrlHashUpdate="urlhashupdate",e.Message="Message"}(e||(exports.MetapageEvents=e={}));
9
+ },{}],"TmGQ":[function(require,module,exports) {
10
+ "use strict";var e,t,s;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiPayloadPluginRequestMethod=exports.JsonRpcMethodsFromParent=exports.JsonRpcMethodsFromChild=void 0,exports.JsonRpcMethodsFromChild=e,function(e){e.InputsUpdate="InputsUpdate",e.OutputsUpdate="OutputsUpdate",e.SetupIframeClientRequest="SetupIframeClientRequest",e.SetupIframeServerResponseAck="SetupIframeServerResponseAck",e.PluginRequest="SetupIframeServerPluginRequestResponseAck",e.HashParamsUpdate="HashParamsUpdate"}(e||(exports.JsonRpcMethodsFromChild=e={})),exports.JsonRpcMethodsFromParent=t,function(e){e.InputsUpdate="InputsUpdate",e.MessageAck="MessageAck",e.SetupIframeServerResponse="SetupIframeServerResponse"}(t||(exports.JsonRpcMethodsFromParent=t={})),exports.ApiPayloadPluginRequestMethod=s,function(e){e.State="metapage/state"}(s||(exports.ApiPayloadPluginRequestMethod=s={}));
11
+ },{}],"D/Lb":[function(require,module,exports) {
12
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
13
+ },{}],"1svx":[function(require,module,exports) {
14
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./core");Object.keys(e).forEach(function(r){"default"!==r&&"__esModule"!==r&&(r in exports&&exports[r]===e[r]||Object.defineProperty(exports,r,{enumerable:!0,get:function(){return e[r]}}))});var r=require("./events");Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===r[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}}))});var t=require("./jsonrpc");Object.keys(t).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===t[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}}))});var o=require("./metaframe");Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===o[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}}))});var n=require("./metapage");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===n[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}}))});var u=require("./versions");Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===u[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return u[e]}}))});
15
+ },{"./core":"s3GQ","./events":"jX2q","./jsonrpc":"TmGQ","./metaframe":"D/Lb","./metapage":"D/Lb","./versions":"GPLR"}],"Xnuv":[function(require,module,exports) {
16
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VERSION_METAFRAME=exports.VERSION_METAPAGE=exports.METAPAGE_KEY_STATE=exports.METAPAGE_KEY_DEFINITION=exports.METAFRAME_JSON_FILE=void 0;var e=require("./v0_4");const t="metaframe.json";exports.METAFRAME_JSON_FILE="metaframe.json";const E="metapage/definition";exports.METAPAGE_KEY_DEFINITION="metapage/definition";const s="metapage/state";exports.METAPAGE_KEY_STATE="metapage/state";const o=e.MetapageVersionsAll[e.MetapageVersionsAll.length-1];exports.VERSION_METAPAGE=o;const A=e.MetaframeVersionsAll[e.MetaframeVersionsAll.length-1];exports.VERSION_METAFRAME=A;
17
+ },{"./v0_4":"1svx"}],"p8iL":[function(require,module,exports) {
18
+ "use strict";function t(t,e){const r=s(t),o=s(e),n=r.pop(),i=o.pop(),a=c(r,o);return 0!==a?a:n&&i?c(n.split("."),i.split(".")):n||i?n?-1:1:0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t,exports.satisfies=exports.compare=exports.validate=void 0;const e=t=>"string"==typeof t&&/^[v\d]/.test(t)&&n.test(t);exports.validate=e;const r=(e,r,o)=>{l(o);const n=t(e,r);return f[o].includes(n)};exports.compare=r;const o=(t,e)=>{const o=e.match(/^([<>=~^]+)/),n=o?o[1]:"=";if("^"!==n&&"~"!==n)return r(t,e,n);const[i,a,p]=s(t),[f,u,l]=s(e);return 0===d(i,f)&&("^"===n?c([a,p],[u,l])>=0:0===d(a,u)&&d(p,l)>=0)};exports.satisfies=o,t.validate=e,t.compare=r,t.satisfies=o;const n=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,s=t=>{if("string"!=typeof t)throw new TypeError("Invalid argument expected string");const e=t.match(n);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},i=t=>"*"===t||"x"===t||"X"===t,a=t=>{const e=parseInt(t,10);return isNaN(e)?t:e},p=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],d=(t,e)=>{if(i(t)||i(e))return 0;const[r,o]=p(a(t),a(e));return r>o?1:r<o?-1:0},c=(t,e)=>{for(let r=0;r<Math.max(t.length,e.length);r++){const o=d(t[r]||0,e[r]||0);if(0!==o)return o}return 0},f={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},u=Object.keys(f),l=t=>{if("string"!=typeof t)throw new TypeError(`Invalid operator type, expected string but got ${typeof t}`);if(-1===u.indexOf(t))throw new Error(`Invalid operator, expected one of ${u.join("|")}`)};
19
+ },{}],"Q9lO":[function(require,module,exports) {
20
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetapageShared=exports.INITIAL_NULL_METAPAGE_DEFINITION=exports.isIframe=exports.MetapageHashParams=void 0;var e,t=require("eventemitter3"),r=require("./v0_4");exports.MetapageHashParams=e,function(e){e.mp_debug="mp_debug"}(e||(exports.MetapageHashParams=e={}));const s=()=>{try{return window!==window.top}catch(e){return!1}};exports.isIframe=s;const i={version:r.MetapageVersionCurrent,metaframes:{}};exports.INITIAL_NULL_METAPAGE_DEFINITION=i;class a extends t.EventEmitter{constructor(){super(),this._definition=i,this.getDefinition=this.getDefinition.bind(this)}error(e){throw"Subclass should implement"}getDefinition(){return this._definition}}exports.MetapageShared=a;
21
+ },{"eventemitter3":"UASB","./v0_4":"1svx"}],"f0H1":[function(require,module,exports) {
22
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.pageLoaded=exports.isPageLoaded=exports.intToRGB=exports.hashCode=exports.stringToRgb=exports.log=exports.generateId=exports.generateNonce=exports.generateMetapageId=exports.generateMetaframeId=exports.existsAnyUrlParam=exports.isDebugFromUrlsParams=exports.getUrlParamDebug=exports.getUrlParam=exports.getMatchingVersion=exports.merge=exports.convertMetaframeJsonToCurrentVersion=exports.convertMetapageDefinitionToCurrentVersion=void 0;var e=require("compare-versions"),t=require("./Shared"),r=require("./v0_4"),o=function(e,t,r,o){return new(r||(r=Promise))(function(a,n){function s(e){try{c(o.next(e))}catch(t){n(t)}}function i(e){try{c(o.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,i)}c((o=o.apply(e,t||[])).next())})};const a=e=>{if(null===e)throw"Metapage definition cannot be null";if("string"==typeof e)try{e=JSON.parse(e)}catch(o){throw`Cannot parse into JSON:\n${e}`}if(!e.version)throw'Missing "version" key in metapage definition';let t;switch(c(e.version)){case r.VersionsMetapage.V0_2:t=a(s(e));break;case r.VersionsMetapage.V0_3:t=e;break;default:console.warn(`Metapage definition version=${e.version} but we only know up to version ${r.MetapageVersionCurrent}. Assuming the definition is compatible, but it's the future!`),t=e}return t};exports.convertMetapageDefinitionToCurrentVersion=a;const n=e=>{switch(e.version){case r.VersionsMetaframe.V0_3:case r.VersionsMetaframe.V0_4:const t=e;return{version:r.VersionsMetaframe.V0_5,inputs:t.inputs,outputs:t.outputs,allow:t.allow,metadata:t.metadata?{name:t.metadata.title,author:t.metadata.author,image:t.metadata.image,description:t.metadata.descriptionUrl,tags:t.metadata.keywords}:void 0};case r.VersionsMetaframe.V0_5:return e;default:throw`Unsupported metaframe version: ${e.version}. Please upgrade to a new version: npm i @metapages/metapage@latest`}};exports.convertMetaframeJsonToCurrentVersion=n;const s=e=>(e.version=r.VersionsMetapage.V0_3,e),i=(e,t)=>{if(!t)return!1;let r=!1;return Object.keys(t).forEach(o=>{r=!0,void 0===t[o]?delete e[o]:e[o]=t[o]}),r};exports.merge=i;const c=t=>{if("latest"===t)return r.MetapageVersionCurrent;if((0,e.compare)(t,"0.2","<"))throw`Unknown version: ${t}`;return(0,e.compare)(t,"0.2",">=")&&(0,e.compare)(t,r.VersionsMetapage.V0_3,"<")?r.VersionsMetapage.V0_2:(0,e.compare)(t,"0.3",">=")?r.VersionsMetapage.V0_3:(console.log(`Could not match version=${t} to any known version, assuming ${r.MetapageVersionCurrent}`),r.MetapageVersionCurrent)};exports.getMatchingVersion=c;const p=e=>window.location.search?new URLSearchParams(window.location.search).get(e):null;exports.getUrlParam=p;const g=()=>new URLSearchParams(window.location.search).has(t.MetapageHashParams.mp_debug);exports.getUrlParamDebug=g;const u=()=>{const e=new URLSearchParams(window.location.search).get(t.MetapageHashParams.mp_debug);return"true"===e||"1"===e};exports.isDebugFromUrlsParams=u;const d=e=>{return e.filter(e=>new URLSearchParams(window.location.search).has(e)).length>0};exports.existsAnyUrlParam=d;const l=(e=8)=>v(e);exports.generateMetaframeId=l;const m=(e=8)=>v(e);exports.generateMetapageId=m;const h=(e=8)=>v(e);exports.generateNonce=h;const f="abcdefghijklmnopqrstuvwxyz0123456789",v=(e=8)=>{for(var t="",r=f.length,o=0;o<e;o++)t+=f.charAt(Math.floor(Math.random()*r));return t};exports.generateId=v;const x=(e,t,r)=>{let o;if((t=t||"000")&&""==t.trim()&&(t=void 0),o="string"==typeof e?e:"number"==typeof e?e+"":JSON.stringify(e,null," "),t&&""!=t.trim()){var a=`color: #${t}`;r&&(a=`${a}; background: #${r}`),o=`%c${o}`,window.console.log(o,a)}else window.console.log(o)};exports.log=x;const w=e=>V(M(e));exports.stringToRgb=w;const M=e=>{var t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return t};exports.hashCode=M;const V=e=>{var t=(16777215&e).toString(16).toUpperCase();return"00000".substring(0,6-t.length)+t};exports.intToRGB=V;const P=()=>"complete"==document.readyState||"interactive"==document.readyState;exports.isPageLoaded=P;const b=()=>o(void 0,void 0,void 0,function*(){return P()?Promise.resolve():new Promise(e=>{if(P())return void e();let t=!1;window.addEventListener("load",()=>{t||(t=!0,e())});setTimeout(()=>{!t&&P()&&(t=!0,e())},200)})});exports.pageLoaded=b;
23
+ },{"compare-versions":"p8iL","./Shared":"Q9lO","./v0_4":"1svx"}],"NK90":[function(require,module,exports) {
24
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetaframePlugin=exports.Metaframe=exports.MetaframeEvents=exports.MetaframeLoadingState=void 0;var t,e,s=require("eventemitter3"),i=require("./Constants"),n=require("./v0_4"),r=require("./MetapageTools"),a=require("./Shared"),o=function(t,e,s,i){return new(s||(s=Promise))(function(n,r){function a(t){try{h(i.next(t))}catch(e){r(e)}}function o(t){try{h(i.throw(t))}catch(e){r(e)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(a,o)}h((i=i.apply(t,e||[])).next())})};exports.MetaframeLoadingState=t,function(t){t.WaitingForPageLoad="WaitingForPageLoad",t.SentSetupIframeClientRequest="SentSetupIframeClientRequest",t.Ready="Ready"}(t||(exports.MetaframeLoadingState=t={})),exports.MetaframeEvents=e,function(t){t.Connected="connected",t.Error="error",t.Input="input",t.Inputs="inputs",t.Message="message"}(e||(exports.MetaframeEvents=e={}));class h extends s.EventEmitter{constructor(e){if(super(),this._inputPipeValues={},this._outputPipeValues={},this._state=t.WaitingForPageLoad,this._messageSendCount=0,this.debug=(0,r.isDebugFromUrlsParams)(),this.id=window.name,this.debug=(0,r.isDebugFromUrlsParams)(),this._isIframe=(0,a.isIframe)(),this.addListener=this.addListener.bind(this),this.dispose=this.dispose.bind(this),this.error=this.error.bind(this),this.getInput=this.getInput.bind(this),this.getInputs=this.getInputs.bind(this),this.getOutput=this.getOutput.bind(this),this.getOutputs=this.getOutputs.bind(this),this.log=this.log.bind(this),this.logInternal=this.logInternal.bind(this),this.onInput=this.onInput.bind(this),this.onInputs=this.onInputs.bind(this),this.onMessage=this.onMessage.bind(this),this.sendRpc=this.sendRpc.bind(this),this.setInput=this.setInput.bind(this),this.setInputs=this.setInputs.bind(this),this.setInternalInputsAndNotify=this.setInternalInputsAndNotify.bind(this),this.setOutput=this.setOutput.bind(this),this.setOutputs=this.setOutputs.bind(this),this.warn=this.warn.bind(this),this._resolveSetupIframeServerResponse=this._resolveSetupIframeServerResponse.bind(this),this.addListenerReturnDisposer=this.addListenerReturnDisposer.bind(this),this.connected=this.connected.bind(this),this.disableNotifyOnHashUrlChange=this.disableNotifyOnHashUrlChange.bind(this),this._onHashUrlChange=this._onHashUrlChange.bind(this),!this._isIframe)return void this.log("Not an iframe, metaframe code disabled");const s=this;(0,r.pageLoaded)().then(()=>{this.log("pageLoaded"),window.addEventListener("message",this.onMessage),s.sendRpc(n.JsonRpcMethodsFromChild.SetupIframeClientRequest,{version:h.version}),s._state=t.SentSetupIframeClientRequest}),(null==e?void 0:e.disableHashChangeEvent)||window.addEventListener("hashchange",this._onHashUrlChange)}_resolveSetupIframeServerResponse(s){if(this._state===t.WaitingForPageLoad)throw"Got message but page has not finished loading, we should never get in this state";this._parentId?this.log("Got JsonRpcMethods.SetupIframeServerResponse but already resolved"):(this._parentVersion=s.version,this.color=(0,r.stringToRgb)(this.id),this._parentId=s.parentId,this.log(`metapage[${this._parentId}](v${this._parentVersion?this._parentVersion:"unknown"}) registered`),this._inputPipeValues=s.state&&s.state.inputs?s.state.inputs:this._inputPipeValues,this._state=t.Ready,this.sendRpc(n.JsonRpcMethodsFromChild.SetupIframeServerResponseAck,{version:h.version}),this._inputPipeValues&&Object.keys(this._inputPipeValues).length>0&&(this.emit(e.Inputs,this._inputPipeValues),Object.keys(this._inputPipeValues).forEach(t=>this.emit(e.Input,t,this._inputPipeValues[t]))),this.emit(e.Inputs,this._inputPipeValues),s.plugin&&(this.plugin=new u(this)),this.emit(e.Connected))}connected(){return o(this,void 0,void 0,function*(){if(this._state!==t.Ready)return new Promise((t,s)=>{let i;i=this.addListenerReturnDisposer(e.Connected,()=>{t(),i()})})})}addListenerReturnDisposer(t,e){super.addListener(t,e);return()=>{super.removeListener(t,e)}}log(t,e,s){this.debug&&this.logInternal(t,e||this.color)}warn(t){this.debug&&this.logInternal(t,"000",this.color)}error(t){this.logInternal(t,this.color,"f00")}logInternal(t,e,s){let i;i="string"==typeof t?t:"number"==typeof t?t+"":JSON.stringify(t),e=e?e+"":e,i=(this.id?`Metaframe[${this.id}] `:"")+`${i}`,(0,r.log)(i,e,s)}dispose(){super.removeAllListeners(),window.removeEventListener("message",this.onMessage),this.disableNotifyOnHashUrlChange(),this._inputPipeValues=void 0,this._outputPipeValues=void 0}addListener(t,s){return super.addListener(t,s),t===e.Inputs&&window.setTimeout(()=>{this._inputPipeValues&&s(this._inputPipeValues)},0),this}onInput(t,s){return this.addListenerReturnDisposer(e.Input,(e,i)=>{t===e&&s(i)})}onInputs(t){return this.addListenerReturnDisposer(e.Inputs,t)}setInput(t,e){var s={};s[t]=e,this.setInputs(s)}setInputs(t){this.sendRpc(n.JsonRpcMethodsFromChild.InputsUpdate,t)}setInternalInputsAndNotify(t){(0,r.merge)(this._inputPipeValues,t)&&(Object.keys(t).forEach(s=>this.emit(e.Input,s,t[s])),this.emit(e.Inputs,t))}getInput(t){return console.assert(!!t),this._inputPipeValues[t]}getInputs(){return this._inputPipeValues}getOutput(t){return console.assert(!!t),this._outputPipeValues[t]}setOutput(t,e){console.assert(!!t);var s={};s[t]=e,this.setOutputs(s)}setOutputs(t){(0,r.merge)(this._outputPipeValues,t)&&this.sendRpc(n.JsonRpcMethodsFromChild.OutputsUpdate,t)}getOutputs(){return this._outputPipeValues}disableNotifyOnHashUrlChange(){window.removeEventListener("hashchange",this._onHashUrlChange)}_onHashUrlChange(t){const e={hash:window.location.hash,metaframe:this.id};this.sendRpc(n.JsonRpcMethodsFromChild.HashParamsUpdate,e)}sendRpc(t,e){if(this._isIframe){const s={jsonrpc:"2.0",id:++this._messageSendCount,method:t,params:e,iframeId:this.id,parentId:this._parentId};window.parent.postMessage(s,"*")}else this.log("Cannot send JSON-RPC window message: there is no window.parent which means we are not an iframe")}onMessage(s){if("object"==typeof s.data){let r=s.data;if("2.0"===r.jsonrpc){var i=r.method;if(i!=n.JsonRpcMethodsFromParent.SetupIframeServerResponse&&(r.parentId!=this._parentId||r.iframeId!=this.id))return void this.error(`window.message: received message but jsonrpc.parentId=${r.parentId} _parentId=${this._parentId} jsonrpc.iframeId=${r.iframeId} id=${this.id}`);switch(i){case n.JsonRpcMethodsFromParent.SetupIframeServerResponse:this._resolveSetupIframeServerResponse(r.params);break;case n.JsonRpcMethodsFromParent.InputsUpdate:if(this._state!==t.Ready)throw"Got InputsUpdate but metaframe is not MetaframeLoadingState.Ready";this.setInternalInputsAndNotify(r.params.inputs);break;case n.JsonRpcMethodsFromParent.MessageAck:this.debug&&this.log(`ACK: ${JSON.stringify(r)}`);break;default:this.debug&&this.log(`window.message: unknown JSON-RPC method: ${JSON.stringify(r)}`)}this.emit(e.Message,r)}}}}exports.Metaframe=h,h.version=i.VERSION_METAFRAME,h.ERROR=e.Error,h.CONNECTED=e.Connected,h.INPUT=e.Input,h.INPUTS=e.Inputs,h.MESSAGE=e.Message;class u{constructor(t){this._metaframe=t,this.requestState=this.requestState.bind(this),this.onState=this.onState.bind(this),this.getState=this.getState.bind(this),this.setState=this.setState.bind(this),this.onDefinition=this.onDefinition.bind(this),this.getDefinition=this.getDefinition.bind(this),this.setDefinition=this.setDefinition.bind(this)}requestState(){var t={method:n.ApiPayloadPluginRequestMethod.State};this._metaframe.sendRpc(n.JsonRpcMethodsFromChild.PluginRequest,t)}onState(t){const e=this._metaframe.onInput(i.METAPAGE_KEY_STATE,t);return this.getState()&&t(this.getState()),e}getState(){return this._metaframe.getInput(i.METAPAGE_KEY_STATE)}setState(t){this._metaframe.setOutput(i.METAPAGE_KEY_STATE,t)}onDefinition(t){var e=this._metaframe.onInput(i.METAPAGE_KEY_DEFINITION,t);return this.getDefinition()&&t(this.getDefinition()),e}setDefinition(t){this._metaframe.setOutput(i.METAPAGE_KEY_DEFINITION,t)}getDefinition(){return this._metaframe.getInput(i.METAPAGE_KEY_DEFINITION)}}exports.MetaframePlugin=u;
25
+ },{"eventemitter3":"UASB","./Constants":"Xnuv","./v0_4":"1svx","./MetapageTools":"f0H1","./Shared":"Q9lO"}]},{},["NK90"], "metapage")
26
+ //# sourceMappingURL=/index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../node_modules/eventemitter3/index.js","v0_4/versions.ts","v0_4/core.ts","v0_4/events.ts","v0_4/jsonrpc.ts","v0_4/index.ts","Constants.ts","../../node_modules/compare-versions/index.mjs","Shared.ts","MetapageTools.ts","Metaframe.ts"],"names":["compareVersions","v1","v2","n1","validateAndParse","n2","p1","pop","p2","r","compareSegments","split","validate","v","test","semver","compare","operator","assertValidOperator","res","operatorResMap","includes","satisfies","m","match","op","v3","r1","r2","r3","compareStrings","TypeError","Error","shift","isWildcard","s","tryParse","n","parseInt","isNaN","forceType","a","b","String","ap","bp","i","Math","max","length","allowedOperators","Object","keys","indexOf","join"],"mappings":";AAAA,aAEA,IAAA,EAAA,OAAA,UAAA,eACA,EAAA,IASA,SAAA,KA4BA,SAAA,EAAA,EAAA,EAA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efix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","// There used to be a single version, but there's no reason to upgrade both versions\n// simultaneously. Same vesions are an ideal, but forcing it is also bad\n\nexport enum VersionsMetaframe {\n\tV0_3 = \"0.3\",\n\tV0_4 = \"0.4\",\n\tV0_5 = \"0.5\",\n}\n\nexport enum VersionsMetapage {\n\tV0_2 = \"0.2\",\n\tV0_3 = \"0.3\",\n}\n\nexport const MetaframeVersionsAll = Object.keys(VersionsMetaframe);\n\nexport const MetaframeVersionCurrent = VersionsMetaframe.V0_5;\n\nexport const MetapageVersionsAll = Object.keys(VersionsMetapage);\n\nexport const MetapageVersionCurrent = VersionsMetapage.V0_3;\n","export { MetaframeVersionCurrent, MetapageVersionCurrent, MetaframeVersionsAll, MetapageVersionsAll } from './versions';\nexport type Url = string;\nexport type MetaframePipeId = string;\nexport type MetaframeId = string;\nexport type MetapageId = string;\n","import { MetaframeId, MetapageDefinitionV3 } from \".\";\nimport { MetapageIFrameRpcClient } from \"../MetapageIFrameRpcClient\";\n\nexport enum MetapageEvents {\n Inputs = \"inputs\",\n Outputs = \"outputs\",\n State = \"state\",\n // The definition has already changed e.g. a metaframe changes its hash params\n // so the current definition now contains that change\n Definition = \"definition\",\n // A plugin is requesting to modify the definition\n // This is not automatically processed, the context of the metapage decides what\n // to do with this update (apply, recreate metapage, ignore etc)\n DefinitionUpdateRequest = \"definitionupdaterequest\",\n Error = \"error\",\n // when a metaframe wants to tell the metapage of the new URL (for saving state/config)\n UrlHashUpdate = \"urlhashupdate\",\n // general event, all events are emitted in their raw form to this namespace\n Message = \"Message\",\n}\n\nexport interface MetapageEventDefinition {\n definition: MetapageDefinitionV3;\n metaframes: {\n [key: string]: MetapageIFrameRpcClient;\n };\n plugins?: {\n [key: string]: MetapageIFrameRpcClient;\n };\n}\n\nexport type MetapageEventUrlHashUpdate = {\n metaframe: MetaframeId;\n hash: string;\n};\n","import { MetaframeId, MetapageId } from \"./core\";\nimport { VersionsMetaframe, VersionsMetapage } from \"./versions\";\nimport { MetaframeInputMap} from \"./metapage\";\nimport { JsonRpcRequest } from '../jsonrpc2';\n\nexport enum JsonRpcMethodsFromChild {\n InputsUpdate = \"InputsUpdate\",\n OutputsUpdate = \"OutputsUpdate\",\n SetupIframeClientRequest = \"SetupIframeClientRequest\",\n SetupIframeServerResponseAck = \"SetupIframeServerResponseAck\",\n // Plugin API\n PluginRequest = \"SetupIframeServerPluginRequestResponseAck\", // See further definitions: ApiPayloadPluginRequest*\n // Experimental feature\n HashParamsUpdate = \"HashParamsUpdate\",\n}\n\nexport enum JsonRpcMethodsFromParent {\n InputsUpdate = \"InputsUpdate\",\n MessageAck = \"MessageAck\",\n SetupIframeServerResponse = \"SetupIframeServerResponse\"\n}\n\nexport interface SetupIframeServerResponseData {\n iframeId: MetaframeId;\n parentId: MetapageId;\n state: {\n inputs: MetaframeInputMap\n };\n // Allow newer metaframes to handle older metapage versions\n version: VersionsMetapage;\n //is this metaframe a plugin?\n plugin: boolean;\n}\n\nexport interface MinimumClientMessage<T> extends JsonRpcRequest<T> {\n iframeId: MetaframeId | undefined;\n parentId: MetapageId | undefined;\n}\n\nexport interface SetupIframeClientAckData<T> extends MinimumClientMessage<T> {\n version: VersionsMetaframe;\n}\n\nexport interface ClientMessageRecievedAck<T> {\n message: MinimumClientMessage<T>;\n}\n\n// Plugin API definitions\nexport enum ApiPayloadPluginRequestMethod {\n State = \"metapage/state\"\n}\n\nexport interface ApiPayloadPluginRequest {\n method: ApiPayloadPluginRequestMethod;\n}\n","export * from \"./core\";\nexport * from \"./events\";\nexport * from \"./jsonrpc\";\nexport * from \"./metaframe\";\nexport * from \"./metapage\";\nexport * from \"./versions\";\n","import {MetapageVersionsAll, MetaframeVersionsAll} from \"./v0_4\";\n\nexport const METAFRAME_JSON_FILE = \"metaframe.json\";\nexport const METAPAGE_KEY_DEFINITION = \"metapage/definition\";\nexport const METAPAGE_KEY_STATE = \"metapage/state\";\n\nexport const VERSION_METAPAGE = MetapageVersionsAll[MetapageVersionsAll.length - 1];\nexport const VERSION_METAFRAME = MetaframeVersionsAll[MetaframeVersionsAll.length - 1];\n","export default function compareVersions(v1, v2) {\n // validate input and split into segments\n const n1 = validateAndParse(v1);\n const n2 = validateAndParse(v2);\n\n // pop off the patch\n const p1 = n1.pop();\n const p2 = n2.pop();\n\n // validate numbers\n const r = compareSegments(n1, n2);\n if (r !== 0) return r;\n\n // validate pre-release\n if (p1 && p2) {\n return compareSegments(p1.split('.'), p2.split('.'));\n } else if (p1 || p2) {\n return p1 ? -1 : 1;\n }\n\n return 0;\n}\n\nexport const validate = (v) =>\n typeof v === 'string' && /^[v\\d]/.test(v) && semver.test(v);\n\nexport const compare = (v1, v2, operator) => {\n // validate input operator\n assertValidOperator(operator);\n\n // since result of compareVersions can only be -1 or 0 or 1\n // a simple map can be used to replace switch\n const res = compareVersions(v1, v2);\n\n return operatorResMap[operator].includes(res);\n};\n\nexport const satisfies = (v, r) => {\n // if no range operator then \"=\"\n const m = r.match(/^([<>=~^]+)/);\n const op = m ? m[1] : '=';\n\n // if gt/lt/eq then operator compare\n if (op !== '^' && op !== '~') return compare(v, r, op);\n\n // else range of either \"~\" or \"^\" is assumed\n const [v1, v2, v3] = validateAndParse(v);\n const [r1, r2, r3] = validateAndParse(r);\n if (compareStrings(v1, r1) !== 0) return false;\n if (op === '^') {\n return compareSegments([v2, v3], [r2, r3]) >= 0;\n }\n if (compareStrings(v2, r2) !== 0) return false;\n return compareStrings(v3, r3) >= 0;\n};\n\n// export CJS style for parity\ncompareVersions.validate = validate;\ncompareVersions.compare = compare;\ncompareVersions.satisfies = satisfies;\n\nconst semver =\n /^[v^~<>=]*?(\\d+)(?:\\.([x*]|\\d+)(?:\\.([x*]|\\d+)(?:\\.([x*]|\\d+))?(?:-([\\da-z\\-]+(?:\\.[\\da-z\\-]+)*))?(?:\\+[\\da-z\\-]+(?:\\.[\\da-z\\-]+)*)?)?)?$/i;\n\nconst validateAndParse = (v) => {\n if (typeof v !== 'string') {\n throw new TypeError('Invalid argument expected string');\n }\n const match = v.match(semver);\n if (!match) {\n throw new Error(`Invalid argument not valid semver ('${v}' received)`);\n }\n match.shift();\n return match;\n};\n\nconst isWildcard = (s) => s === '*' || s === 'x' || s === 'X';\n\nconst tryParse = (v) => {\n const n = parseInt(v, 10);\n return isNaN(n) ? v : n;\n};\n\nconst forceType = (a, b) =>\n typeof a !== typeof b ? [String(a), String(b)] : [a, b];\n\nconst compareStrings = (a, b) => {\n if (isWildcard(a) || isWildcard(b)) return 0;\n const [ap, bp] = forceType(tryParse(a), tryParse(b));\n if (ap > bp) return 1;\n if (ap < bp) return -1;\n return 0;\n};\n\nconst compareSegments = (a, b) => {\n for (let i = 0; i < Math.max(a.length, b.length); i++) {\n const r = compareStrings(a[i] || 0, b[i] || 0);\n if (r !== 0) return r;\n }\n return 0;\n};\n\nconst operatorResMap = {\n '>': [1],\n '>=': [0, 1],\n '=': [0],\n '<=': [-1, 0],\n '<': [-1],\n};\n\nconst allowedOperators = Object.keys(operatorResMap);\n\nconst assertValidOperator = (op) => {\n if (typeof op !== 'string') {\n throw new TypeError(\n `Invalid operator type, expected string but got ${typeof op}`\n );\n }\n if (allowedOperators.indexOf(op) === -1) {\n throw new Error(\n `Invalid operator, expected one of ${allowedOperators.join('|')}`\n );\n }\n};\n","import { EventEmitter } from \"eventemitter3\";\nimport {\n JsonRpcMethodsFromParent,\n MetapageDefinitionV3,\n MetapageVersionCurrent,\n} from \"./v0_4\";\nimport { MetapageEvents } from \"./v0_4/events\";\n\nexport enum MetapageHashParams {\n mp_debug = \"mp_debug\",\n}\n\nexport const isIframe = (): boolean => {\n //http://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t\n try {\n return window !== window.top;\n } catch (ignored) {\n return false;\n }\n};\n\nexport const INITIAL_NULL_METAPAGE_DEFINITION: MetapageDefinitionV3 = {\n version: MetapageVersionCurrent,\n metaframes: {},\n};\n\nexport class MetapageShared extends EventEmitter<\n MetapageEvents | JsonRpcMethodsFromParent\n> {\n // Easier to ensure this value is never null|undefined\n _definition: MetapageDefinitionV3 = INITIAL_NULL_METAPAGE_DEFINITION;\n\n constructor() {\n super();\n this.getDefinition = this.getDefinition.bind(this);\n }\n\n public error(err: any) {\n throw \"Subclass should implement\";\n }\n public getDefinition(): MetapageDefinitionV3 {\n return this._definition;\n }\n}\n","import { compare } from \"compare-versions\";\nimport { MetapageHashParams } from \"./Shared\";\nimport {\n MetaframeInputMap,\n MetaframeId,\n MetapageId,\n VersionsMetapage,\n MetapageVersionCurrent,\n MetaframeDefinitionV5,\n VersionsMetaframe,\n MetaframeDefinitionV4,\n MetapageDefinitionV3,\n} from \"./v0_4\";\nimport { MetapageDefinition as V0_2MetapageDefinition } from \"./v0_2/all\";\nimport { MetapageDefinition as V0_3MetapageDefinition } from \"./v0_3/all\";\n\nexport const convertMetapageDefinitionToCurrentVersion = (\n def: any | MetapageDefinitionV3\n): MetapageDefinitionV3 => {\n if (def === null) {\n throw \"Metapage definition cannot be null\";\n }\n if (typeof def === \"string\") {\n try {\n def = JSON.parse(def);\n } catch (err) {\n throw `Cannot parse into JSON:\\n${def}`;\n }\n }\n\n if (!def.version) {\n throw 'Missing \"version\" key in metapage definition';\n }\n\n // Recursively convert up the version\n let updatedDefinition: MetapageDefinitionV3;\n\n switch (getMatchingVersion(def.version)) {\n case VersionsMetapage.V0_2: {\n updatedDefinition = convertMetapageDefinitionToCurrentVersion(\n definition_v0_2_to_v0_3(def as V0_2MetapageDefinition)\n );\n break;\n }\n case VersionsMetapage.V0_3: {\n updatedDefinition = def as MetapageDefinitionV3; // Latest\n break;\n }\n default: // Latest\n console.warn(\n `Metapage definition version=${def.version} but we only know up to version ${MetapageVersionCurrent}. Assuming the definition is compatible, but it's the future!`\n );\n updatedDefinition = def as MetapageDefinitionV3;\n break;\n }\n return updatedDefinition;\n};\n\nexport const convertMetaframeJsonToCurrentVersion = (\n m: MetaframeDefinitionV5 | MetaframeDefinitionV4\n): MetaframeDefinitionV5 => {\n switch (m.version) {\n case VersionsMetaframe.V0_3:\n case VersionsMetaframe.V0_4:\n const source: MetaframeDefinitionV4 = m as MetaframeDefinitionV4;\n const metaframeDefV5: MetaframeDefinitionV5 = {\n version: VersionsMetaframe.V0_5,\n inputs: source.inputs,\n outputs: source.outputs,\n allow: source.allow,\n metadata: source.metadata\n ? {\n name: source.metadata.title,\n author: source.metadata.author,\n image: source.metadata.image,\n description: source.metadata.descriptionUrl,\n tags: source.metadata.keywords,\n }\n : undefined,\n };\n return metaframeDefV5;\n case VersionsMetaframe.V0_5:\n return m as MetaframeDefinitionV5;\n default:\n throw `Unsupported metaframe version: ${m.version}. Please upgrade to a new version: npm i @metapages/metapage@latest`;\n }\n};\n\nconst definition_v0_2_to_v0_3 = (\n old: V0_2MetapageDefinition\n): V0_3MetapageDefinition => {\n // Exactly the same except v0.3 has plugins\n old.version = VersionsMetapage.V0_3;\n return old;\n};\n\n/**\n * Merges new values into the current object.\n * Does NOT check if there are actually new keys.\n * Does NOT check values against each other. This means you\n * can keep sending the same value, and the message will\n * be passed in.\n * Returns true if the original map was modified.\n */\nexport const merge = (\n current: MetaframeInputMap,\n newInputs: MetaframeInputMap\n): boolean => {\n if (!newInputs) {\n return false;\n }\n let modified = false;\n Object.keys(newInputs).forEach((pipeId: string) => {\n modified = true;\n // undefined means remove the key\n // null means keep the key, but set to null\n if (newInputs[pipeId] === undefined) {\n delete current[pipeId];\n } else {\n current[pipeId] = newInputs[pipeId];\n }\n });\n return modified;\n};\n\nexport const getMatchingVersion = (version: string): VersionsMetapage => {\n if (version === \"latest\") {\n return MetapageVersionCurrent;\n } else if (compare(version, \"0.2\", \"<\")) {\n throw `Unknown version: ${version}`;\n } else if (\n compare(version, \"0.2\", \">=\") &&\n compare(version, VersionsMetapage.V0_3, \"<\")\n ) {\n return VersionsMetapage.V0_2;\n } else if (compare(version, \"0.3\", \">=\")) {\n return VersionsMetapage.V0_3;\n } else {\n // Return something, assume latest\n console.log(\n `Could not match version=${version} to any known version, assuming ${MetapageVersionCurrent}`\n );\n return MetapageVersionCurrent;\n }\n};\n\nexport const getUrlParam = (key: MetapageHashParams): string | null => {\n if (!window.location.search) {\n return null;\n }\n return new URLSearchParams(window.location.search).get(key);\n};\n\nexport const getUrlParamDebug = (): boolean => {\n return new URLSearchParams(window.location.search).has(\n MetapageHashParams.mp_debug\n );\n};\n\nexport const isDebugFromUrlsParams = (): boolean => {\n const param = new URLSearchParams(window.location.search).get(\n MetapageHashParams.mp_debug\n );\n return param === \"true\" || param === \"1\";\n};\n\nexport const existsAnyUrlParam = (k: string[]): boolean => {\n const members = k.filter((param: string) => {\n return new URLSearchParams(window.location.search).has(param);\n });\n return members.length > 0;\n};\n\nexport const generateMetaframeId = (length: number = 8): MetaframeId => {\n return generateId(length);\n};\n\nexport const generateMetapageId = (length: number = 8): MetapageId => {\n return generateId(length);\n};\n\nexport const generateNonce = (length: number = 8): string => {\n return generateId(length);\n};\n\nconst LETTERS = \"abcdefghijklmnopqrstuvwxyz0123456789\";\nexport const generateId = (length: number = 8): string => {\n var result = \"\";\n var characters =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n var charactersLength = LETTERS.length;\n for (var i = 0; i < length; i++) {\n result += LETTERS.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n};\n\nexport const log = (o: any, color?: string, backgroundColor?: string) => {\n color = color ? color : \"000\";\n if (color && color.trim() == \"\") {\n color = undefined;\n }\n let s: string;\n if (typeof o === \"string\") {\n s = o as string;\n } else if (typeof o === \"number\") {\n s = o + \"\";\n } else {\n s = JSON.stringify(o, null, \" \");\n }\n\n if (color && color.trim() != \"\") {\n var cssstring = `color: #${color}`;\n if (backgroundColor) {\n cssstring = `${cssstring}; background: #${backgroundColor}`;\n }\n s = `%c${s}`;\n window.console.log(s, cssstring);\n } else {\n window.console.log(s);\n }\n};\n\nexport const stringToRgb = (str: string): string => {\n return intToRGB(hashCode(str));\n};\n\nexport const hashCode = (str: string): number => {\n // java string#hashCode\n var hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n return hash;\n};\n\nexport const intToRGB = (i: number): string => {\n var c = (i & 0x00ffffff).toString(16).toUpperCase();\n return \"00000\".substring(0, 6 - c.length) + c;\n};\n\nexport const isPageLoaded = (): boolean => {\n return (\n document.readyState == \"complete\" || document.readyState == \"interactive\"\n );\n // https://stackoverflow.com/questions/13364613/how-to-know-if-window-load-event-was-fired-already/28093606\n // // TODO ugh casting here but I can't seem to get the right type with the loadEventEnd\n // return window.performance.getEntriesByType(\"navigation\").every((e) => { return (e as PerformanceNavigationTiming).loadEventEnd > 0 });\n};\n\nexport const pageLoaded = async (): Promise<void> => {\n if (isPageLoaded()) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n if (isPageLoaded()) {\n resolve();\n return;\n }\n let loaded = false;\n window.addEventListener(\"load\", () => {\n if (loaded) {\n return;\n }\n loaded = true;\n resolve();\n });\n // tiny chance of missing the document.readyState === \"loaded\"\n const timer = setTimeout(() => {\n if (!loaded && isPageLoaded()) {\n loaded = true;\n resolve();\n }\n }, 200);\n });\n};\n","import { EventEmitter, ListenerFn } from \"eventemitter3\";\nimport {\n VERSION_METAFRAME,\n METAPAGE_KEY_STATE,\n METAPAGE_KEY_DEFINITION,\n} from \"./Constants\";\nimport {\n MetaframeId,\n MetaframeInputMap,\n MetaframePipeId,\n MetapageId,\n ApiPayloadPluginRequest,\n ApiPayloadPluginRequestMethod,\n JsonRpcMethodsFromParent,\n JsonRpcMethodsFromChild,\n SetupIframeServerResponseData,\n MinimumClientMessage,\n VersionsMetapage,\n} from \"./v0_4\";\nimport {\n isDebugFromUrlsParams,\n stringToRgb,\n log as MetapageToolsLog,\n merge,\n pageLoaded,\n} from \"./MetapageTools\";\nimport { isIframe } from \"./Shared\";\nimport { MetapageEventUrlHashUpdate } from \"./v0_4/events\";\n\n// TODO combine/unify MetaframeEvents and MetaframeLoadingState\nexport enum MetaframeLoadingState {\n WaitingForPageLoad = \"WaitingForPageLoad\",\n SentSetupIframeClientRequest = \"SentSetupIframeClientRequest\",\n Ready = \"Ready\",\n}\n\nexport enum MetaframeEvents {\n Connected = \"connected\",\n Error = \"error\",\n Input = \"input\",\n Inputs = \"inputs\",\n Message = \"message\",\n}\n\nexport type MetaframeOptions = {\n disableHashChangeEvent?: boolean;\n};\n\nexport class Metaframe extends EventEmitter<\n MetaframeEvents | JsonRpcMethodsFromChild\n> {\n public static readonly version = VERSION_METAFRAME;\n\n public static readonly ERROR = MetaframeEvents.Error;\n public static readonly CONNECTED = MetaframeEvents.Connected;\n public static readonly INPUT = MetaframeEvents.Input;\n public static readonly INPUTS = MetaframeEvents.Inputs;\n public static readonly MESSAGE = MetaframeEvents.Message;\n\n _inputPipeValues: MetaframeInputMap = {};\n _outputPipeValues: MetaframeInputMap = {};\n _parentId: MetapageId | undefined;\n _parentVersion: VersionsMetapage | undefined;\n _isIframe: boolean;\n _state: MetaframeLoadingState = MetaframeLoadingState.WaitingForPageLoad;\n _messageSendCount = 0;\n\n debug: boolean = isDebugFromUrlsParams();\n color: string | undefined;\n plugin: MetaframePlugin | undefined;\n\n /**\n * This is the (locally) unique id that the parent metapage\n * assigns to the metaframe via iframe.name which we get here as window.name\n */\n id: string = window.name;\n\n constructor(options?: MetaframeOptions) {\n super();\n this.debug = isDebugFromUrlsParams();\n this._isIframe = isIframe();\n\n this.addListener = this.addListener.bind(this);\n this.dispose = this.dispose.bind(this);\n this.error = this.error.bind(this);\n this.getInput = this.getInput.bind(this);\n this.getInputs = this.getInputs.bind(this);\n this.getOutput = this.getOutput.bind(this);\n this.getOutputs = this.getOutputs.bind(this);\n this.log = this.log.bind(this);\n this.logInternal = this.logInternal.bind(this);\n this.onInput = this.onInput.bind(this);\n this.onInputs = this.onInputs.bind(this);\n this.onMessage = this.onMessage.bind(this);\n this.sendRpc = this.sendRpc.bind(this);\n this.setInput = this.setInput.bind(this);\n this.setInputs = this.setInputs.bind(this);\n this.setInternalInputsAndNotify =\n this.setInternalInputsAndNotify.bind(this);\n this.setOutput = this.setOutput.bind(this);\n this.setOutputs = this.setOutputs.bind(this);\n this.warn = this.warn.bind(this);\n this._resolveSetupIframeServerResponse =\n this._resolveSetupIframeServerResponse.bind(this);\n this.addListenerReturnDisposer = this.addListenerReturnDisposer.bind(this);\n this.connected = this.connected.bind(this);\n this.disableNotifyOnHashUrlChange =\n this.disableNotifyOnHashUrlChange.bind(this);\n this._onHashUrlChange = this._onHashUrlChange.bind(this);\n\n if (!this._isIframe) {\n //Don't add any of the machinery, it only works if we're iframes.\n //This will never return\n // this.ready = new Promise((_) => {});\n this.log(\"Not an iframe, metaframe code disabled\");\n return;\n }\n\n const thisRef = this;\n // Do no listen or send messages until the page is loaded\n // This iframe is not created UNTIL the parent page is loaded and listening to messages\n pageLoaded().then(() => {\n this.log(\"pageLoaded\");\n window.addEventListener(\"message\", this.onMessage);\n // Now that we're listening, request to the parent to register us so we can talk\n thisRef.sendRpc(JsonRpcMethodsFromChild.SetupIframeClientRequest, {\n version: Metaframe.version,\n });\n thisRef._state = MetaframeLoadingState.SentSetupIframeClientRequest;\n });\n\n if (!options?.disableHashChangeEvent) {\n window.addEventListener(\"hashchange\", this._onHashUrlChange);\n }\n }\n\n _resolveSetupIframeServerResponse(params: SetupIframeServerResponseData) {\n if (this._state === MetaframeLoadingState.WaitingForPageLoad) {\n throw \"Got message but page has not finished loading, we should never get in this state\";\n }\n\n if (!this._parentId) {\n this._parentVersion = params.version;\n this.color = stringToRgb(this.id);\n this._parentId = params.parentId;\n this.log(\n `metapage[${this._parentId}](v${\n this._parentVersion ? this._parentVersion : \"unknown\"\n }) registered`\n );\n\n this._inputPipeValues =\n params.state && params.state.inputs\n ? params.state.inputs\n : this._inputPipeValues;\n\n //Tell the parent we have registered.\n this._state = MetaframeLoadingState.Ready;\n // TODO why do we need Metaframe.version here? It was sent in the initial SetupIframeClientRequest\n this.sendRpc(JsonRpcMethodsFromChild.SetupIframeServerResponseAck, {\n version: Metaframe.version,\n });\n\n //Send notifications of initial inputs (if non-null)\n //so you don't have to listen to the ready event if you don't want to\n if (\n this._inputPipeValues &&\n Object.keys(this._inputPipeValues).length > 0\n ) {\n this.emit(MetaframeEvents.Inputs, this._inputPipeValues);\n Object.keys(this._inputPipeValues).forEach((pipeId) =>\n this.emit(\n MetaframeEvents.Input,\n pipeId,\n this._inputPipeValues[pipeId]\n )\n );\n }\n\n this.emit(MetaframeEvents.Inputs, this._inputPipeValues);\n\n // if this is a plugin, initialize the plugin object\n if (params.plugin) {\n this.plugin = new MetaframePlugin(this);\n }\n\n //Resolve AFTER sending inputs. This way consumers can either:\n //1) Just listen to inputs updates. The first will be when the metaframe is ready\n //2) Listen to the ready event, get the inputs if desired, and listen to subsequent\n // inputs updates. You may not wish to respond to the first updates but you might\n // want to know when the metaframe is ready\n //*** Does this distinction make sense?\n this.emit(MetaframeEvents.Connected);\n } else {\n this.log(\n \"Got JsonRpcMethods.SetupIframeServerResponse but already resolved\"\n );\n }\n }\n\n async connected(): Promise<void> {\n if (this._state === MetaframeLoadingState.Ready) {\n return;\n }\n return new Promise((resolve, _) => {\n let disposer: () => void;\n disposer = this.addListenerReturnDisposer(\n MetaframeEvents.Connected,\n () => {\n resolve();\n disposer();\n }\n );\n });\n }\n\n addListenerReturnDisposer(\n event: MetaframeEvents | JsonRpcMethodsFromChild,\n listener: ListenerFn<any[]>\n ): () => void {\n super.addListener(event, listener);\n const disposer = () => {\n super.removeListener(event, listener);\n };\n return disposer;\n }\n\n public log(o: any, color?: string, backgroundColor?: string) {\n if (!this.debug) {\n return;\n }\n this.logInternal(o, color ? color : this.color);\n }\n\n public warn(o: any) {\n if (!this.debug) {\n return;\n }\n this.logInternal(o, \"000\", this.color);\n }\n\n public error(err: any) {\n this.logInternal(err, this.color, \"f00\");\n }\n\n logInternal(o: any, color?: string, backgroundColor?: string) {\n let s: string;\n if (typeof o === \"string\") {\n s = o as string;\n } else if (typeof o === \"number\") {\n s = o + \"\";\n } else {\n s = JSON.stringify(o);\n }\n\n color = color ? color + \"\" : color;\n\n s = (this.id ? `Metaframe[${this.id}] ` : \"\") + `${s}`;\n MetapageToolsLog(s, color, backgroundColor);\n }\n\n public dispose() {\n super.removeAllListeners();\n window.removeEventListener(\"message\", this.onMessage);\n this.disableNotifyOnHashUrlChange();\n // @ts-ignore\n this._inputPipeValues = undefined;\n // @ts-ignore\n this._outputPipeValues = undefined;\n }\n\n public addListener(\n event: MetaframeEvents | JsonRpcMethodsFromChild,\n listener: ListenerFn<any[]>\n ) {\n super.addListener(event, listener);\n\n //If it is an input or output, set the current input/output values when\n //attaching a listener on the next tick to ensure that the listener\n //will always get a value if it exists\n if (event === MetaframeEvents.Inputs) {\n window.setTimeout(() => {\n if (this._inputPipeValues) {\n listener(this._inputPipeValues);\n }\n }, 0);\n }\n return this;\n }\n\n public onInput(pipeId: MetaframePipeId, listener: any): () => void {\n return this.addListenerReturnDisposer(\n MetaframeEvents.Input,\n (pipe: MetaframePipeId, value: any) => {\n if (pipeId === pipe) {\n listener(value);\n }\n }\n );\n }\n\n public onInputs(listener: (m: MetaframeInputMap) => void): () => void {\n const disposer = this.addListenerReturnDisposer(\n MetaframeEvents.Inputs,\n listener\n );\n return disposer;\n }\n\n /**\n * This is a particular use case: metapage inputs are saved outside\n * the iframe, so when this iframe is restarted in the same metapage\n * it will start with this value. So in a way, it can be used for\n * state storage, by the metaframe itself.\n */\n public setInput(pipeId: MetaframePipeId, blob: any) {\n var inputs: MetaframeInputMap = {};\n inputs[pipeId] = blob;\n this.setInputs(inputs);\n }\n\n /**\n * This does NOT directly update internal inputs. It tells\n * the metapage parent, which then updates back. So if there\n * is no metapage parent, this will do nothing.\n *\n * @param inputs\n */\n public setInputs(inputs: MetaframeInputMap) {\n this.sendRpc(JsonRpcMethodsFromChild.InputsUpdate, inputs);\n }\n\n setInternalInputsAndNotify(inputs: MetaframeInputMap) {\n if (!merge(this._inputPipeValues, inputs)) {\n return;\n }\n\n Object.keys(inputs).forEach((pipeId) =>\n this.emit(MetaframeEvents.Input, pipeId, inputs[pipeId])\n );\n this.emit(MetaframeEvents.Inputs, inputs);\n }\n\n public getInput(pipeId: MetaframePipeId): any {\n console.assert(!!pipeId);\n return this._inputPipeValues[pipeId];\n }\n\n public getInputs(): MetaframeInputMap {\n return this._inputPipeValues;\n }\n\n public getOutput(pipeId: MetaframePipeId): any {\n console.assert(!!pipeId);\n return this._outputPipeValues[pipeId];\n }\n\n /**\n * What does setting this to null mean?\n * @param pipeId :MetaframePipeId [description]\n * @param updateBlob :any [description]\n */\n public setOutput(pipeId: MetaframePipeId, updateBlob: any): void {\n console.assert(!!pipeId);\n\n var outputs: MetaframeInputMap = {};\n outputs[pipeId] = updateBlob;\n\n this.setOutputs(outputs);\n }\n\n public setOutputs(outputs: MetaframeInputMap): void {\n if (!merge(this._outputPipeValues, outputs)) {\n return;\n }\n this.sendRpc(JsonRpcMethodsFromChild.OutputsUpdate, outputs);\n }\n\n public getOutputs(): MetaframeInputMap {\n return this._outputPipeValues;\n }\n\n /**\n * If the hash params of our URL changes, e.g. from updating because\n * our state changed, then notify the parent metapage so that the\n * parent metapage can save the state\n */\n public disableNotifyOnHashUrlChange(): void {\n window.removeEventListener(\"hashchange\", this._onHashUrlChange);\n }\n\n /** Tell the parent metapage our hash params changed */\n _onHashUrlChange(_: any): void {\n const payload: MetapageEventUrlHashUpdate = {\n hash: window.location.hash,\n metaframe: this.id as MetaframeId,\n };\n this.sendRpc(JsonRpcMethodsFromChild.HashParamsUpdate, payload);\n }\n\n sendRpc(method: JsonRpcMethodsFromChild, params: any) {\n if (this._isIframe) {\n const message: MinimumClientMessage<any> = {\n jsonrpc: \"2.0\",\n id: ++this._messageSendCount, // just increment the counter for the id\n method: method,\n params: params,\n iframeId: this.id,\n parentId: this._parentId, // TODO this is likely not actually needed ? iframes cannot send to anyone but the parent? But the parent does not automatically know where a message comes from\n };\n window.parent.postMessage(message, \"*\");\n } else {\n this.log(\n \"Cannot send JSON-RPC window message: there is no window.parent which means we are not an iframe\"\n );\n }\n }\n\n onMessage(e: MessageEvent) {\n if (typeof e.data === \"object\") {\n let jsonrpc: MinimumClientMessage<any> = e.data;\n if (jsonrpc.jsonrpc === \"2.0\") {\n //Make sure this is a jsonrpc object\n var method = jsonrpc.method as JsonRpcMethodsFromParent;\n if (\n !(\n method == JsonRpcMethodsFromParent.SetupIframeServerResponse ||\n (jsonrpc.parentId == this._parentId && jsonrpc.iframeId == this.id)\n )\n ) {\n this.error(\n `window.message: received message but jsonrpc.parentId=${jsonrpc.parentId} _parentId=${this._parentId} jsonrpc.iframeId=${jsonrpc.iframeId} id=${this.id}`\n );\n return;\n }\n\n switch (method) {\n case JsonRpcMethodsFromParent.SetupIframeServerResponse:\n this._resolveSetupIframeServerResponse(jsonrpc.params);\n break; //Handled elsewhere\n case JsonRpcMethodsFromParent.InputsUpdate:\n if (this._state !== MetaframeLoadingState.Ready) {\n throw \"Got InputsUpdate but metaframe is not MetaframeLoadingState.Ready\";\n }\n this.setInternalInputsAndNotify(jsonrpc.params.inputs);\n break;\n case JsonRpcMethodsFromParent.MessageAck:\n if (this.debug) this.log(`ACK: ${JSON.stringify(jsonrpc)}`);\n break;\n default:\n if (this.debug)\n this.log(\n `window.message: unknown JSON-RPC method: ${JSON.stringify(\n jsonrpc\n )}`\n );\n break;\n }\n\n this.emit(MetaframeEvents.Message, jsonrpc);\n }\n }\n }\n}\n\n/**\n * A special kind of metaframe that can get and set the metapage definition\n * and metapage state (so quite powerful).\n */\nexport class MetaframePlugin {\n _metaframe: Metaframe;\n\n constructor(metaframe: Metaframe) {\n this._metaframe = metaframe;\n this.requestState = this.requestState.bind(this);\n this.onState = this.onState.bind(this);\n this.getState = this.getState.bind(this);\n this.setState = this.setState.bind(this);\n this.onDefinition = this.onDefinition.bind(this);\n this.getDefinition = this.getDefinition.bind(this);\n this.setDefinition = this.setDefinition.bind(this);\n }\n\n requestState() {\n var payload: ApiPayloadPluginRequest = {\n method: ApiPayloadPluginRequestMethod.State,\n };\n this._metaframe.sendRpc(JsonRpcMethodsFromChild.PluginRequest, payload);\n }\n\n onState(listener: (_: any) => void): () => void {\n const disposer = this._metaframe.onInput(METAPAGE_KEY_STATE, listener);\n if (this.getState()) {\n listener(this.getState());\n }\n return disposer;\n }\n\n getState(): any {\n return this._metaframe.getInput(METAPAGE_KEY_STATE);\n }\n\n setState(state: any) {\n this._metaframe.setOutput(METAPAGE_KEY_STATE, state);\n }\n\n onDefinition(listener: (a: any) => void): () => void {\n var disposer = this._metaframe.onInput(METAPAGE_KEY_DEFINITION, listener);\n if (this.getDefinition()) {\n listener(this.getDefinition());\n }\n return disposer;\n }\n\n setDefinition(definition: any) {\n this._metaframe.setOutput(METAPAGE_KEY_DEFINITION, definition);\n }\n\n getDefinition(): any {\n return this._metaframe.getInput(METAPAGE_KEY_DEFINITION);\n }\n}\n"]}