@easy-editor/core 1.0.0 → 1.0.1
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.cjs +211 -15
- package/dist/index.js +200 -16
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/plugin-extend-mobx.d.ts +44 -0
- package/dist/plugin/plugin-extend.d.ts +3 -2
- package/dist/types/schema.d.ts +28 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11210,6 +11210,204 @@ class PluginContext {
|
|
|
11210
11210
|
}
|
|
11211
11211
|
}
|
|
11212
11212
|
|
|
11213
|
+
let MobxExtendType = /*#__PURE__*/function (MobxExtendType) {
|
|
11214
|
+
MobxExtendType["OBSERVABLE"] = "observable";
|
|
11215
|
+
MobxExtendType["OBSERVABLE_REF"] = "observable.ref";
|
|
11216
|
+
MobxExtendType["OBSERVABLE_SHALLOW"] = "observable.shallow";
|
|
11217
|
+
MobxExtendType["COMPUTED"] = "computed";
|
|
11218
|
+
MobxExtendType["ACTION"] = "action";
|
|
11219
|
+
return MobxExtendType;
|
|
11220
|
+
}({});
|
|
11221
|
+
const MOBX_EXTEND_SYMBOL = Symbol('mobx-extend');
|
|
11222
|
+
const isMobxExtendProperty = value => {
|
|
11223
|
+
return value && typeof value === 'object' && value[MOBX_EXTEND_SYMBOL] === true;
|
|
11224
|
+
};
|
|
11225
|
+
const createMobxDescriptor = config => ({
|
|
11226
|
+
[MOBX_EXTEND_SYMBOL]: true,
|
|
11227
|
+
config
|
|
11228
|
+
});
|
|
11229
|
+
const observableProperty = initialValue => {
|
|
11230
|
+
return createMobxDescriptor({
|
|
11231
|
+
type: MobxExtendType.OBSERVABLE,
|
|
11232
|
+
initialValue
|
|
11233
|
+
});
|
|
11234
|
+
};
|
|
11235
|
+
const observableRef = initialValue => {
|
|
11236
|
+
return createMobxDescriptor({
|
|
11237
|
+
type: MobxExtendType.OBSERVABLE_REF,
|
|
11238
|
+
initialValue
|
|
11239
|
+
});
|
|
11240
|
+
};
|
|
11241
|
+
const observableShallow = initialValue => {
|
|
11242
|
+
return createMobxDescriptor({
|
|
11243
|
+
type: MobxExtendType.OBSERVABLE_SHALLOW,
|
|
11244
|
+
initialValue
|
|
11245
|
+
});
|
|
11246
|
+
};
|
|
11247
|
+
const computedProperty = config => {
|
|
11248
|
+
return createMobxDescriptor({
|
|
11249
|
+
type: MobxExtendType.COMPUTED,
|
|
11250
|
+
...config
|
|
11251
|
+
});
|
|
11252
|
+
};
|
|
11253
|
+
const computedGetter = getter => {
|
|
11254
|
+
return computedProperty({
|
|
11255
|
+
getter
|
|
11256
|
+
});
|
|
11257
|
+
};
|
|
11258
|
+
const computedGetterSetter = (getter, setter) => {
|
|
11259
|
+
return computedProperty({
|
|
11260
|
+
getter,
|
|
11261
|
+
setter
|
|
11262
|
+
});
|
|
11263
|
+
};
|
|
11264
|
+
const actionMethod = (method, name) => {
|
|
11265
|
+
return createMobxDescriptor({
|
|
11266
|
+
type: MobxExtendType.ACTION,
|
|
11267
|
+
method,
|
|
11268
|
+
name
|
|
11269
|
+
});
|
|
11270
|
+
};
|
|
11271
|
+
const handleObservableProperty = (prototype, propertyName, config) => {
|
|
11272
|
+
const {
|
|
11273
|
+
type,
|
|
11274
|
+
initialValue,
|
|
11275
|
+
getter,
|
|
11276
|
+
setter
|
|
11277
|
+
} = config;
|
|
11278
|
+
let observableDecorator;
|
|
11279
|
+
switch (type) {
|
|
11280
|
+
case MobxExtendType.OBSERVABLE_REF:
|
|
11281
|
+
observableDecorator = observable.ref;
|
|
11282
|
+
break;
|
|
11283
|
+
case MobxExtendType.OBSERVABLE_SHALLOW:
|
|
11284
|
+
observableDecorator = observable.shallow;
|
|
11285
|
+
break;
|
|
11286
|
+
default:
|
|
11287
|
+
observableDecorator = observable;
|
|
11288
|
+
}
|
|
11289
|
+
if (getter || setter) {
|
|
11290
|
+
const privatePropertyName = `_${propertyName}`;
|
|
11291
|
+
const descriptor = {
|
|
11292
|
+
get: getter || function () {
|
|
11293
|
+
if (!(privatePropertyName in this)) {
|
|
11294
|
+
this[privatePropertyName] = initialValue;
|
|
11295
|
+
observableDecorator(this, privatePropertyName);
|
|
11296
|
+
}
|
|
11297
|
+
return this[privatePropertyName];
|
|
11298
|
+
},
|
|
11299
|
+
enumerable: true,
|
|
11300
|
+
configurable: true
|
|
11301
|
+
};
|
|
11302
|
+
if (setter) {
|
|
11303
|
+
descriptor.set = setter;
|
|
11304
|
+
} else {
|
|
11305
|
+
descriptor.set = function (value) {
|
|
11306
|
+
if (!(privatePropertyName in this)) {
|
|
11307
|
+
observableDecorator(this, privatePropertyName);
|
|
11308
|
+
}
|
|
11309
|
+
this[privatePropertyName] = value;
|
|
11310
|
+
};
|
|
11311
|
+
}
|
|
11312
|
+
Object.defineProperty(prototype, propertyName, descriptor);
|
|
11313
|
+
} else {
|
|
11314
|
+
const privatePropertyName = `__${propertyName}`;
|
|
11315
|
+
Object.defineProperty(prototype, propertyName, {
|
|
11316
|
+
get: function () {
|
|
11317
|
+
if (!(privatePropertyName in this)) {
|
|
11318
|
+
this[privatePropertyName] = initialValue;
|
|
11319
|
+
observableDecorator(this, privatePropertyName);
|
|
11320
|
+
}
|
|
11321
|
+
return this[privatePropertyName];
|
|
11322
|
+
},
|
|
11323
|
+
set: function (value) {
|
|
11324
|
+
if (!(privatePropertyName in this)) {
|
|
11325
|
+
observableDecorator(this, privatePropertyName);
|
|
11326
|
+
}
|
|
11327
|
+
this[privatePropertyName] = value;
|
|
11328
|
+
},
|
|
11329
|
+
enumerable: true,
|
|
11330
|
+
configurable: true
|
|
11331
|
+
});
|
|
11332
|
+
}
|
|
11333
|
+
};
|
|
11334
|
+
const handleComputedProperty = (prototype, propertyName, config) => {
|
|
11335
|
+
const {
|
|
11336
|
+
getter,
|
|
11337
|
+
setter
|
|
11338
|
+
} = config;
|
|
11339
|
+
const descriptor = {
|
|
11340
|
+
get() {
|
|
11341
|
+
return computed(() => getter.call(this)).get();
|
|
11342
|
+
},
|
|
11343
|
+
enumerable: true,
|
|
11344
|
+
configurable: true
|
|
11345
|
+
};
|
|
11346
|
+
if (setter) {
|
|
11347
|
+
descriptor.set = function (value) {
|
|
11348
|
+
setter.call(this, value);
|
|
11349
|
+
};
|
|
11350
|
+
}
|
|
11351
|
+
Object.defineProperty(prototype, propertyName, descriptor);
|
|
11352
|
+
};
|
|
11353
|
+
const handleActionMethod = (prototype, propertyName, config) => {
|
|
11354
|
+
const {
|
|
11355
|
+
method,
|
|
11356
|
+
name
|
|
11357
|
+
} = config;
|
|
11358
|
+
const actionName = name || propertyName;
|
|
11359
|
+
Object.defineProperty(prototype, propertyName, {
|
|
11360
|
+
value: action(actionName, method),
|
|
11361
|
+
writable: true,
|
|
11362
|
+
enumerable: true,
|
|
11363
|
+
configurable: true
|
|
11364
|
+
});
|
|
11365
|
+
};
|
|
11366
|
+
const addMobxExtendProperty = (prototype, propertyName, config) => {
|
|
11367
|
+
switch (config.type) {
|
|
11368
|
+
case MobxExtendType.OBSERVABLE:
|
|
11369
|
+
case MobxExtendType.OBSERVABLE_REF:
|
|
11370
|
+
case MobxExtendType.OBSERVABLE_SHALLOW:
|
|
11371
|
+
handleObservableProperty(prototype, propertyName, config);
|
|
11372
|
+
break;
|
|
11373
|
+
case MobxExtendType.COMPUTED:
|
|
11374
|
+
handleComputedProperty(prototype, propertyName, config);
|
|
11375
|
+
break;
|
|
11376
|
+
case MobxExtendType.ACTION:
|
|
11377
|
+
handleActionMethod(prototype, propertyName, config);
|
|
11378
|
+
break;
|
|
11379
|
+
default:
|
|
11380
|
+
console.warn(`Unknown Mobx extend type: ${config.type}`);
|
|
11381
|
+
}
|
|
11382
|
+
};
|
|
11383
|
+
const mobxExtendObservable = observableProperty;
|
|
11384
|
+
const mobxExtendObservableRef = observableRef;
|
|
11385
|
+
const mobxExtendObservableShallow = observableShallow;
|
|
11386
|
+
const mobxExtendComputed = computedProperty;
|
|
11387
|
+
const mobxExtendComputedGetter = computedGetter;
|
|
11388
|
+
const mobxExtendComputedGetterSetter = computedGetterSetter;
|
|
11389
|
+
const mobxExtendAction = actionMethod;
|
|
11390
|
+
|
|
11391
|
+
const extend = (extendMap, extendClass, properties) => {
|
|
11392
|
+
const newProperties = {};
|
|
11393
|
+
const prototype = extendMap[extendClass].prototype;
|
|
11394
|
+
for (const key in properties) {
|
|
11395
|
+
const property = properties[key];
|
|
11396
|
+
if (isMobxExtendProperty(property)) {
|
|
11397
|
+
addMobxExtendProperty(prototype, key, property.config);
|
|
11398
|
+
continue;
|
|
11399
|
+
}
|
|
11400
|
+
if (typeof property === 'function') {
|
|
11401
|
+
newProperties[key] = {
|
|
11402
|
+
value: property
|
|
11403
|
+
};
|
|
11404
|
+
} else {
|
|
11405
|
+
newProperties[key] = property;
|
|
11406
|
+
}
|
|
11407
|
+
}
|
|
11408
|
+
Object.defineProperties(prototype, newProperties);
|
|
11409
|
+
};
|
|
11410
|
+
|
|
11213
11411
|
class PluginRuntime {
|
|
11214
11412
|
get ctx() {
|
|
11215
11413
|
return this.manager.getPluginContext({
|
|
@@ -11285,20 +11483,6 @@ class PluginRuntime {
|
|
|
11285
11483
|
}
|
|
11286
11484
|
}
|
|
11287
11485
|
|
|
11288
|
-
const extend = (extendMap, extendClass, properties) => {
|
|
11289
|
-
const newProperties = {};
|
|
11290
|
-
for (const key in properties) {
|
|
11291
|
-
if (typeof properties[key] === 'function') {
|
|
11292
|
-
newProperties[key] = {
|
|
11293
|
-
value: properties[key]
|
|
11294
|
-
};
|
|
11295
|
-
} else {
|
|
11296
|
-
newProperties[key] = properties[key];
|
|
11297
|
-
}
|
|
11298
|
-
}
|
|
11299
|
-
Object.defineProperties(extendMap[extendClass].prototype, newProperties);
|
|
11300
|
-
};
|
|
11301
|
-
|
|
11302
11486
|
const sequence = ({
|
|
11303
11487
|
tasks,
|
|
11304
11488
|
names,
|
|
@@ -11884,7 +12068,7 @@ const destroy = async () => {
|
|
|
11884
12068
|
logger.info('Engine destruction successfully');
|
|
11885
12069
|
};
|
|
11886
12070
|
|
|
11887
|
-
const version = '1.0.
|
|
12071
|
+
const version = '1.0.1';
|
|
11888
12072
|
config.set('VERSION', version);
|
|
11889
12073
|
console.log(`%c EasyEditor %c v${version} `, 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #5584ff; font-weight: bold;', 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;');
|
|
11890
12074
|
|
|
@@ -11912,7 +12096,9 @@ exports.History = History;
|
|
|
11912
12096
|
exports.Hotkey = Hotkey;
|
|
11913
12097
|
exports.LocationDetailType = LocationDetailType;
|
|
11914
12098
|
exports.Logger = Logger;
|
|
12099
|
+
exports.MOBX_EXTEND_SYMBOL = MOBX_EXTEND_SYMBOL;
|
|
11915
12100
|
exports.Materials = Materials;
|
|
12101
|
+
exports.MobxExtendType = MobxExtendType;
|
|
11916
12102
|
exports.NODE_CHILDREN_EVENT = NODE_CHILDREN_EVENT;
|
|
11917
12103
|
exports.NODE_EVENT = NODE_EVENT;
|
|
11918
12104
|
exports.Node = Node$1;
|
|
@@ -11939,6 +12125,7 @@ exports.Simulator = Simulator;
|
|
|
11939
12125
|
exports.TRANSFORM_STAGE = TRANSFORM_STAGE;
|
|
11940
12126
|
exports.UNSET = UNSET;
|
|
11941
12127
|
exports.Viewport = Viewport;
|
|
12128
|
+
exports.addMobxExtendProperty = addMobxExtendProperty;
|
|
11942
12129
|
exports.clipboard = clipboard;
|
|
11943
12130
|
exports.cloneDeep = cloneDeep;
|
|
11944
12131
|
exports.commonEvent = commonEvent;
|
|
@@ -11951,6 +12138,7 @@ exports.createOffsetObserver = createOffsetObserver;
|
|
|
11951
12138
|
exports.destroy = destroy;
|
|
11952
12139
|
exports.ensureNode = ensureNode;
|
|
11953
12140
|
exports.event = event;
|
|
12141
|
+
exports.extend = extend;
|
|
11954
12142
|
exports.generateSessionId = generateSessionId;
|
|
11955
12143
|
exports.getClosestClickableNode = getClosestClickableNode;
|
|
11956
12144
|
exports.getClosestNode = getClosestNode;
|
|
@@ -11982,6 +12170,7 @@ exports.isLocateEvent = isLocateEvent;
|
|
|
11982
12170
|
exports.isLocationChildrenDetail = isLocationChildrenDetail;
|
|
11983
12171
|
exports.isLocationData = isLocationData;
|
|
11984
12172
|
exports.isLowCodeComponentType = isLowCodeComponentType;
|
|
12173
|
+
exports.isMobxExtendProperty = isMobxExtendProperty;
|
|
11985
12174
|
exports.isNode = isNode;
|
|
11986
12175
|
exports.isNodeSchema = isNodeSchema;
|
|
11987
12176
|
exports.isObject = isObject$1;
|
|
@@ -12002,6 +12191,13 @@ exports.isValidArrayIndex = isValidArrayIndex;
|
|
|
12002
12191
|
exports.logger = logger;
|
|
12003
12192
|
exports.makeEventsHandler = makeEventsHandler;
|
|
12004
12193
|
exports.materials = materials;
|
|
12194
|
+
exports.mobxExtendAction = mobxExtendAction;
|
|
12195
|
+
exports.mobxExtendComputed = mobxExtendComputed;
|
|
12196
|
+
exports.mobxExtendComputedGetter = mobxExtendComputedGetter;
|
|
12197
|
+
exports.mobxExtendComputedGetterSetter = mobxExtendComputedGetterSetter;
|
|
12198
|
+
exports.mobxExtendObservable = mobxExtendObservable;
|
|
12199
|
+
exports.mobxExtendObservableRef = mobxExtendObservableRef;
|
|
12200
|
+
exports.mobxExtendObservableShallow = mobxExtendObservableShallow;
|
|
12005
12201
|
exports.project = project;
|
|
12006
12202
|
exports.setShaken = setShaken;
|
|
12007
12203
|
exports.setters = setters;
|
package/dist/index.js
CHANGED
|
@@ -11208,6 +11208,204 @@ class PluginContext {
|
|
|
11208
11208
|
}
|
|
11209
11209
|
}
|
|
11210
11210
|
|
|
11211
|
+
let MobxExtendType = /*#__PURE__*/function (MobxExtendType) {
|
|
11212
|
+
MobxExtendType["OBSERVABLE"] = "observable";
|
|
11213
|
+
MobxExtendType["OBSERVABLE_REF"] = "observable.ref";
|
|
11214
|
+
MobxExtendType["OBSERVABLE_SHALLOW"] = "observable.shallow";
|
|
11215
|
+
MobxExtendType["COMPUTED"] = "computed";
|
|
11216
|
+
MobxExtendType["ACTION"] = "action";
|
|
11217
|
+
return MobxExtendType;
|
|
11218
|
+
}({});
|
|
11219
|
+
const MOBX_EXTEND_SYMBOL = Symbol('mobx-extend');
|
|
11220
|
+
const isMobxExtendProperty = value => {
|
|
11221
|
+
return value && typeof value === 'object' && value[MOBX_EXTEND_SYMBOL] === true;
|
|
11222
|
+
};
|
|
11223
|
+
const createMobxDescriptor = config => ({
|
|
11224
|
+
[MOBX_EXTEND_SYMBOL]: true,
|
|
11225
|
+
config
|
|
11226
|
+
});
|
|
11227
|
+
const observableProperty = initialValue => {
|
|
11228
|
+
return createMobxDescriptor({
|
|
11229
|
+
type: MobxExtendType.OBSERVABLE,
|
|
11230
|
+
initialValue
|
|
11231
|
+
});
|
|
11232
|
+
};
|
|
11233
|
+
const observableRef = initialValue => {
|
|
11234
|
+
return createMobxDescriptor({
|
|
11235
|
+
type: MobxExtendType.OBSERVABLE_REF,
|
|
11236
|
+
initialValue
|
|
11237
|
+
});
|
|
11238
|
+
};
|
|
11239
|
+
const observableShallow = initialValue => {
|
|
11240
|
+
return createMobxDescriptor({
|
|
11241
|
+
type: MobxExtendType.OBSERVABLE_SHALLOW,
|
|
11242
|
+
initialValue
|
|
11243
|
+
});
|
|
11244
|
+
};
|
|
11245
|
+
const computedProperty = config => {
|
|
11246
|
+
return createMobxDescriptor({
|
|
11247
|
+
type: MobxExtendType.COMPUTED,
|
|
11248
|
+
...config
|
|
11249
|
+
});
|
|
11250
|
+
};
|
|
11251
|
+
const computedGetter = getter => {
|
|
11252
|
+
return computedProperty({
|
|
11253
|
+
getter
|
|
11254
|
+
});
|
|
11255
|
+
};
|
|
11256
|
+
const computedGetterSetter = (getter, setter) => {
|
|
11257
|
+
return computedProperty({
|
|
11258
|
+
getter,
|
|
11259
|
+
setter
|
|
11260
|
+
});
|
|
11261
|
+
};
|
|
11262
|
+
const actionMethod = (method, name) => {
|
|
11263
|
+
return createMobxDescriptor({
|
|
11264
|
+
type: MobxExtendType.ACTION,
|
|
11265
|
+
method,
|
|
11266
|
+
name
|
|
11267
|
+
});
|
|
11268
|
+
};
|
|
11269
|
+
const handleObservableProperty = (prototype, propertyName, config) => {
|
|
11270
|
+
const {
|
|
11271
|
+
type,
|
|
11272
|
+
initialValue,
|
|
11273
|
+
getter,
|
|
11274
|
+
setter
|
|
11275
|
+
} = config;
|
|
11276
|
+
let observableDecorator;
|
|
11277
|
+
switch (type) {
|
|
11278
|
+
case MobxExtendType.OBSERVABLE_REF:
|
|
11279
|
+
observableDecorator = observable.ref;
|
|
11280
|
+
break;
|
|
11281
|
+
case MobxExtendType.OBSERVABLE_SHALLOW:
|
|
11282
|
+
observableDecorator = observable.shallow;
|
|
11283
|
+
break;
|
|
11284
|
+
default:
|
|
11285
|
+
observableDecorator = observable;
|
|
11286
|
+
}
|
|
11287
|
+
if (getter || setter) {
|
|
11288
|
+
const privatePropertyName = `_${propertyName}`;
|
|
11289
|
+
const descriptor = {
|
|
11290
|
+
get: getter || function () {
|
|
11291
|
+
if (!(privatePropertyName in this)) {
|
|
11292
|
+
this[privatePropertyName] = initialValue;
|
|
11293
|
+
observableDecorator(this, privatePropertyName);
|
|
11294
|
+
}
|
|
11295
|
+
return this[privatePropertyName];
|
|
11296
|
+
},
|
|
11297
|
+
enumerable: true,
|
|
11298
|
+
configurable: true
|
|
11299
|
+
};
|
|
11300
|
+
if (setter) {
|
|
11301
|
+
descriptor.set = setter;
|
|
11302
|
+
} else {
|
|
11303
|
+
descriptor.set = function (value) {
|
|
11304
|
+
if (!(privatePropertyName in this)) {
|
|
11305
|
+
observableDecorator(this, privatePropertyName);
|
|
11306
|
+
}
|
|
11307
|
+
this[privatePropertyName] = value;
|
|
11308
|
+
};
|
|
11309
|
+
}
|
|
11310
|
+
Object.defineProperty(prototype, propertyName, descriptor);
|
|
11311
|
+
} else {
|
|
11312
|
+
const privatePropertyName = `__${propertyName}`;
|
|
11313
|
+
Object.defineProperty(prototype, propertyName, {
|
|
11314
|
+
get: function () {
|
|
11315
|
+
if (!(privatePropertyName in this)) {
|
|
11316
|
+
this[privatePropertyName] = initialValue;
|
|
11317
|
+
observableDecorator(this, privatePropertyName);
|
|
11318
|
+
}
|
|
11319
|
+
return this[privatePropertyName];
|
|
11320
|
+
},
|
|
11321
|
+
set: function (value) {
|
|
11322
|
+
if (!(privatePropertyName in this)) {
|
|
11323
|
+
observableDecorator(this, privatePropertyName);
|
|
11324
|
+
}
|
|
11325
|
+
this[privatePropertyName] = value;
|
|
11326
|
+
},
|
|
11327
|
+
enumerable: true,
|
|
11328
|
+
configurable: true
|
|
11329
|
+
});
|
|
11330
|
+
}
|
|
11331
|
+
};
|
|
11332
|
+
const handleComputedProperty = (prototype, propertyName, config) => {
|
|
11333
|
+
const {
|
|
11334
|
+
getter,
|
|
11335
|
+
setter
|
|
11336
|
+
} = config;
|
|
11337
|
+
const descriptor = {
|
|
11338
|
+
get() {
|
|
11339
|
+
return computed(() => getter.call(this)).get();
|
|
11340
|
+
},
|
|
11341
|
+
enumerable: true,
|
|
11342
|
+
configurable: true
|
|
11343
|
+
};
|
|
11344
|
+
if (setter) {
|
|
11345
|
+
descriptor.set = function (value) {
|
|
11346
|
+
setter.call(this, value);
|
|
11347
|
+
};
|
|
11348
|
+
}
|
|
11349
|
+
Object.defineProperty(prototype, propertyName, descriptor);
|
|
11350
|
+
};
|
|
11351
|
+
const handleActionMethod = (prototype, propertyName, config) => {
|
|
11352
|
+
const {
|
|
11353
|
+
method,
|
|
11354
|
+
name
|
|
11355
|
+
} = config;
|
|
11356
|
+
const actionName = name || propertyName;
|
|
11357
|
+
Object.defineProperty(prototype, propertyName, {
|
|
11358
|
+
value: action(actionName, method),
|
|
11359
|
+
writable: true,
|
|
11360
|
+
enumerable: true,
|
|
11361
|
+
configurable: true
|
|
11362
|
+
});
|
|
11363
|
+
};
|
|
11364
|
+
const addMobxExtendProperty = (prototype, propertyName, config) => {
|
|
11365
|
+
switch (config.type) {
|
|
11366
|
+
case MobxExtendType.OBSERVABLE:
|
|
11367
|
+
case MobxExtendType.OBSERVABLE_REF:
|
|
11368
|
+
case MobxExtendType.OBSERVABLE_SHALLOW:
|
|
11369
|
+
handleObservableProperty(prototype, propertyName, config);
|
|
11370
|
+
break;
|
|
11371
|
+
case MobxExtendType.COMPUTED:
|
|
11372
|
+
handleComputedProperty(prototype, propertyName, config);
|
|
11373
|
+
break;
|
|
11374
|
+
case MobxExtendType.ACTION:
|
|
11375
|
+
handleActionMethod(prototype, propertyName, config);
|
|
11376
|
+
break;
|
|
11377
|
+
default:
|
|
11378
|
+
console.warn(`Unknown Mobx extend type: ${config.type}`);
|
|
11379
|
+
}
|
|
11380
|
+
};
|
|
11381
|
+
const mobxExtendObservable = observableProperty;
|
|
11382
|
+
const mobxExtendObservableRef = observableRef;
|
|
11383
|
+
const mobxExtendObservableShallow = observableShallow;
|
|
11384
|
+
const mobxExtendComputed = computedProperty;
|
|
11385
|
+
const mobxExtendComputedGetter = computedGetter;
|
|
11386
|
+
const mobxExtendComputedGetterSetter = computedGetterSetter;
|
|
11387
|
+
const mobxExtendAction = actionMethod;
|
|
11388
|
+
|
|
11389
|
+
const extend = (extendMap, extendClass, properties) => {
|
|
11390
|
+
const newProperties = {};
|
|
11391
|
+
const prototype = extendMap[extendClass].prototype;
|
|
11392
|
+
for (const key in properties) {
|
|
11393
|
+
const property = properties[key];
|
|
11394
|
+
if (isMobxExtendProperty(property)) {
|
|
11395
|
+
addMobxExtendProperty(prototype, key, property.config);
|
|
11396
|
+
continue;
|
|
11397
|
+
}
|
|
11398
|
+
if (typeof property === 'function') {
|
|
11399
|
+
newProperties[key] = {
|
|
11400
|
+
value: property
|
|
11401
|
+
};
|
|
11402
|
+
} else {
|
|
11403
|
+
newProperties[key] = property;
|
|
11404
|
+
}
|
|
11405
|
+
}
|
|
11406
|
+
Object.defineProperties(prototype, newProperties);
|
|
11407
|
+
};
|
|
11408
|
+
|
|
11211
11409
|
class PluginRuntime {
|
|
11212
11410
|
get ctx() {
|
|
11213
11411
|
return this.manager.getPluginContext({
|
|
@@ -11283,20 +11481,6 @@ class PluginRuntime {
|
|
|
11283
11481
|
}
|
|
11284
11482
|
}
|
|
11285
11483
|
|
|
11286
|
-
const extend = (extendMap, extendClass, properties) => {
|
|
11287
|
-
const newProperties = {};
|
|
11288
|
-
for (const key in properties) {
|
|
11289
|
-
if (typeof properties[key] === 'function') {
|
|
11290
|
-
newProperties[key] = {
|
|
11291
|
-
value: properties[key]
|
|
11292
|
-
};
|
|
11293
|
-
} else {
|
|
11294
|
-
newProperties[key] = properties[key];
|
|
11295
|
-
}
|
|
11296
|
-
}
|
|
11297
|
-
Object.defineProperties(extendMap[extendClass].prototype, newProperties);
|
|
11298
|
-
};
|
|
11299
|
-
|
|
11300
11484
|
const sequence = ({
|
|
11301
11485
|
tasks,
|
|
11302
11486
|
names,
|
|
@@ -11882,8 +12066,8 @@ const destroy = async () => {
|
|
|
11882
12066
|
logger.info('Engine destruction successfully');
|
|
11883
12067
|
};
|
|
11884
12068
|
|
|
11885
|
-
const version = '1.0.
|
|
12069
|
+
const version = '1.0.1';
|
|
11886
12070
|
config.set('VERSION', version);
|
|
11887
12071
|
console.log(`%c EasyEditor %c v${version} `, 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #5584ff; font-weight: bold;', 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;');
|
|
11888
12072
|
|
|
11889
|
-
export { AutoFit, COMPONENT_META_EVENT, ComponentMeta, Config, DESIGNER_EVENT, DETECTING_EVENT, DOCUMENT_EVENT, DRAGON_EVENT, Designer, Detecting, Document, DragObject, DragObjectType, Dragon, DropLocation, EDITOR_EVENT, Event, EventBus, GLOBAL_EVENT, HISTORY_EVENT, History, Hotkey, LocationDetailType, Logger, Materials, NODE_CHILDREN_EVENT, NODE_EVENT, Node$1 as Node, NodeChildren, OffsetObserver, PROJECT_EVENT, PluginContext, PluginRuntime, Plugins, PositionNO, Project, Prop, PropValueChangedType, Props, SELECTION_EVENT, Selection, Session, Setters, SettingField, SettingPropEntry, SettingTopEntry, SettingsManager, Simulator, TRANSFORM_STAGE, UNSET, Viewport, clipboard, cloneDeep, commonEvent, comparePosition, config, contains, createEventBus, createLogger, createOffsetObserver, destroy, ensureNode, event, generateSessionId, getClosestClickableNode, getClosestNode, getConvertedExtraKey, getEvent, getOriginalExtraKey, getSourceSensor, getWindow, getZLevelTop, hotkey, init, insertChild, insertChildren, isComponentMeta, isDOMNodeVisible, isDocument, isDocumentNode, isDragAnyObject, isDragEvent, isDragNodeDataObject, isDragNodeObject, isDynamicSetter, isElementNode, isExtraKey, isInvalidPoint, isJSExpression, isJSFunction, isLocateEvent, isLocationChildrenDetail, isLocationData, isLowCodeComponentType, isNode, isNodeSchema, isObject$1 as isObject, isPlainObject$1 as isPlainObject, isPluginEventName, isProCodeComponentType, isProp, isPurgeable, isRegisterOptions, isSameAs, isSetterConfig, isSettingField, isShaken, isSimulator, isSimulatorRenderer, isTextNode, isValidArrayIndex, logger, makeEventsHandler, materials, plugins, project, setShaken, setters, splitPath, uniqueId, version };
|
|
12073
|
+
export { AutoFit, COMPONENT_META_EVENT, ComponentMeta, Config, DESIGNER_EVENT, DETECTING_EVENT, DOCUMENT_EVENT, DRAGON_EVENT, Designer, Detecting, Document, DragObject, DragObjectType, Dragon, DropLocation, EDITOR_EVENT, Event, EventBus, GLOBAL_EVENT, HISTORY_EVENT, History, Hotkey, LocationDetailType, Logger, MOBX_EXTEND_SYMBOL, Materials, MobxExtendType, NODE_CHILDREN_EVENT, NODE_EVENT, Node$1 as Node, NodeChildren, OffsetObserver, PROJECT_EVENT, PluginContext, PluginRuntime, Plugins, PositionNO, Project, Prop, PropValueChangedType, Props, SELECTION_EVENT, Selection, Session, Setters, SettingField, SettingPropEntry, SettingTopEntry, SettingsManager, Simulator, TRANSFORM_STAGE, UNSET, Viewport, addMobxExtendProperty, clipboard, cloneDeep, commonEvent, comparePosition, config, contains, createEventBus, createLogger, createOffsetObserver, destroy, ensureNode, event, extend, generateSessionId, getClosestClickableNode, getClosestNode, getConvertedExtraKey, getEvent, getOriginalExtraKey, getSourceSensor, getWindow, getZLevelTop, hotkey, init, insertChild, insertChildren, isComponentMeta, isDOMNodeVisible, isDocument, isDocumentNode, isDragAnyObject, isDragEvent, isDragNodeDataObject, isDragNodeObject, isDynamicSetter, isElementNode, isExtraKey, isInvalidPoint, isJSExpression, isJSFunction, isLocateEvent, isLocationChildrenDetail, isLocationData, isLowCodeComponentType, isMobxExtendProperty, isNode, isNodeSchema, isObject$1 as isObject, isPlainObject$1 as isPlainObject, isPluginEventName, isProCodeComponentType, isProp, isPurgeable, isRegisterOptions, isSameAs, isSetterConfig, isSettingField, isShaken, isSimulator, isSimulatorRenderer, isTextNode, isValidArrayIndex, logger, makeEventsHandler, materials, mobxExtendAction, mobxExtendComputed, mobxExtendComputedGetter, mobxExtendComputedGetterSetter, mobxExtendObservable, mobxExtendObservableRef, mobxExtendObservableShallow, plugins, project, setShaken, setters, splitPath, uniqueId, version };
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare enum MobxExtendType {
|
|
2
|
+
OBSERVABLE = "observable",
|
|
3
|
+
OBSERVABLE_REF = "observable.ref",
|
|
4
|
+
OBSERVABLE_SHALLOW = "observable.shallow",
|
|
5
|
+
COMPUTED = "computed",
|
|
6
|
+
ACTION = "action"
|
|
7
|
+
}
|
|
8
|
+
export declare const MOBX_EXTEND_SYMBOL: unique symbol;
|
|
9
|
+
export interface BaseMobxConfig {
|
|
10
|
+
type: MobxExtendType;
|
|
11
|
+
}
|
|
12
|
+
export interface ObservableConfig<T = any> extends BaseMobxConfig {
|
|
13
|
+
type: MobxExtendType.OBSERVABLE | MobxExtendType.OBSERVABLE_REF | MobxExtendType.OBSERVABLE_SHALLOW;
|
|
14
|
+
initialValue?: T;
|
|
15
|
+
getter?: (this: any) => T;
|
|
16
|
+
setter?: (this: any, value: T) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface ComputedConfig<T = any> extends BaseMobxConfig {
|
|
19
|
+
type: MobxExtendType.COMPUTED;
|
|
20
|
+
getter: (this: any) => T;
|
|
21
|
+
setter?: (this: any, value: T) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface ActionConfig extends BaseMobxConfig {
|
|
24
|
+
type: MobxExtendType.ACTION;
|
|
25
|
+
method: (this: any, ...args: any[]) => any;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
export type MobxConfig = ObservableConfig | ComputedConfig | ActionConfig;
|
|
29
|
+
export interface MobxExtendDescriptor {
|
|
30
|
+
[MOBX_EXTEND_SYMBOL]: true;
|
|
31
|
+
config: MobxConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare const isMobxExtendProperty: (value: any) => value is MobxExtendDescriptor;
|
|
34
|
+
/**
|
|
35
|
+
* 为类原型添加 Mobx 扩展属性
|
|
36
|
+
*/
|
|
37
|
+
export declare const addMobxExtendProperty: (prototype: any, propertyName: string, config: MobxConfig) => void;
|
|
38
|
+
export declare const mobxExtendObservable: <T = any>(initialValue?: T) => MobxExtendDescriptor;
|
|
39
|
+
export declare const mobxExtendObservableRef: <T = any>(initialValue?: T) => MobxExtendDescriptor;
|
|
40
|
+
export declare const mobxExtendObservableShallow: <T = any>(initialValue?: T) => MobxExtendDescriptor;
|
|
41
|
+
export declare const mobxExtendComputed: <T = any>(config: Omit<ComputedConfig<T>, "type">) => MobxExtendDescriptor;
|
|
42
|
+
export declare const mobxExtendComputedGetter: <T = any>(getter: (this: any) => T) => MobxExtendDescriptor;
|
|
43
|
+
export declare const mobxExtendComputedGetterSetter: <T = any>(getter: (this: any) => T, setter: (this: any, value: T) => void) => MobxExtendDescriptor;
|
|
44
|
+
export declare const mobxExtendAction: (method: (this: any, ...args: any[]) => any, name?: string) => MobxExtendDescriptor;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ComponentMeta, Designer, Detecting, Document, Dragon, DropLocation, History, Materials, Node, NodeChildren, OffsetObserver, Project, Prop, Props, Selection, Setters, Simulator, Viewport } from '..';
|
|
2
|
+
import { type MobxExtendDescriptor } from './plugin-extend-mobx';
|
|
2
3
|
export interface PluginExtend {
|
|
3
4
|
extendClass: PluginExtendClass;
|
|
4
|
-
extend: <T extends keyof PluginExtendClass>(extendClass: T, properties: Record<PropertyKey, () => any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>)) => void;
|
|
5
|
+
extend: <T extends keyof PluginExtendClass>(extendClass: T, properties: Record<PropertyKey, () => any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>) | Record<PropertyKey, MobxExtendDescriptor>) => void;
|
|
5
6
|
}
|
|
6
7
|
export interface PluginExtendClass {
|
|
7
8
|
Simulator: typeof Simulator;
|
|
@@ -29,4 +30,4 @@ export interface PluginExtendClass {
|
|
|
29
30
|
* @param extendClass 扩展类
|
|
30
31
|
* @param properties 扩展属性
|
|
31
32
|
*/
|
|
32
|
-
export declare const extend: <T extends keyof PluginExtendClass>(extendMap: Record<T, PluginExtendClass[T]>, extendClass: T, properties: Record<PropertyKey,
|
|
33
|
+
export declare const extend: <T extends keyof PluginExtendClass>(extendMap: Record<T, PluginExtendClass[T]>, extendClass: T, properties: Record<PropertyKey, any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>)) => void;
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -2,14 +2,42 @@ import type { CompositeValue, JSExpression, JSFunction, JSONObject, PropsMap } f
|
|
|
2
2
|
import type { DataSource } from './data-source';
|
|
3
3
|
export interface ProjectSchema<T = RootSchema> {
|
|
4
4
|
id?: string;
|
|
5
|
+
/**
|
|
6
|
+
* 协议版本号
|
|
7
|
+
*/
|
|
5
8
|
version: string;
|
|
9
|
+
/**
|
|
10
|
+
* 组件映射关系
|
|
11
|
+
*/
|
|
6
12
|
componentsMap?: any;
|
|
13
|
+
/**
|
|
14
|
+
* 组件树
|
|
15
|
+
*/
|
|
7
16
|
componentsTree: T[];
|
|
17
|
+
/**
|
|
18
|
+
* 工具类
|
|
19
|
+
*/
|
|
8
20
|
utils?: Record<string, any>;
|
|
21
|
+
/**
|
|
22
|
+
* 全局常量
|
|
23
|
+
*/
|
|
9
24
|
constants?: JSONObject;
|
|
25
|
+
/**
|
|
26
|
+
* 全局样式
|
|
27
|
+
*/
|
|
10
28
|
css?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 配置信息
|
|
31
|
+
*/
|
|
11
32
|
config?: Record<string, any>;
|
|
33
|
+
/**
|
|
34
|
+
* 元数据信息
|
|
35
|
+
*/
|
|
12
36
|
meta?: Record<string, any>;
|
|
37
|
+
/**
|
|
38
|
+
* 异步数据源配置
|
|
39
|
+
*/
|
|
40
|
+
dataSource?: DataSource;
|
|
13
41
|
[key: string]: any;
|
|
14
42
|
}
|
|
15
43
|
export interface RootSchema extends NodeSchema {
|
|
@@ -41,10 +69,6 @@ export interface RootSchema extends NodeSchema {
|
|
|
41
69
|
* 样式文件
|
|
42
70
|
*/
|
|
43
71
|
css?: string;
|
|
44
|
-
/**
|
|
45
|
-
* 异步数据源配置
|
|
46
|
-
*/
|
|
47
|
-
dataSource?: DataSource;
|
|
48
72
|
}
|
|
49
73
|
export interface NodeSchema {
|
|
50
74
|
id?: string;
|