@m2c2kit/core 0.3.30 → 0.3.31
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/index.d.ts +16 -0
- package/dist/index.js +50 -10
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -4
- package/package.json +6 -7
package/dist/index.d.ts
CHANGED
|
@@ -1605,6 +1605,22 @@ declare class Game implements Activity {
|
|
|
1605
1605
|
*/
|
|
1606
1606
|
constructor(options: GameOptions);
|
|
1607
1607
|
private createFreeNodesScene;
|
|
1608
|
+
/**
|
|
1609
|
+
* Returns the base URL of an imported module.
|
|
1610
|
+
*
|
|
1611
|
+
* @remarks Previously, a regex was used:
|
|
1612
|
+
* `const regex = new RegExp(`^.*${packageName}[^\\/]*`);`
|
|
1613
|
+
* but this triggered irrelevant warnings for ReDoS in some overly
|
|
1614
|
+
* sensitive package scanners, so now we use URL and pathname parsing.
|
|
1615
|
+
* Also: trailing slashes are removed from the returned base URL.
|
|
1616
|
+
*
|
|
1617
|
+
* @param packageName - the name of the imported package module, like
|
|
1618
|
+
* `@m2c2kit/assessment-symbol-search`
|
|
1619
|
+
* @param moduleUrl - the full URL of the module's entrypoint, possibly
|
|
1620
|
+
* including a version suffix, like `https://cdn.com/@m2c2kit/assessment-symbol-search@0.8.13/dist/index.js`
|
|
1621
|
+
* @returns - the base URL of the imported module, without the entrypoint,
|
|
1622
|
+
* like `https://cdn.com/@m2c2kit/assessment-symbol-search@0.8.13`
|
|
1623
|
+
*/
|
|
1608
1624
|
private getImportedModuleBaseUrl;
|
|
1609
1625
|
private addLocalizationParametersToGameParameters;
|
|
1610
1626
|
init(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -7670,7 +7670,11 @@ function getAugmentedNamespace(n) {
|
|
|
7670
7670
|
var f = n.default;
|
|
7671
7671
|
if (typeof f == "function") {
|
|
7672
7672
|
var a = function a () {
|
|
7673
|
-
|
|
7673
|
+
var isInstance = false;
|
|
7674
|
+
try {
|
|
7675
|
+
isInstance = this instanceof a;
|
|
7676
|
+
} catch {}
|
|
7677
|
+
if (isInstance) {
|
|
7674
7678
|
return Reflect.construct(f, arguments, this.constructor);
|
|
7675
7679
|
}
|
|
7676
7680
|
return f.apply(this, arguments);
|
|
@@ -9150,15 +9154,51 @@ class Game {
|
|
|
9150
9154
|
};
|
|
9151
9155
|
this.eventStore.addEvent(freeNodesSceneNewEvent);
|
|
9152
9156
|
}
|
|
9157
|
+
/**
|
|
9158
|
+
* Returns the base URL of an imported module.
|
|
9159
|
+
*
|
|
9160
|
+
* @remarks Previously, a regex was used:
|
|
9161
|
+
* `const regex = new RegExp(`^.*${packageName}[^\\/]*`);`
|
|
9162
|
+
* but this triggered irrelevant warnings for ReDoS in some overly
|
|
9163
|
+
* sensitive package scanners, so now we use URL and pathname parsing.
|
|
9164
|
+
* Also: trailing slashes are removed from the returned base URL.
|
|
9165
|
+
*
|
|
9166
|
+
* @param packageName - the name of the imported package module, like
|
|
9167
|
+
* `@m2c2kit/assessment-symbol-search`
|
|
9168
|
+
* @param moduleUrl - the full URL of the module's entrypoint, possibly
|
|
9169
|
+
* including a version suffix, like `https://cdn.com/@m2c2kit/assessment-symbol-search@0.8.13/dist/index.js`
|
|
9170
|
+
* @returns - the base URL of the imported module, without the entrypoint,
|
|
9171
|
+
* like `https://cdn.com/@m2c2kit/assessment-symbol-search@0.8.13`
|
|
9172
|
+
*/
|
|
9153
9173
|
getImportedModuleBaseUrl(packageName, moduleUrl) {
|
|
9154
|
-
const
|
|
9155
|
-
const
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9174
|
+
const url = new URL(moduleUrl);
|
|
9175
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
9176
|
+
let lastMatchIndex = -1;
|
|
9177
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
9178
|
+
if (packageName.startsWith("@")) {
|
|
9179
|
+
const nameParts = packageName.split("/");
|
|
9180
|
+
if (nameParts.length === 2) {
|
|
9181
|
+
const scopePart = nameParts[0];
|
|
9182
|
+
const namePart = nameParts[1];
|
|
9183
|
+
for (let i2 = 0; i2 < segments.length - 1; i2++) {
|
|
9184
|
+
if (segments[i2] === scopePart && (segments[i2 + 1] === namePart || segments[i2 + 1].startsWith(`${namePart}@`))) {
|
|
9185
|
+
lastMatchIndex = i2 + 1;
|
|
9186
|
+
}
|
|
9187
|
+
}
|
|
9188
|
+
}
|
|
9189
|
+
} else {
|
|
9190
|
+
if (segments[i] === packageName || segments[i].startsWith(`${packageName}@`)) {
|
|
9191
|
+
lastMatchIndex = i;
|
|
9192
|
+
}
|
|
9193
|
+
}
|
|
9194
|
+
}
|
|
9195
|
+
if (lastMatchIndex === -1) {
|
|
9196
|
+
throw new Error(
|
|
9197
|
+
`Could not locate base URL for package "${packageName}" in "${moduleUrl}"`
|
|
9159
9198
|
);
|
|
9160
9199
|
}
|
|
9161
|
-
|
|
9200
|
+
const basePath = segments.slice(0, lastMatchIndex + 1).join("/");
|
|
9201
|
+
return `${url.origin}/${basePath}`.replace(/\/*$/, "");
|
|
9162
9202
|
}
|
|
9163
9203
|
addLocalizationParametersToGameParameters() {
|
|
9164
9204
|
this.options.parameters = {
|
|
@@ -11289,11 +11329,11 @@ class Game {
|
|
|
11289
11329
|
if (!this.surface) {
|
|
11290
11330
|
throw new M2Error("no canvaskit surface. unable to take screenshot.");
|
|
11291
11331
|
}
|
|
11292
|
-
const missingParametersCount = [sx, sy, sw, sh].map((x) => x
|
|
11332
|
+
const missingParametersCount = [sx, sy, sw, sh].map((x) => x === void 0 ? 1 : 0).reduce((a, b) => a + b);
|
|
11293
11333
|
return new Promise((resolve, reject) => {
|
|
11294
11334
|
switch (missingParametersCount) {
|
|
11295
11335
|
case 0: {
|
|
11296
|
-
if (
|
|
11336
|
+
if (sx === void 0 || sy === void 0 || sw === void 0 || sh === void 0) {
|
|
11297
11337
|
reject("missing values in arguments for takeScreenshot()");
|
|
11298
11338
|
return;
|
|
11299
11339
|
}
|
|
@@ -12934,7 +12974,7 @@ class Story {
|
|
|
12934
12974
|
}
|
|
12935
12975
|
}
|
|
12936
12976
|
|
|
12937
|
-
console.log("\u26AA @m2c2kit/core version 0.3.
|
|
12977
|
+
console.log("\u26AA @m2c2kit/core version 0.3.31 (62ccf312)");
|
|
12938
12978
|
|
|
12939
12979
|
export { Action, ActivityType, CanvasKitHelpers, ColorfulMutablePath, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, FontManager, Game, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LegacyTimer, M2Error, M2EventType, M2ImageStatus, M2Node, M2NodeFactory, M2NodeType, M2SoundStatus, M2c2KitHelpers, MoveAction, MutablePath, NoneTransition, PlayAction, RandomDraws, RepeatAction, RepeatForeverAction, RotateAction, ScaleAction, Scene, SceneTransition, SequenceAction, Shape, ShapeType, SlideTransition, SoundManager, SoundPlayer, SoundRecorder, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
|
|
12940
12980
|
//# sourceMappingURL=index.js.map
|