Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@icreate/core

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@icreate/core - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

154

dist/ics.es5.js

@@ -230,10 +230,28 @@ /*

/*
* @Author: 文贝
* @Date: 2022-02-09 00:39:00
* @LastEditors: 文贝
* @LastEditTime: 2022-02-09 17:31:27
* @Descripttion:
* @FilePath: \src\core\utils.ts
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var Utils = /** @class */ (function () {

@@ -400,41 +418,3 @@ function Utils() {

};
return Utils;
}());
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var Imedx = /** @class */ (function () {
function Imedx() {
this._callbacks = {};
this._baseCommandUrl = 'http://command.com/';
this.baseAjaxUrl = 'http://icreate.com/';
var isNode = typeof window === 'undefined';
this.isImedx = isNode ? false : !!window['CefSharp'];
this.cefSharp = isNode ? { PostMessage: function () { } } : window['CefSharp'];
}
Imedx.prototype.$command = function (opts) {
Utils.Command = function (opts) {
var link = document.createElement('a');

@@ -450,6 +430,6 @@ var params = [];

};
Imedx.prototype.$function = function (opts) {
Utils.Function = function (opts) {
var _this = this;
return new Promise(function (resolve, reject) {
_this._ajax(__assign(__assign({}, opts), { url: "" + _this.baseAjaxUrl + opts.url, method: opts.method || 'GET' }))
_this._ajax(__assign(__assign({}, opts), { url: "" + _this._baseAjaxUrl + opts.url, method: opts.method || 'GET' }))
.then(function (xhr) {

@@ -482,63 +462,4 @@ try {

};
/**
* 接受cef分发事件,触发容器中的该属性eventName的回调函数
* @param {*} eventName 事件名称
* @param {*} data 数据
*/
Imedx.prototype.$onReceive = function (message) {
var _a = JSON.parse(message), eventName = _a.eventName, data = _a.data;
var callbacks = this._callbacks[eventName];
if (!callbacks || !callbacks.length) {
return;
}
for (var i = 0; i < callbacks.length; i++) {
callbacks[i].apply(this, data);
}
};
/**
* @description:订阅C#事件
* @param {string} eventName
* @param {Function} callback
* @return {void}
*/
Imedx.prototype.$on = function (eventName, callback) {
if (!this._callbacks[eventName]) {
this._callbacks[eventName] = [];
}
this._callbacks[eventName].push(callback);
};
/**
* @description: 取消C#订阅事件
* @param {string} eventName
* @param {Function} callback
* @return {void}
*/
Imedx.prototype.$off = function (eventName, callback) {
var callbacks = this._callbacks[eventName];
if (!callbacks) {
return;
}
var index = -1;
for (var i = 0; i < callbacks.length; i++) {
if (callbacks[i] === callback) {
index = i;
break;
}
}
if (index < 0) {
return;
}
this._callbacks[eventName].splice(index, 1);
};
/**
* @description: 触发C#事件
* @param {string} eventName
* @return {void}
*/
Imedx.prototype.$emit = function (eventName) {
var args = Array.prototype.slice.call(arguments, 1);
this.cefSharp.PostMessage(JSON.stringify(__assign({ eventName: eventName }, args)));
};
// ajax请求
Imedx.prototype._ajax = function (opts) {
Utils._ajax = function (opts) {
var that = this;

@@ -569,5 +490,5 @@ return new Promise(function (resolve, reject) {

// 发起请求函数
Imedx.prototype._httpRequest = function (opts) {
Utils._httpRequest = function (opts) {
var _option = new ExecOptons();
Utils.extend(_option, opts);
this.extend(_option, opts);
var xhr = this._getXMLHttpRequest();

@@ -593,3 +514,3 @@ if (_option.timeout > 0)

// 创建XMLHttpRequest
Imedx.prototype._getXMLHttpRequest = function () {
Utils._getXMLHttpRequest = function () {
// let XMLHttpRequest = require('xhr2');

@@ -602,3 +523,5 @@ var xhr = new XMLHttpRequest();

};
return Imedx;
Utils._baseCommandUrl = 'http://command.com/';
Utils._baseAjaxUrl = 'http://icreate.com/';
return Utils;
}());

@@ -610,3 +533,3 @@

* @LastEditors: 文贝
* @LastEditTime: 2022-02-10 00:36:43
* @LastEditTime: 2022-02-12 00:11:44
* @Descripttion:

@@ -630,3 +553,2 @@ * @FilePath: \src\ics.ts

this.utils = Utils;
this.imedx = new Imedx();
}

@@ -643,3 +565,3 @@ Ics.prototype.toAbsAppPath = function (path) {

export { ics, Event, UIBlock as BlockUI, Logger, Utils, Imedx, LogLevels, ExecOptons, UIOptions };
export { ics, Event, UIBlock as BlockUI, Logger, Utils, LogLevels, ExecOptons, UIOptions };
//# sourceMappingURL=ics.es5.js.map

@@ -235,10 +235,28 @@ (function (global, factory) {

/*
* @Author: 文贝
* @Date: 2022-02-09 00:39:00
* @LastEditors: 文贝
* @LastEditTime: 2022-02-09 17:31:27
* @Descripttion:
* @FilePath: \src\core\utils.ts
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var Utils = /** @class */ (function () {

@@ -405,41 +423,3 @@ function Utils() {

};
return Utils;
}());
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var Imedx = /** @class */ (function () {
function Imedx() {
this._callbacks = {};
this._baseCommandUrl = 'http://command.com/';
this.baseAjaxUrl = 'http://icreate.com/';
var isNode = typeof window === 'undefined';
this.isImedx = isNode ? false : !!window['CefSharp'];
this.cefSharp = isNode ? { PostMessage: function () { } } : window['CefSharp'];
}
Imedx.prototype.$command = function (opts) {
Utils.Command = function (opts) {
var link = document.createElement('a');

@@ -455,6 +435,6 @@ var params = [];

};
Imedx.prototype.$function = function (opts) {
Utils.Function = function (opts) {
var _this = this;
return new Promise(function (resolve, reject) {
_this._ajax(__assign(__assign({}, opts), { url: "" + _this.baseAjaxUrl + opts.url, method: opts.method || 'GET' }))
_this._ajax(__assign(__assign({}, opts), { url: "" + _this._baseAjaxUrl + opts.url, method: opts.method || 'GET' }))
.then(function (xhr) {

@@ -487,63 +467,4 @@ try {

};
/**
* 接受cef分发事件,触发容器中的该属性eventName的回调函数
* @param {*} eventName 事件名称
* @param {*} data 数据
*/
Imedx.prototype.$onReceive = function (message) {
var _a = JSON.parse(message), eventName = _a.eventName, data = _a.data;
var callbacks = this._callbacks[eventName];
if (!callbacks || !callbacks.length) {
return;
}
for (var i = 0; i < callbacks.length; i++) {
callbacks[i].apply(this, data);
}
};
/**
* @description:订阅C#事件
* @param {string} eventName
* @param {Function} callback
* @return {void}
*/
Imedx.prototype.$on = function (eventName, callback) {
if (!this._callbacks[eventName]) {
this._callbacks[eventName] = [];
}
this._callbacks[eventName].push(callback);
};
/**
* @description: 取消C#订阅事件
* @param {string} eventName
* @param {Function} callback
* @return {void}
*/
Imedx.prototype.$off = function (eventName, callback) {
var callbacks = this._callbacks[eventName];
if (!callbacks) {
return;
}
var index = -1;
for (var i = 0; i < callbacks.length; i++) {
if (callbacks[i] === callback) {
index = i;
break;
}
}
if (index < 0) {
return;
}
this._callbacks[eventName].splice(index, 1);
};
/**
* @description: 触发C#事件
* @param {string} eventName
* @return {void}
*/
Imedx.prototype.$emit = function (eventName) {
var args = Array.prototype.slice.call(arguments, 1);
this.cefSharp.PostMessage(JSON.stringify(__assign({ eventName: eventName }, args)));
};
// ajax请求
Imedx.prototype._ajax = function (opts) {
Utils._ajax = function (opts) {
var that = this;

@@ -574,5 +495,5 @@ return new Promise(function (resolve, reject) {

// 发起请求函数
Imedx.prototype._httpRequest = function (opts) {
Utils._httpRequest = function (opts) {
var _option = new ExecOptons();
Utils.extend(_option, opts);
this.extend(_option, opts);
var xhr = this._getXMLHttpRequest();

@@ -598,3 +519,3 @@ if (_option.timeout > 0)

// 创建XMLHttpRequest
Imedx.prototype._getXMLHttpRequest = function () {
Utils._getXMLHttpRequest = function () {
// let XMLHttpRequest = require('xhr2');

@@ -607,3 +528,5 @@ var xhr = new XMLHttpRequest();

};
return Imedx;
Utils._baseCommandUrl = 'http://command.com/';
Utils._baseAjaxUrl = 'http://icreate.com/';
return Utils;
}());

@@ -615,3 +538,3 @@

* @LastEditors: 文贝
* @LastEditTime: 2022-02-10 00:36:43
* @LastEditTime: 2022-02-12 00:11:44
* @Descripttion:

@@ -635,3 +558,2 @@ * @FilePath: \src\ics.ts

this.utils = Utils;
this.imedx = new Imedx();
}

@@ -653,3 +575,2 @@ Ics.prototype.toAbsAppPath = function (path) {

exports.Utils = Utils;
exports.Imedx = Imedx;
exports.ExecOptons = ExecOptons;

@@ -656,0 +577,0 @@ exports.UIOptions = UIOptions;

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,6 +18,7 @@ /*

* @LastEditors: 文贝
* @LastEditTime: 2022-02-09 17:31:27
* @LastEditTime: 2022-02-12 00:11:36
* @Descripttion:
* @FilePath: \src\core\utils.ts
*/
var interfaces_1 = require("../interfaces/interfaces");
var Utils = /** @class */ (function () {

@@ -173,2 +185,105 @@ function Utils() {

};
Utils.Command = function (opts) {
var link = document.createElement('a');
var params = [];
for (var key in opts.data) {
params.push(key + '=' + opts.data[key]);
}
link.href = "" + this._baseCommandUrl + opts.url + (params.length > 0 ? "?" + params.join('&') : '');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
Utils.Function = function (opts) {
var _this = this;
var that = this;
return new Promise(function (resolve, reject) {
_this._ajax(__assign(__assign({}, opts), { url: "" + _this._baseAjaxUrl + opts.url, method: opts.method || 'GET' }))
.then(function (xhr) {
try {
var response = JSON.parse(xhr.responseText);
if (response.Code === 200) {
resolve(response.Data);
}
else {
reject(response.Message);
}
}
catch (error) {
console.error("[imedx ajax error('" + opts.url + "')]:" + error);
reject(error);
}
})
.catch(function (xhr) {
if (xhr) {
console.error("[imedx ajax error('" + opts.url + "')]:" + xhr);
reject(xhr); // 失败
}
else {
console.error("[imedx ajax error('" + opts.url + "')]:" + xhr);
// alert(xhr.responseText)
}
});
});
};
// ajax请求
Utils._ajax = function (opts) {
var that = this;
return new Promise(function (resolve, reject) {
try {
var xhr_1 = that._httpRequest(opts);
xhr_1.onreadystatechange = function () {
if (xhr_1.readyState === 4) {
if (xhr_1.status === 200) {
try {
resolve(xhr_1);
}
catch (error) {
reject(xhr_1);
}
}
else
reject(xhr_1);
}
};
}
catch (error) {
reject(error);
}
});
};
// 发起请求函数
Utils._httpRequest = function (opts) {
var _option = new interfaces_1.ExecOptons();
this.extend(_option, opts);
var xhr = this._getXMLHttpRequest();
if (_option.timeout > 0)
xhr.timeout = _option.timeout;
if (_option.method.toUpperCase() === 'POST') {
xhr.open(_option.method, _option.url, _option.async);
xhr.setRequestHeader('Content-Type', _option.contentType);
xhr.send(JSON.stringify(_option.data));
}
else if (_option.method.toUpperCase() === 'GET') {
var params = [];
for (var key in _option.data) {
params.push(key + '=' + _option.data[key]);
}
console.log(_option.url + (params.length > 0 ? "?" + params.join('&') : ''));
xhr.open(_option.method, _option.url + (params.length > 0 ? "?" + params.join('&') : ''), _option.async);
xhr.send(null);
}
return xhr;
};
// 创建XMLHttpRequest
Utils._getXMLHttpRequest = function () {
// let XMLHttpRequest = require('xhr2');
var xhr = new XMLHttpRequest();
if (xhr.overrideMimeType) {
xhr.overrideMimeType('text/xml');
}
return xhr;
};
Utils._baseCommandUrl = 'http://command.com/';
Utils._baseAjaxUrl = 'http://icreate.com/';
return Utils;

@@ -175,0 +290,0 @@ }());

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIOptions = exports.ExecOptons = exports.LogLevels = exports.Imedx = exports.Utils = exports.Logger = exports.BlockUI = exports.Event = exports.ics = void 0;
exports.UIOptions = exports.ExecOptons = exports.LogLevels = exports.Utils = exports.Logger = exports.BlockUI = exports.Event = exports.ics = void 0;
/*

@@ -8,3 +8,3 @@ * @Author: 文贝

* @LastEditors: 文贝
* @LastEditTime: 2022-02-10 00:36:43
* @LastEditTime: 2022-02-12 00:11:44
* @Descripttion:

@@ -25,4 +25,2 @@ * @FilePath: \src\ics.ts

exports.Utils = utils_1.default;
var imedx_1 = require("./core/imedx");
exports.Imedx = imedx_1.default;
var Ics = /** @class */ (function () {

@@ -43,3 +41,2 @@ function Ics() {

this.utils = utils_1.default;
this.imedx = new imedx_1.default();
}

@@ -46,0 +43,0 @@ Ics.prototype.toAbsAppPath = function (path) {

@@ -0,2 +1,5 @@

import { ExecOptons } from '../interfaces/interfaces';
export default class Utils {
private static _baseCommandUrl;
private static _baseAjaxUrl;
static createNamespace(root: any, ns: string): object;

@@ -40,2 +43,7 @@ static replaceAll(str: string, search: string, replacement: string): string;

static extend(dstObj: object, srcObj: object): object;
static Command(opts: ExecOptons): void;
static Function(opts: ExecOptons): Promise<any>;
private static _ajax;
private static _httpRequest;
private static _getXMLHttpRequest;
}

@@ -6,3 +6,2 @@ import { ExecOptons, IBlockUI, IEvent, ILogger, LogLevels, UIOptions } from './interfaces/interfaces';

import Utils from './core/utils';
import Imedx from './core/imedx';
declare class Ics {

@@ -16,5 +15,4 @@ appPath: string;

utils: Utils;
imedx: Imedx;
}
declare const ics: Ics;
export { ics, Event, BlockUI, Logger, Utils, Imedx, LogLevels, ExecOptons, UIOptions };
export { ics, Event, BlockUI, Logger, Utils, LogLevels, ExecOptons, UIOptions };
{
"name": "@icreate/core",
"version": "0.0.7",
"version": "0.0.8",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc