@m2c2kit/cli 0.1.4 → 0.1.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.
- package/dist/.env +1 -1
- package/dist/cli.js +110 -18
- package/dist/fonts/roboto/LICENSE.txt +202 -202
- package/dist/templates/README.md.handlebars +17 -15
- package/dist/templates/index.html.handlebars +4 -4
- package/dist/templates/launch.json.handlebars +15 -15
- package/dist/templates/m2c2kit.json.handlebars +4 -4
- package/dist/templates/package.json.handlebars +23 -23
- package/dist/templates/rollup.config.js.handlebars +2 -2
- package/dist/templates/starter.ts.handlebars +399 -96
- package/package.json +5 -5
package/dist/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CLI_VERSION=0.1.
|
|
1
|
+
CLI_VERSION=0.1.8
|
package/dist/cli.js
CHANGED
|
@@ -63,6 +63,11 @@ await yarg
|
|
|
63
63
|
});
|
|
64
64
|
}, (argv) => {
|
|
65
65
|
const appName = argv["name"];
|
|
66
|
+
if (!isValidAppName(appName)) {
|
|
67
|
+
console.error(`${chalk.red("ERROR")}: the name ${appName} is not valid. The name must be a valid JavaScript identifer (e.g., begin with a letter, $ or _; not contain spaces; not be a reserved word, etc.).`);
|
|
68
|
+
yarg.exit(1, new Error("invalid name"));
|
|
69
|
+
}
|
|
70
|
+
const className = appName.charAt(0).toUpperCase() + appName.slice(1);
|
|
66
71
|
const newFolderPath = path.join(path.resolve(), appName);
|
|
67
72
|
if (fs.existsSync(newFolderPath)) {
|
|
68
73
|
console.error(`${chalk.red("ERROR")}: folder ${newFolderPath} already exists. Please remove this folder and try again.`);
|
|
@@ -114,6 +119,7 @@ await yarg
|
|
|
114
119
|
try {
|
|
115
120
|
const contents = applyValuesToTemplate(t.templateFilePath, {
|
|
116
121
|
appName: appName,
|
|
122
|
+
className: className,
|
|
117
123
|
cliVersion: cliVersion,
|
|
118
124
|
studyCode: generateStudyCode(),
|
|
119
125
|
});
|
|
@@ -260,25 +266,10 @@ await yarg
|
|
|
260
266
|
if (abort) {
|
|
261
267
|
yarg.exit(1, new Error("user aborted"));
|
|
262
268
|
}
|
|
263
|
-
// get study code first from command line, then from config file, then
|
|
264
|
-
|
|
269
|
+
// get study code first from command line, then from config file, then generate new one
|
|
270
|
+
const studyCode = argv["studyCode"] ??
|
|
265
271
|
serverConfig?.studyCode ??
|
|
266
|
-
|
|
267
|
-
if (studyCode === "") {
|
|
268
|
-
const response = await prompts({
|
|
269
|
-
type: "text",
|
|
270
|
-
name: "studyCode",
|
|
271
|
-
message: "study code?",
|
|
272
|
-
validate: (text) => text.length > 0
|
|
273
|
-
? true
|
|
274
|
-
: "provide a study code (5 random alphanumeric digits, e.g., R5T7A)",
|
|
275
|
-
onState: (state) => (abort = state.aborted === true),
|
|
276
|
-
});
|
|
277
|
-
studyCode = response.studyCode;
|
|
278
|
-
}
|
|
279
|
-
if (abort) {
|
|
280
|
-
yarg.exit(1, new Error("user aborted"));
|
|
281
|
-
}
|
|
272
|
+
generateStudyCode();
|
|
282
273
|
// if new url or study code was provided, save these
|
|
283
274
|
if (url !== serverConfig?.url || studyCode !== serverConfig?.studyCode) {
|
|
284
275
|
m2c2kitProjectConfig.set("server", { url, studyCode });
|
|
@@ -389,4 +380,105 @@ await yarg
|
|
|
389
380
|
})
|
|
390
381
|
.demandCommand()
|
|
391
382
|
.strict()
|
|
383
|
+
// seems to have problems getting version automatically; thus I explicity
|
|
384
|
+
// provide
|
|
385
|
+
.version(cliVersion)
|
|
392
386
|
.showHelpOnFail(true).argv;
|
|
387
|
+
function isValidAppName(name) {
|
|
388
|
+
const reserved = [
|
|
389
|
+
"abstract",
|
|
390
|
+
"arguments",
|
|
391
|
+
"await",
|
|
392
|
+
"boolean",
|
|
393
|
+
"break",
|
|
394
|
+
"byte",
|
|
395
|
+
"case",
|
|
396
|
+
"catch",
|
|
397
|
+
"char",
|
|
398
|
+
"class",
|
|
399
|
+
"const",
|
|
400
|
+
"continue",
|
|
401
|
+
"debugger",
|
|
402
|
+
"default",
|
|
403
|
+
"delete",
|
|
404
|
+
"do",
|
|
405
|
+
"double",
|
|
406
|
+
"else",
|
|
407
|
+
"enum",
|
|
408
|
+
"eval",
|
|
409
|
+
"export",
|
|
410
|
+
"extends",
|
|
411
|
+
"false",
|
|
412
|
+
"final",
|
|
413
|
+
"finally",
|
|
414
|
+
"float",
|
|
415
|
+
"for",
|
|
416
|
+
"function",
|
|
417
|
+
"goto",
|
|
418
|
+
"if",
|
|
419
|
+
"implements",
|
|
420
|
+
"import",
|
|
421
|
+
"in",
|
|
422
|
+
"instanceof",
|
|
423
|
+
"int",
|
|
424
|
+
"interface",
|
|
425
|
+
"let",
|
|
426
|
+
"long",
|
|
427
|
+
"native",
|
|
428
|
+
"new",
|
|
429
|
+
"null",
|
|
430
|
+
"package",
|
|
431
|
+
"private",
|
|
432
|
+
"protected",
|
|
433
|
+
"public",
|
|
434
|
+
"return",
|
|
435
|
+
"short",
|
|
436
|
+
"static",
|
|
437
|
+
"super",
|
|
438
|
+
"switch",
|
|
439
|
+
"synchronized",
|
|
440
|
+
"this",
|
|
441
|
+
"throw",
|
|
442
|
+
"throws",
|
|
443
|
+
"transient",
|
|
444
|
+
"true",
|
|
445
|
+
"try",
|
|
446
|
+
"typeof",
|
|
447
|
+
"var",
|
|
448
|
+
"void",
|
|
449
|
+
"volatile",
|
|
450
|
+
"while",
|
|
451
|
+
"with",
|
|
452
|
+
"yield",
|
|
453
|
+
];
|
|
454
|
+
const builtin = [
|
|
455
|
+
"Array",
|
|
456
|
+
"Date",
|
|
457
|
+
"eval",
|
|
458
|
+
"function",
|
|
459
|
+
"hasOwnProperty",
|
|
460
|
+
"Infinity",
|
|
461
|
+
"isFinite",
|
|
462
|
+
"isNaN",
|
|
463
|
+
"isPrototypeOf",
|
|
464
|
+
"length",
|
|
465
|
+
"Math",
|
|
466
|
+
"name",
|
|
467
|
+
"NaN",
|
|
468
|
+
"Number",
|
|
469
|
+
"Object",
|
|
470
|
+
"prototype",
|
|
471
|
+
"String",
|
|
472
|
+
"toString",
|
|
473
|
+
"undefined",
|
|
474
|
+
"valueOf",
|
|
475
|
+
];
|
|
476
|
+
if (reserved.includes(name) || builtin.includes(name)) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
const re = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
480
|
+
if (!re.test(name)) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright [yyyy] [name of copyright owner]
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
# {{appName}}
|
|
2
|
-
|
|
3
|
-
This project was generated with the m2c2kit CLI version {{cliVersion}}.
|
|
4
|
-
|
|
5
|
-
## Development server
|
|
6
|
-
|
|
7
|
-
Run `npm run serve` from the command line for a development server. Browse to `http://localhost:3000/`. The app will automatically compile and reload when you change source files.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# {{appName}}
|
|
2
|
+
|
|
3
|
+
This project was generated with the m2c2kit CLI version {{cliVersion}}.
|
|
4
|
+
|
|
5
|
+
## Development server
|
|
6
|
+
|
|
7
|
+
Run `npm run serve` from the command line for a development server. Browse to `http://localhost:3000/`. The app will automatically compile and reload when you change source files. If you get an error on the reload, edit `rollup.config.js` and increase the delay parameter (unit is milliseconds) in this line:
|
|
8
|
+
|
|
9
|
+
livereload({ watch: "build", delay: 0 })
|
|
10
|
+
|
|
11
|
+
## Debugging
|
|
12
|
+
|
|
13
|
+
With the file `.vscode/launch.json`, the project has been configured for debugging with Visual Studio Code and Chrome. If the development server is running, debugging in Visual Studio Code is available by pressing `F5` or selecting Run --> Start Debugging
|
|
14
|
+
|
|
15
|
+
## Build
|
|
16
|
+
|
|
17
|
+
Run `npm run build` from the command line to build the project. Build artifacts will be stored in the `dist/` directory.
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
width: 100vw;
|
|
22
22
|
">
|
|
23
23
|
<canvas style="height: 100vh; width: 100vw"></canvas>
|
|
24
|
-
|
|
25
|
-
from the code and call
|
|
24
|
+
<!-- If you don't want the game to start immediately, remove session.start()
|
|
25
|
+
from the code and call session.start() somehow else, such as with
|
|
26
26
|
the button shown below or a programmatic call -->
|
|
27
|
-
|
|
27
|
+
<!-- <button
|
|
28
28
|
style="position: absolute; bottom: 8px; left: 8px"
|
|
29
29
|
id="startButton"
|
|
30
30
|
onclick="{
|
|
31
31
|
document.getElementById('startButton').disabled = true;
|
|
32
|
-
window.
|
|
32
|
+
window.session.start();
|
|
33
33
|
}"
|
|
34
34
|
>
|
|
35
35
|
Start
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "pwa-chrome",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "Launch Chrome against localhost",
|
|
11
|
-
"url": "http://localhost:3000",
|
|
12
|
-
"webRoot": "${workspaceFolder}/build"
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "pwa-chrome",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Chrome against localhost",
|
|
11
|
+
"url": "http://localhost:3000",
|
|
12
|
+
"webRoot": "${workspaceFolder}/build"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"server": {
|
|
3
|
-
"studyCode": "{{studyCode}}"
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"server": {
|
|
3
|
+
"studyCode": "{{studyCode}}"
|
|
4
|
+
}
|
|
5
5
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{appName}}",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"serve": "rollup -c --watch --configServe",
|
|
6
|
-
"build": "rollup -c --configProd"
|
|
7
|
-
},
|
|
8
|
-
"private": true,
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@m2c2kit/core": "0.1.
|
|
11
|
-
"@m2c2kit/addons": "0.1.
|
|
12
|
-
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"rollup": "2.
|
|
15
|
-
"@rollup/plugin-typescript": "8.3.0",
|
|
16
|
-
"@rollup/plugin-node-resolve": "13.1.
|
|
17
|
-
"@rollup/plugin-commonjs": "21.0.1",
|
|
18
|
-
"rollup-plugin-shim": "1.0.0",
|
|
19
|
-
"rollup-plugin-copy": "3.4.0",
|
|
20
|
-
"rollup-plugin-delete": "2.0.0",
|
|
21
|
-
"rollup-plugin-serve": "1.1.0",
|
|
22
|
-
"rollup-plugin-livereload": "2.0.5"
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "{{appName}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"serve": "rollup -c --watch --configServe",
|
|
6
|
+
"build": "rollup -c --configProd"
|
|
7
|
+
},
|
|
8
|
+
"private": true,
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@m2c2kit/core": "0.1.6",
|
|
11
|
+
"@m2c2kit/addons": "0.1.6"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"rollup": "2.63.0",
|
|
15
|
+
"@rollup/plugin-typescript": "8.3.0",
|
|
16
|
+
"@rollup/plugin-node-resolve": "13.1.3",
|
|
17
|
+
"@rollup/plugin-commonjs": "21.0.1",
|
|
18
|
+
"rollup-plugin-shim": "1.0.0",
|
|
19
|
+
"rollup-plugin-copy": "3.4.0",
|
|
20
|
+
"rollup-plugin-delete": "2.0.0",
|
|
21
|
+
"rollup-plugin-serve": "1.1.0",
|
|
22
|
+
"rollup-plugin-livereload": "2.0.5"
|
|
23
|
+
}
|
|
24
24
|
}
|
|
@@ -38,7 +38,7 @@ export default (commandLineArgs) => {
|
|
|
38
38
|
},
|
|
39
39
|
],
|
|
40
40
|
plugins: [
|
|
41
|
-
del({ targets: [
|
|
41
|
+
commandLineArgs.configProd && del({ targets: [outputFolder] }),
|
|
42
42
|
...sharedPlugins,
|
|
43
43
|
typescript({
|
|
44
44
|
inlineSourceMap: commandLineArgs.configServe && true,
|
|
@@ -85,7 +85,7 @@ export default (commandLineArgs) => {
|
|
|
85
85
|
port: 3000,
|
|
86
86
|
}),
|
|
87
87
|
commandLineArgs.configServe &&
|
|
88
|
-
livereload(),
|
|
88
|
+
livereload({ watch: "build", delay: 0 }),
|
|
89
89
|
],
|
|
90
90
|
},
|
|
91
91
|
];
|
|
@@ -1,96 +1,399 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WebColors,
|
|
3
|
-
Action,
|
|
4
|
-
Game,
|
|
5
|
-
Scene,
|
|
6
|
-
Sprite,
|
|
7
|
-
Point,
|
|
8
|
-
Label,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
import {
|
|
2
|
+
WebColors,
|
|
3
|
+
Action,
|
|
4
|
+
Game,
|
|
5
|
+
Scene,
|
|
6
|
+
Sprite,
|
|
7
|
+
Point,
|
|
8
|
+
Label,
|
|
9
|
+
LabelHorizontalAlignmentMode,
|
|
10
|
+
Shape,
|
|
11
|
+
Rect,
|
|
12
|
+
GameOptions,
|
|
13
|
+
GameParameters,
|
|
14
|
+
TrialSchema,
|
|
15
|
+
Session,
|
|
16
|
+
GameTrialEvent,
|
|
17
|
+
GameLifecycleEvent,
|
|
18
|
+
} from "@m2c2kit/core";
|
|
19
|
+
import { Button, Instructions } from "@m2c2kit/addons";
|
|
20
|
+
|
|
21
|
+
class {{className}} extends Game {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
constructor(specifiedParameters?: any) {
|
|
24
|
+
const defaultParameters: GameParameters = {
|
|
25
|
+
ReadyTime: {
|
|
26
|
+
value: 1000,
|
|
27
|
+
description:
|
|
28
|
+
"How long the 'get ready' message scene is shown, milliseconds",
|
|
29
|
+
},
|
|
30
|
+
TrialNum: { value: 3, description: "How many trials to run" },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const demoTrialSchema: TrialSchema = {
|
|
34
|
+
colorChosen: { type: "string", description: "the color that was picked" },
|
|
35
|
+
correct: { type: "boolean", description: "was the answer correct?" },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const options: GameOptions = {
|
|
39
|
+
name: "{{appName}}",
|
|
40
|
+
version: "1.0.0",
|
|
41
|
+
uri: "https://your-repo-or-webpage-here",
|
|
42
|
+
shortDescription: "A brief couple sentence description.",
|
|
43
|
+
longDescription: "An extended, many-sentence description.",
|
|
44
|
+
showFps: true,
|
|
45
|
+
trialSchema: demoTrialSchema,
|
|
46
|
+
parameters: defaultParameters,
|
|
47
|
+
// set this color so we can see the boundaries of the game during development,
|
|
48
|
+
// but typically we would not set this
|
|
49
|
+
bodyBackgroundColor: WebColors.Wheat,
|
|
50
|
+
// note: using 2:1 aspect ratio, because that is closer to modern phones
|
|
51
|
+
width: 400,
|
|
52
|
+
height: 800,
|
|
53
|
+
// set stretch to true if you want to fill the screen on large windows
|
|
54
|
+
// (e.g., iPad, desktop browser)
|
|
55
|
+
stretch: false,
|
|
56
|
+
// Roboto is included by default. Leave fontUrls unchanged, unless you want to use different font
|
|
57
|
+
fontUrls: ["./fonts/roboto/Roboto-Regular.ttf"],
|
|
58
|
+
// for each image below, you specify either a tag of an svg in the property "svgString"
|
|
59
|
+
// or you specify a URL to an image in the property "url",
|
|
60
|
+
// such as url: 'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/android.svg'
|
|
61
|
+
images: [
|
|
62
|
+
{
|
|
63
|
+
name: "star",
|
|
64
|
+
height: 60,
|
|
65
|
+
width: 60,
|
|
66
|
+
svgString:
|
|
67
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="304" height="290"> <path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" style="fill:#00FF00;stroke:#0000FF;stroke-width:15;stroke-linejoin:round"/></svg>',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "smiley",
|
|
71
|
+
height: 64,
|
|
72
|
+
width: 64,
|
|
73
|
+
svgString:
|
|
74
|
+
'<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="451.451 -28.549 1657.098 1657.098" enable-background="new 451.451 -28.549 1657.098 1657.098" xml:space="preserve"><g><g><circle cx="992.682" cy="640.47" r="66.818"/></g><g><circle cx="1558.728" cy="640.47" r="66.818"/></g><g><path d="M1280,1600c-107.984,0-212.756-21.157-311.407-62.883c-95.268-40.295-180.819-97.973-254.279-171.432c-73.459-73.459-131.137-159.01-171.432-254.278C501.157,1012.757,480,907.984,480,800s21.157-212.756,62.883-311.407c40.295-95.268,97.973-180.819,171.432-254.279c73.46-73.459,159.011-131.137,254.279-171.432C1067.244,21.157,1172.016,0,1280,0s212.757,21.157,311.407,62.883c95.268,40.295,180.819,97.973,254.278,171.432c73.459,73.46,131.137,159.011,171.432,254.279C2058.843,587.244,2080,692.016,2080,800s-21.157,212.757-62.883,311.407c-40.295,95.268-97.973,180.819-171.432,254.278s-159.01,131.137-254.278,171.432C1492.757,1578.843,1387.984,1600,1280,1600z M1280,71.591c-401.646,0-728.409,326.763-728.409,728.409S878.354,1528.409,1280,1528.409S2008.409,1201.646,2008.409,800C2008.409,398.354,1681.646,71.591,1280,71.591z"/></g><g><path d="M1665.953,1071.004c-213.156,213.156-558.75,213.156-771.905,0c20.534-20.534,41.068-41.068,61.602-61.602c179.134,179.134,469.567,179.134,648.7,0C1624.884,1029.936,1645.418,1050.47,1665.953,1071.004z"/></g><g><path d="M1167.066,463.279c-96.31-96.31-252.459-96.31-348.768,0c16.971,16.971,33.941,33.941,50.912,50.912c68.192-68.192,178.753-68.192,246.945,0C1133.125,497.22,1150.096,480.249,1167.066,463.279z"/></g><g><path d="M1733.112,463.279c-96.31-96.31-252.459-96.31-348.768,0c16.971,16.971,33.941,33.941,50.912,50.912c68.192-68.192,178.753-68.192,246.945,0C1699.171,497.22,1716.142,480.249,1733.112,463.279z"/></g></g></svg>',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
super(options, specifiedParameters);
|
|
80
|
+
// just for convenience, alias the variable game to "this"
|
|
81
|
+
// (even though eslint doesn't like it)
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
83
|
+
const game = this;
|
|
84
|
+
|
|
85
|
+
const instructionsScenes = Instructions.Create({
|
|
86
|
+
sceneNamePrefix: "instructions",
|
|
87
|
+
backgroundColor: WebColors.White,
|
|
88
|
+
nextButtonBackgroundColor: WebColors.Black,
|
|
89
|
+
backButtonBackgroundColor: WebColors.Black,
|
|
90
|
+
instructionScenes: [
|
|
91
|
+
{
|
|
92
|
+
title: "{{appName}} Demo",
|
|
93
|
+
text: "For this task, you will click the red rectangle. Open the developer console to see the trial data and other output.",
|
|
94
|
+
textFontSize: 24,
|
|
95
|
+
titleFontSize: 30,
|
|
96
|
+
image: "smiley",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: "{{appName}} Demo",
|
|
100
|
+
text: "Press START to begin!",
|
|
101
|
+
textFontSize: 24,
|
|
102
|
+
titleFontSize: 30,
|
|
103
|
+
textAlignmentMode: LabelHorizontalAlignmentMode.center,
|
|
104
|
+
textVerticalBias: 0.25,
|
|
105
|
+
nextButtonText: "START",
|
|
106
|
+
nextButtonBackgroundColor: WebColors.Green,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
// this is the name of the scene to go to after the last instructions scene
|
|
110
|
+
postInstructionsScene: "getReady",
|
|
111
|
+
});
|
|
112
|
+
game.addScenes(instructionsScenes);
|
|
113
|
+
|
|
114
|
+
const getReadyScene = new Scene({
|
|
115
|
+
// Because this is the scene after the instructions, we must give
|
|
116
|
+
// it a name and provide it to postInstructionsScene, above
|
|
117
|
+
name: "getReady",
|
|
118
|
+
backgroundColor: WebColors.White,
|
|
119
|
+
});
|
|
120
|
+
game.addScene(getReadyScene);
|
|
121
|
+
|
|
122
|
+
const getReadyMessage = new Label({
|
|
123
|
+
text: "Get Ready",
|
|
124
|
+
fontSize: 24,
|
|
125
|
+
position: new Point(200, 400),
|
|
126
|
+
});
|
|
127
|
+
getReadyScene.addChild(getReadyMessage);
|
|
128
|
+
|
|
129
|
+
// example of how to use an image. The image must be previously loaded
|
|
130
|
+
const starSprite = new Sprite({
|
|
131
|
+
imageName: "star",
|
|
132
|
+
position: new Point(200, 500),
|
|
133
|
+
});
|
|
134
|
+
getReadyScene.addChild(starSprite);
|
|
135
|
+
|
|
136
|
+
// getReadyScene.setup() has a callback that is executed each time this scene is shown
|
|
137
|
+
getReadyScene.setup(() => {
|
|
138
|
+
getReadyScene.run(
|
|
139
|
+
Action.Sequence([
|
|
140
|
+
// Get the wait duration from the default game parameters, defined above
|
|
141
|
+
Action.Wait({ duration: game.getParameter("ReadyTime") }),
|
|
142
|
+
Action.Custom({
|
|
143
|
+
callback: () => {
|
|
144
|
+
game.presentScene(chooseRectangleScene);
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
])
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// these entities before the setup() can be defined outside of a setup()
|
|
152
|
+
// because they exist through multiple trials
|
|
153
|
+
// Their position and how they respond to interactions may differ across trials,
|
|
154
|
+
// and that logic will be written within a setup()
|
|
155
|
+
const chooseRectangleScene = new Scene({
|
|
156
|
+
backgroundColor: WebColors.LightGray,
|
|
157
|
+
});
|
|
158
|
+
game.addScene(chooseRectangleScene);
|
|
159
|
+
const redRect = new Shape({
|
|
160
|
+
rect: new Rect({ width: 150, height: 100 }),
|
|
161
|
+
fillColor: WebColors.Red,
|
|
162
|
+
});
|
|
163
|
+
chooseRectangleScene.addChild(redRect);
|
|
164
|
+
const blueRect = new Shape({
|
|
165
|
+
rect: new Rect({ width: 150, height: 100 }),
|
|
166
|
+
fillColor: WebColors.Blue,
|
|
167
|
+
});
|
|
168
|
+
chooseRectangleScene.addChild(blueRect);
|
|
169
|
+
const correctMessage = new Label({
|
|
170
|
+
text: "CORRECT!",
|
|
171
|
+
position: new Point(200, 500),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const chooseMessage = new Label({
|
|
175
|
+
text: "Choose the red rectangle",
|
|
176
|
+
position: new Point(200, 200),
|
|
177
|
+
});
|
|
178
|
+
chooseRectangleScene.addChild(chooseMessage);
|
|
179
|
+
|
|
180
|
+
correctMessage.hidden = true;
|
|
181
|
+
chooseRectangleScene.addChild(correctMessage);
|
|
182
|
+
const wrongMessage = new Label({
|
|
183
|
+
text: "WRONG!",
|
|
184
|
+
position: new Point(200, 500),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
wrongMessage.hidden = true;
|
|
188
|
+
chooseRectangleScene.addChild(wrongMessage);
|
|
189
|
+
|
|
190
|
+
// chooseRectangleScene.setup() is passed a callback that is executed each
|
|
191
|
+
// time this scene is shown. Within setup(), We will randomly decide on
|
|
192
|
+
// what side the red rectangle is shown
|
|
193
|
+
chooseRectangleScene.setup(() => {
|
|
194
|
+
let redOnLeft = true;
|
|
195
|
+
if (Math.random() > 0.5) {
|
|
196
|
+
redOnLeft = false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (redOnLeft) {
|
|
200
|
+
redRect.position = new Point(100, 300);
|
|
201
|
+
blueRect.position = new Point(300, 300);
|
|
202
|
+
} else {
|
|
203
|
+
redRect.position = new Point(300, 300);
|
|
204
|
+
blueRect.position = new Point(100, 300);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// helper function to record the user's choice and
|
|
208
|
+
// decide if we are done
|
|
209
|
+
function recordUserInput(choseRedRect: boolean) {
|
|
210
|
+
game.addTrialData("correct", choseRedRect);
|
|
211
|
+
if (choseRedRect) {
|
|
212
|
+
game.addTrialData("colorChosen", "red");
|
|
213
|
+
} else {
|
|
214
|
+
game.addTrialData("colorChosen", "blue");
|
|
215
|
+
}
|
|
216
|
+
game.trialComplete();
|
|
217
|
+
// have we finished the number of trials?
|
|
218
|
+
if (game.trialIndex < game.getParameter<number>("TrialNum")) {
|
|
219
|
+
game.presentScene(getReadyScene);
|
|
220
|
+
} else {
|
|
221
|
+
game.presentScene(endScene);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
redRect.isUserInteractionEnabled = true;
|
|
226
|
+
redRect.onTapDown(() => {
|
|
227
|
+
redRect.run(
|
|
228
|
+
Action.Sequence([
|
|
229
|
+
Action.Custom({
|
|
230
|
+
callback: () => {
|
|
231
|
+
// once a choice is made, don't allow additional taps
|
|
232
|
+
redRect.isUserInteractionEnabled = false;
|
|
233
|
+
blueRect.isUserInteractionEnabled = false;
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
// short animation to shrink and grow button
|
|
237
|
+
Action.Scale({ scale: 0.8, duration: 250 }),
|
|
238
|
+
Action.Scale({ scale: 1, duration: 250 }),
|
|
239
|
+
// Show the "CORRECT" message
|
|
240
|
+
Action.Custom({
|
|
241
|
+
callback: () => {
|
|
242
|
+
correctMessage.hidden = false;
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
Action.Wait({ duration: 1000 }),
|
|
246
|
+
// Handle the logic of recording data, and deciding if we should
|
|
247
|
+
// do another trial in recordUserInput
|
|
248
|
+
Action.Custom({
|
|
249
|
+
callback: () => {
|
|
250
|
+
correctMessage.hidden = true;
|
|
251
|
+
recordUserInput(true);
|
|
252
|
+
},
|
|
253
|
+
}),
|
|
254
|
+
])
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
blueRect.isUserInteractionEnabled = true;
|
|
259
|
+
blueRect.onTapDown(() => {
|
|
260
|
+
blueRect.run(
|
|
261
|
+
Action.Sequence([
|
|
262
|
+
Action.Custom({
|
|
263
|
+
callback: () => {
|
|
264
|
+
redRect.isUserInteractionEnabled = false;
|
|
265
|
+
blueRect.isUserInteractionEnabled = false;
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
Action.Scale({ scale: 0.8, duration: 250 }),
|
|
269
|
+
Action.Scale({ scale: 1, duration: 250 }),
|
|
270
|
+
Action.Custom({
|
|
271
|
+
callback: () => {
|
|
272
|
+
wrongMessage.hidden = false;
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
Action.Wait({ duration: 1000 }),
|
|
276
|
+
Action.Custom({
|
|
277
|
+
callback: () => {
|
|
278
|
+
wrongMessage.hidden = true;
|
|
279
|
+
recordUserInput(false);
|
|
280
|
+
},
|
|
281
|
+
}),
|
|
282
|
+
])
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const endScene = new Scene();
|
|
288
|
+
game.addScene(endScene);
|
|
289
|
+
const doneLabel = new Label({
|
|
290
|
+
text: `This will be reassigned in the setup() callback. If you see this, something went wrong!`,
|
|
291
|
+
position: new Point(200, 300),
|
|
292
|
+
});
|
|
293
|
+
endScene.addChild(doneLabel);
|
|
294
|
+
|
|
295
|
+
const startOverButton = new Button({
|
|
296
|
+
text: "Start over",
|
|
297
|
+
position: new Point(200, 600),
|
|
298
|
+
});
|
|
299
|
+
startOverButton.isUserInteractionEnabled = true;
|
|
300
|
+
startOverButton.onTapDown(() => {
|
|
301
|
+
// in the setup() for the end scene, we animate the smiley sprite with
|
|
302
|
+
// a move action. if the user taps the start over button before the
|
|
303
|
+
// animation is completed, we should remove it by calling
|
|
304
|
+
// removeAllActions()
|
|
305
|
+
smileySprite.removeAllActions();
|
|
306
|
+
game.initData();
|
|
307
|
+
game.presentScene(getReadyScene);
|
|
308
|
+
});
|
|
309
|
+
endScene.addChild(startOverButton);
|
|
310
|
+
|
|
311
|
+
const exitButton = new Button({
|
|
312
|
+
text: "Exit",
|
|
313
|
+
position: new Point(200, 675),
|
|
314
|
+
});
|
|
315
|
+
exitButton.isUserInteractionEnabled = true;
|
|
316
|
+
exitButton.onTapDown(() => {
|
|
317
|
+
// hide the start over button
|
|
318
|
+
startOverButton.hidden = true;
|
|
319
|
+
// don't allow repeated taps on exit button
|
|
320
|
+
exitButton.isUserInteractionEnabled = false;
|
|
321
|
+
game.end();
|
|
322
|
+
});
|
|
323
|
+
endScene.addChild(exitButton);
|
|
324
|
+
|
|
325
|
+
const smileySprite = new Sprite({ imageName: "smiley" });
|
|
326
|
+
endScene.addChild(smileySprite);
|
|
327
|
+
|
|
328
|
+
endScene.setup(() => {
|
|
329
|
+
doneLabel.text = `You did ${game.trialIndex} trials. You're done!`;
|
|
330
|
+
|
|
331
|
+
// example of how to position a sprite and create an action to move it
|
|
332
|
+
smileySprite.position = new Point(200, 500);
|
|
333
|
+
smileySprite.run(
|
|
334
|
+
Action.Move({ point: new Point(200, 100), duration: 3000 })
|
|
335
|
+
);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
game.entryScene = "instructions-01";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// ============================================================================
|
|
343
|
+
|
|
344
|
+
// When running within an Android webview, the below defines how the session
|
|
345
|
+
// can communicate events to the Android app. Note: the names of this Android
|
|
346
|
+
// namespace and its functions must match the corresponding Android code
|
|
347
|
+
// in addJavascriptInterface() and @JavascriptInterface
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
349
|
+
declare namespace Android {
|
|
350
|
+
function onGameTrialComplete(gameTrialEventAsString: string): void;
|
|
351
|
+
function onGameLifecycleChange(gameLifecycleEventAsString: string): void;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// default was 3 trials; this is how we can specify a different value
|
|
355
|
+
const game1 = new {{className}}({ TrialNum: 2 });
|
|
356
|
+
|
|
357
|
+
const session = new Session({
|
|
358
|
+
activities: [game1],
|
|
359
|
+
gameCallbacks: {
|
|
360
|
+
// onGameTrialComplete() is where you insert code to post data to an API
|
|
361
|
+
// or interop with a native function in the host app, if applicable
|
|
362
|
+
onGameTrialComplete: (e: GameTrialEvent) => {
|
|
363
|
+
console.log(`********** trial ${e.trialIndex} complete`);
|
|
364
|
+
console.log("data: " + JSON.stringify(e.gameData));
|
|
365
|
+
console.log("trial schema: " + JSON.stringify(e.trialSchema));
|
|
366
|
+
console.log("game parameters: " + JSON.stringify(e.gameParameters));
|
|
367
|
+
|
|
368
|
+
// callback to native Android app, if running in that context
|
|
369
|
+
if (typeof Android !== "undefined") {
|
|
370
|
+
Android.onGameTrialComplete(JSON.stringify(e));
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
// onGameLifecycleChange() is called when the game lifecycles changes
|
|
374
|
+
onGameLifecycleChange: (e: GameLifecycleEvent) => {
|
|
375
|
+
if (e.ended) {
|
|
376
|
+
console.log(`user requested exit in game ${e.gameName}`);
|
|
377
|
+
// this session has only one activity, but this is how it would go to
|
|
378
|
+
// the next activity
|
|
379
|
+
if (session.nextActivity) {
|
|
380
|
+
session.advanceToNextActivity();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// callback to native Android app, if running in that context
|
|
384
|
+
if (typeof Android !== "undefined") {
|
|
385
|
+
Android.onGameLifecycleChange(JSON.stringify(e));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// make session also available on window in case we want to control
|
|
393
|
+
// the session through another means
|
|
394
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
395
|
+
(window as unknown as any).session = session;
|
|
396
|
+
|
|
397
|
+
session.init().then(() => {
|
|
398
|
+
session.start();
|
|
399
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "m2c2kit command line interface",
|
|
5
5
|
"module": "dist/cli.js",
|
|
6
6
|
"files": [
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"handlebars": "4.7.7",
|
|
31
31
|
"ora": "6.0.1",
|
|
32
32
|
"prompts": "2.4.2",
|
|
33
|
-
"yargs": "17.3.
|
|
33
|
+
"yargs": "17.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "
|
|
36
|
+
"@types/node": "17.0.8",
|
|
37
37
|
"@types/prompts": "2.0.14",
|
|
38
|
-
"@types/yargs": "17.0.
|
|
38
|
+
"@types/yargs": "17.0.8",
|
|
39
39
|
"copyfiles": "2.4.1",
|
|
40
40
|
"rimraf": "3.0.2",
|
|
41
41
|
"tslib": "2.3.1",
|
|
42
|
-
"typescript": "4.5.
|
|
42
|
+
"typescript": "4.5.4"
|
|
43
43
|
}
|
|
44
44
|
}
|