@bikky/compiler 0.0.43 → 0.0.44
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BiscuitLibraries.mjs","sourceRoot":"","sources":["BiscuitLibraries.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BiscuitLibraries.mjs","sourceRoot":"","sources":["BiscuitLibraries.mts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,iBAAiB,CAAC"}
|
package/Libraries/MixinCode.mjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MixableClass = exports.makeMixerFoo = void 0;
|
|
4
1
|
//Propertydescriptor is needed to preserve getters and setters, otherwise we trigger them.
|
|
5
2
|
// We assign functions directly though to preserve the prototype chain when using super() [it's not working].
|
|
6
3
|
function duplicatePrototype(prototype, parent) {
|
|
7
4
|
var names = Array.from(Object.getOwnPropertyNames(prototype));
|
|
8
|
-
names.push
|
|
5
|
+
names.push(...Object.getOwnPropertySymbols(prototype));
|
|
9
6
|
var result = { __proto__: parent };
|
|
10
|
-
for (
|
|
11
|
-
|
|
7
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
8
|
+
let name = names[i];
|
|
12
9
|
var descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
13
10
|
Object.defineProperty(result, name, descriptor);
|
|
14
11
|
}
|
|
@@ -18,25 +15,38 @@ var mixingObject = [];
|
|
|
18
15
|
var mixingBases = [];
|
|
19
16
|
var mixingBaseProtos = [];
|
|
20
17
|
//The following parameter type allows abstract classes, where as new () => Core doesn't.
|
|
21
|
-
function makeMixerFoo(mixin, common) {
|
|
22
|
-
var constraints = [];
|
|
23
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
24
|
-
constraints[_i - 2] = arguments[_i];
|
|
25
|
-
}
|
|
18
|
+
export function makeMixerFoo(mixin, common, ...constraints) {
|
|
26
19
|
if (typeof mixin !== "function" || !mixin.prototype)
|
|
27
20
|
throw new Error("Can only mix classes into other classes.");
|
|
28
21
|
//Allow static functions on the parent class to be accessible in the child.
|
|
29
|
-
|
|
22
|
+
const AllGeneratedClasses = [];
|
|
30
23
|
Object.defineProperty(mixin, Symbol.hasInstance, {
|
|
31
|
-
value:
|
|
32
|
-
return AllGeneratedClasses.some(
|
|
24
|
+
value: (other) => {
|
|
25
|
+
return AllGeneratedClasses.some((e) => other instanceof e) && other instanceof common;
|
|
33
26
|
},
|
|
34
27
|
configurable: true,
|
|
35
28
|
writable: false,
|
|
36
29
|
enumerable: false
|
|
37
30
|
});
|
|
38
31
|
return function mix(core) {
|
|
39
|
-
var newClass = eval(
|
|
32
|
+
var newClass = eval(`
|
|
33
|
+
function Mixin_${mixin.name}(...args) {
|
|
34
|
+
//This allows us to change the prototype which the constructor uses for creating
|
|
35
|
+
// the object, forcing it to use the prototype of the child class rather than
|
|
36
|
+
// the prototype of the core.
|
|
37
|
+
var object = Reflect.construct(core, args, this.__proto__.constructor);
|
|
38
|
+
mixingObject.push(object);
|
|
39
|
+
|
|
40
|
+
//Mixins extend from Mixbase, which assigns the this object to the object created
|
|
41
|
+
// by core (above).
|
|
42
|
+
new (mixin)(...args);
|
|
43
|
+
mixingObject.shift();
|
|
44
|
+
|
|
45
|
+
return object;
|
|
46
|
+
};
|
|
47
|
+
Mixin_${mixin.name}.__proto__ = core;
|
|
48
|
+
Mixin_${mixin.name}
|
|
49
|
+
`);
|
|
40
50
|
var originalPrototypes = [];
|
|
41
51
|
var current = mixin;
|
|
42
52
|
originalPrototypes.push(current.prototype);
|
|
@@ -48,21 +58,20 @@ function makeMixerFoo(mixin, common) {
|
|
|
48
58
|
var newPrototypes = [];
|
|
49
59
|
while (originalPrototypes.length > 0) {
|
|
50
60
|
current = originalPrototypes.pop();
|
|
51
|
-
|
|
61
|
+
let originalClass = current;
|
|
52
62
|
var prototype = newPrototypes.length == 0 ? core.prototype : newPrototypes[0];
|
|
53
|
-
|
|
63
|
+
let newmix = duplicatePrototype(current, prototype);
|
|
54
64
|
var edits = {
|
|
55
65
|
//We override the original isA so that this class appears to be both
|
|
56
66
|
// the mixin as well as the core types. We don't care about the prototype
|
|
57
67
|
// because mixins already in the core will have their own versions of this
|
|
58
68
|
// function.
|
|
59
|
-
isA
|
|
60
|
-
var _a;
|
|
69
|
+
isA(other) {
|
|
61
70
|
if (other == mixin || other == core) {
|
|
62
71
|
return true;
|
|
63
72
|
}
|
|
64
73
|
else {
|
|
65
|
-
return
|
|
74
|
+
return mixin.prototype.isA?.call(this, other) || core.prototype.isA.call(this, other);
|
|
66
75
|
}
|
|
67
76
|
},
|
|
68
77
|
};
|
|
@@ -87,29 +96,22 @@ function makeMixerFoo(mixin, common) {
|
|
|
87
96
|
return newClass;
|
|
88
97
|
};
|
|
89
98
|
}
|
|
90
|
-
|
|
91
|
-
function MixableClass(param) {
|
|
99
|
+
export function MixableClass(param) {
|
|
92
100
|
//This is done to preserve super calls in mixins.
|
|
93
|
-
|
|
101
|
+
class Mixbase {
|
|
94
102
|
//@ts-ignore we don't need to call super in this child class.
|
|
95
|
-
|
|
96
|
-
var args = [];
|
|
97
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
98
|
-
args[_i] = arguments[_i];
|
|
99
|
-
}
|
|
103
|
+
constructor(...args) {
|
|
100
104
|
//We can't override the class' object using .call or .apply, but we can override it in the base class.
|
|
101
105
|
var object = mixingObject[0];
|
|
102
106
|
return object;
|
|
103
107
|
}
|
|
104
|
-
|
|
105
|
-
}());
|
|
108
|
+
}
|
|
106
109
|
Mixbase.__proto__ = param;
|
|
107
110
|
Mixbase.prototype.__proto__ = param.prototype;
|
|
108
111
|
mixingBases.push(Mixbase);
|
|
109
112
|
mixingBaseProtos.push(Mixbase.prototype);
|
|
110
113
|
return Mixbase;
|
|
111
114
|
}
|
|
112
|
-
exports.MixableClass = MixableClass;
|
|
113
115
|
if (typeof global !== "undefined") {
|
|
114
116
|
global.Mixable = MixableClass;
|
|
115
117
|
global.makeMixer = makeMixerFoo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinCode.mjs","sourceRoot":"","sources":["MixinCode.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MixinCode.mjs","sourceRoot":"","sources":["MixinCode.mts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,6GAA6G;AAC7G,SAAS,kBAAkB,CAAC,SAAc,EAAE,MAAW;IACtD,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAwB,CAAC;IACrF,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,IAAI,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAE,CAAC;QACnE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,IAAI,YAAY,GAAU,EAAE,CAAC;AAQ7B,IAAI,WAAW,GAAG,EAAqB,CAAC;AACxC,IAAI,gBAAgB,GAAG,EAAW,CAAC;AAEnC,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAC1B,KAAmB,EAAE,MAAoB,EAAE,GAAG,WAAmB;IAClE,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,CAAE,KAAa,CAA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