New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@antv/l7-core

Package Overview
Dependencies
Maintainers
61
Versions
541
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/l7-core - npm Package Compare versions

Comparing version 2.9.32-alpha.0 to 2.9.32-alpha.1

9

es/services/asset/FontService.d.ts

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

import { EventEmitter } from 'eventemitter3';
import 'reflect-metadata';

@@ -10,3 +11,3 @@ import { IFontAtlas, IFontMapping, IFontOptions, IFontService, IIconFontGlyph } from './IFontService';

export declare const DEFAULT_RADIUS = 8;
export default class FontService implements IFontService {
export default class FontService extends EventEmitter implements IFontService {
get scale(): number;

@@ -37,2 +38,8 @@ get canvas(): HTMLCanvasElement;

setFontOptions(option: Partial<IFontOptions>): void;
/**
* 用户自定义添加第三方字体 (用户使用 layer/point/text/iconfont 的前提需要加载第三方字体文件)
* @param fontFamily
* @param fontPath
*/
addFontFace(fontFamily: string, fontPath: string): void;
destroy(): void;

@@ -39,0 +46,0 @@ private generateFontAtlas;

import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";

@@ -14,4 +18,9 @@

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import { $window, LRUCache } from '@antv/l7-utils';
import { injectable } from 'inversify';
import { EventEmitter } from 'eventemitter3';
import TinySDF from 'l7-tiny-sdf';

@@ -56,17 +65,31 @@ import 'reflect-metadata';

var FontService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
var FontService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function (_EventEmitter) {
_inherits(FontService, _EventEmitter);
var _super = _createSuper(FontService);
function FontService() {
var _this;
_classCallCheck(this, FontService);
_defineProperty(this, "fontAtlas", void 0);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_defineProperty(this, "iconFontMap", void 0);
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(this, "iconFontGlyphs", {});
_defineProperty(_assertThisInitialized(_this), "fontAtlas", void 0);
_defineProperty(this, "fontOptions", void 0);
_defineProperty(_assertThisInitialized(_this), "iconFontMap", void 0);
_defineProperty(this, "key", void 0);
_defineProperty(_assertThisInitialized(_this), "iconFontGlyphs", {});
_defineProperty(this, "cache", new LRUCache(CACHE_LIMIT));
_defineProperty(_assertThisInitialized(_this), "fontOptions", void 0);
_defineProperty(_assertThisInitialized(_this), "key", void 0);
_defineProperty(_assertThisInitialized(_this), "cache", new LRUCache(CACHE_LIMIT));
return _this;
}

@@ -112,6 +135,6 @@

value: function addIconGlyphs(glyphs) {
var _this = this;
var _this2 = this;
glyphs.forEach(function (glyph) {
_this.iconFontGlyphs[glyph.name] = glyph.unicode;
_this2.iconFontGlyphs[glyph.name] = glyph.unicode;
});

@@ -153,4 +176,3 @@ }

value: function setFontOptions(option) {
this.fontOptions = _objectSpread(_objectSpread({}, this.fontOptions), option); // const oldKey = this.key;
this.fontOptions = _objectSpread(_objectSpread({}, this.fontOptions), option);
this.key = this.getKey();

@@ -171,3 +193,37 @@ var charSet = this.getNewChars(this.key, this.fontOptions.characterSet);

}
/**
* 用户自定义添加第三方字体 (用户使用 layer/point/text/iconfont 的前提需要加载第三方字体文件)
* @param fontFamily
* @param fontPath
*/
}, {
key: "addFontFace",
value: function addFontFace(fontFamily, fontPath) {
var _this3 = this;
var style = document.createElement('style');
style.type = 'text/css';
style.innerText = "\n @font-face{\n font-family: '".concat(fontFamily, "';\n src: url('").concat(fontPath, "') format('woff2'),\n url('").concat(fontPath, "') format('woff'),\n url('").concat(fontPath, "') format('truetype');\n }");
document.getElementsByTagName('head')[0].appendChild(style);
style.onload = function () {
if (document.fonts) {
try {
// @ts-ignore
document.fonts.load("24px ".concat(fontFamily), 'L7text');
document.fonts.ready.then(function () {
_this3.emit('fontloaded', {
fontFamily: fontFamily
});
});
} catch (e) {
console.warn('当前环境不支持 document.fonts !');
console.warn('当前环境不支持 iconfont !');
console.warn(e);
}
}
};
}
}, {
key: "destroy",

@@ -335,3 +391,3 @@ value: function destroy() {

return FontService;
}()) || _class);
}(EventEmitter)) || _class);
export { FontService as default };

4

es/services/asset/IFontService.d.ts

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

import EventEmitter from 'eventemitter3';
export interface IFontOptions {

@@ -49,3 +50,3 @@ fontFamily: string;

}
export interface IFontService {
export interface IFontService extends EventEmitter {
mapping: IFontMapping;

@@ -59,2 +60,3 @@ iconFontMap: Map<string, string>;

addIconFont(name: string, fontUnicode: string): void;
addFontFace(fontname: string, fontpath: string): void;
getIconFontKey(name: string): string;

@@ -61,0 +63,0 @@ getGlyph(name: string): string;

@@ -23,6 +23,4 @@ import EventEmitter from 'eventemitter3';

}
export interface IIconService {
export interface IIconService extends EventEmitter {
canvasHeight: number;
on(event: string, fn: EventEmitter.ListenerFn, context?: any): this;
off(event: string, fn: EventEmitter.ListenerFn, context?: any): this;
init(): void;

@@ -29,0 +27,0 @@ addImage(id: string, image: IImage): void;

@@ -110,2 +110,6 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread2";

}
if (config.resCallback) {
transformRequestConfig.resCallback = config.resCallback;
}
} // public validateSceneConfig(data: object) {

@@ -112,0 +116,0 @@ // return this.validate(this.sceneConfigValidator, data);

@@ -19,2 +19,3 @@ import { PositionName } from '../component/IControlService';

transformRequest?: (requestParameters: Partial<RequestParameters>) => RequestParameters;
resCallback?: (response: Object) => Uint8Array;
}

@@ -21,0 +22,0 @@ export interface IGlobalConfigService {

@@ -18,3 +18,2 @@ import 'reflect-metadata';

private pickBufferScale;
private pickedLayers;
init(id: string): void;

@@ -21,0 +20,0 @@ boxPickLayer(layer: ILayer, box: [number, number, number, number], cb: (...args: any[]) => void): Promise<any>;

@@ -51,4 +51,2 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

_defineProperty(this, "pickedLayers", []);
_defineProperty(this, "pickFromPickingFBO", function (layer, _ref) {

@@ -124,3 +122,2 @@ var x = _ref.x,

layer.setCurrentPickId(pickedFeatureIdx);
_this.pickedLayers = [layer];

@@ -149,3 +146,2 @@ _this.triggerHoverOnLayer(layer, layerTarget); // 触发拾取事件

layer.setCurrentPickId(null);
_this.pickedLayers = [];
}

@@ -459,11 +455,4 @@

depth: 1
}); // Tip: clear last picked layer state
_this4.pickedLayers.filter(function (pickedlayer) {
return !pickedlayer.isVector;
}).map(function (pickedlayer) {
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0]));
}); // Tip: clear last picked tilelayer state
_this4.pickedTileLayers.map(function (pickedTileLayer) {

@@ -470,0 +459,0 @@ var _pickedTileLayer$tile;

import { ISceneConfig } from '../config/IConfigService';
import { ILayer } from '../layer/ILayerService';
export interface ISceneService {
import EventEmitter from 'eventemitter3';
export interface ISceneService extends EventEmitter {
destroyed: boolean;
loaded: boolean;
fontFamily: string;
loadFont: boolean;
on(type: string, handle: (...args: any[]) => void): void;
once(type: string, handle: (...args: any[]) => void): void;
off(type: string, handle: (...args: any[]) => void): void;
removeAllListeners(event?: string): this;

@@ -12,0 +8,0 @@ init(config: ISceneConfig): void;

// scene 事件
export var SceneEventList = ['loaded', 'maploaded', 'resize', 'destroy', 'dragstart', 'dragging', 'dragend', 'dragcancel'];
export var SceneEventList = ['loaded', 'fontloaded', 'maploaded', 'resize', 'destroy', 'dragstart', 'dragging', 'dragend', 'dragcancel'];

@@ -12,4 +12,2 @@ import { EventEmitter } from 'eventemitter3';

loaded: boolean;
loadFont: boolean;
fontFamily: string;
private readonly id;

@@ -16,0 +14,0 @@ /**

@@ -40,5 +40,2 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";

// loadFont 判断用户当前是否添加自定义字体
// fontFamily 用户当前自己添加的字体的名称
/**

@@ -67,6 +64,2 @@ * 使用各种 Service

_defineProperty(_assertThisInitialized(_this), "loadFont", false);
_defineProperty(_assertThisInitialized(_this), "fontFamily", '');
_initializerDefineProperty(_assertThisInitialized(_this), "id", _descriptor, _assertThisInitialized(_this));

@@ -416,3 +409,3 @@

if (this.inited) {
_context5.next = 23;
_context5.next = 12;
break;

@@ -428,27 +421,5 @@ }

this.destroy();
} // @ts-ignore
} // FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
if (!(this.loadFont && document.fonts)) {
_context5.next = 18;
break;
}
_context5.prev = 8;
_context5.next = 11;
return document.fonts.load("24px ".concat(this.fontFamily), 'L7text');
case 11:
_context5.next = 18;
break;
case 13:
_context5.prev = 13;
_context5.t0 = _context5["catch"](8);
console.warn('当前环境不支持 document.fonts !');
console.warn('当前环境不支持 iconfont !');
console.warn(_context5.t0);
case 18:
// FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
this.layerService.initLayers();

@@ -460,3 +431,3 @@ this.controlService.addControls();

case 23:
case 12:
// 尝试初始化未初始化的图层

@@ -468,3 +439,3 @@ this.layerService.updateLayerRenderList();

case 26:
case 15:
case "end":

@@ -474,3 +445,3 @@ return _context5.stop();

}
}, _callee5, this, [[8, 13]]);
}, _callee5, this);
}));

@@ -493,8 +464,3 @@

value: function addFontFace(fontFamily, fontPath) {
this.fontFamily = fontFamily;
var style = document.createElement('style');
style.type = 'text/css';
style.innerText = "\n @font-face{\n font-family: '".concat(fontFamily, "';\n src: url('").concat(fontPath, "') format('woff2'),\n url('").concat(fontPath, "') format('woff'),\n url('").concat(fontPath, "') format('truetype');\n }");
document.getElementsByTagName('head')[0].appendChild(style);
this.loadFont = true;
this.fontService.addFontFace(fontFamily, fontPath);
}

@@ -501,0 +467,0 @@ }, {

@@ -16,2 +16,10 @@ "use strict";

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -23,2 +31,4 @@

var _eventemitter = require("eventemitter3");
var _l7TinySdf = _interopRequireDefault(require("l7-tiny-sdf"));

@@ -38,2 +48,6 @@

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
var DEFAULT_CHAR_SET = getDefaultCharacterSet();

@@ -82,11 +96,24 @@ exports.DEFAULT_CHAR_SET = DEFAULT_CHAR_SET;

var FontService = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
var FontService = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function (_EventEmitter) {
(0, _inherits2.default)(FontService, _EventEmitter);
var _super = _createSuper(FontService);
function FontService() {
var _this;
(0, _classCallCheck2.default)(this, FontService);
(0, _defineProperty2.default)(this, "fontAtlas", void 0);
(0, _defineProperty2.default)(this, "iconFontMap", void 0);
(0, _defineProperty2.default)(this, "iconFontGlyphs", {});
(0, _defineProperty2.default)(this, "fontOptions", void 0);
(0, _defineProperty2.default)(this, "key", void 0);
(0, _defineProperty2.default)(this, "cache", new _l7Utils.LRUCache(CACHE_LIMIT));
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fontAtlas", void 0);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "iconFontMap", void 0);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "iconFontGlyphs", {});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fontOptions", void 0);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "key", void 0);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cache", new _l7Utils.LRUCache(CACHE_LIMIT));
return _this;
}

@@ -132,6 +159,6 @@

value: function addIconGlyphs(glyphs) {
var _this = this;
var _this2 = this;
glyphs.forEach(function (glyph) {
_this.iconFontGlyphs[glyph.name] = glyph.unicode;
_this2.iconFontGlyphs[glyph.name] = glyph.unicode;
});

@@ -173,4 +200,3 @@ }

value: function setFontOptions(option) {
this.fontOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.fontOptions), option); // const oldKey = this.key;
this.fontOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.fontOptions), option);
this.key = this.getKey();

@@ -191,3 +217,37 @@ var charSet = this.getNewChars(this.key, this.fontOptions.characterSet);

}
/**
* 用户自定义添加第三方字体 (用户使用 layer/point/text/iconfont 的前提需要加载第三方字体文件)
* @param fontFamily
* @param fontPath
*/
}, {
key: "addFontFace",
value: function addFontFace(fontFamily, fontPath) {
var _this3 = this;
var style = document.createElement('style');
style.type = 'text/css';
style.innerText = "\n @font-face{\n font-family: '".concat(fontFamily, "';\n src: url('").concat(fontPath, "') format('woff2'),\n url('").concat(fontPath, "') format('woff'),\n url('").concat(fontPath, "') format('truetype');\n }");
document.getElementsByTagName('head')[0].appendChild(style);
style.onload = function () {
if (document.fonts) {
try {
// @ts-ignore
document.fonts.load("24px ".concat(fontFamily), 'L7text');
document.fonts.ready.then(function () {
_this3.emit('fontloaded', {
fontFamily: fontFamily
});
});
} catch (e) {
console.warn('当前环境不支持 document.fonts !');
console.warn('当前环境不支持 iconfont !');
console.warn(e);
}
}
};
}
}, {
key: "destroy",

@@ -354,3 +414,3 @@ value: function destroy() {

return FontService;
}()) || _class);
}(_eventemitter.EventEmitter)) || _class);
exports.default = FontService;

@@ -123,2 +123,6 @@ "use strict";

}
if (config.resCallback) {
_l7Utils.transformRequestConfig.resCallback = config.resCallback;
}
} // public validateSceneConfig(data: object) {

@@ -125,0 +129,0 @@ // return this.validate(this.sceneConfigValidator, data);

@@ -63,3 +63,2 @@ "use strict";

(0, _defineProperty2.default)(this, "pickBufferScale", 1.0);
(0, _defineProperty2.default)(this, "pickedLayers", []);
(0, _defineProperty2.default)(this, "pickFromPickingFBO", function (layer, _ref) {

@@ -135,3 +134,2 @@ var x = _ref.x,

layer.setCurrentPickId(pickedFeatureIdx);
_this.pickedLayers = [layer];

@@ -160,3 +158,2 @@ _this.triggerHoverOnLayer(layer, layerTarget); // 触发拾取事件

layer.setCurrentPickId(null);
_this.pickedLayers = [];
}

@@ -470,11 +467,4 @@

depth: 1
}); // Tip: clear last picked layer state
_this4.pickedLayers.filter(function (pickedlayer) {
return !pickedlayer.isVector;
}).map(function (pickedlayer) {
_this4.selectFeature(pickedlayer, new Uint8Array([0, 0, 0, 0]));
}); // Tip: clear last picked tilelayer state
_this4.pickedTileLayers.map(function (pickedTileLayer) {

@@ -481,0 +471,0 @@ var _pickedTileLayer$tile;

@@ -8,3 +8,3 @@ "use strict";

// scene 事件
var SceneEventList = ['loaded', 'maploaded', 'resize', 'destroy', 'dragstart', 'dragging', 'dragend', 'dragcancel'];
var SceneEventList = ['loaded', 'fontloaded', 'maploaded', 'resize', 'destroy', 'dragstart', 'dragging', 'dragend', 'dragcancel'];
exports.SceneEventList = SceneEventList;

@@ -73,5 +73,2 @@ "use strict";

// loadFont 判断用户当前是否添加自定义字体
// fontFamily 用户当前自己添加的字体的名称
/**

@@ -97,4 +94,2 @@ * 使用各种 Service

(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "loaded", false);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "loadFont", false);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fontFamily", '');
(0, _initializerDefineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", _descriptor, (0, _assertThisInitialized2.default)(_this));

@@ -421,3 +416,3 @@ (0, _initializerDefineProperty2.default)((0, _assertThisInitialized2.default)(_this), "iconService", _descriptor2, (0, _assertThisInitialized2.default)(_this));

if (this.inited) {
_context5.next = 23;
_context5.next = 12;
break;

@@ -433,27 +428,5 @@ }

this.destroy();
} // @ts-ignore
} // FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
if (!(this.loadFont && document.fonts)) {
_context5.next = 18;
break;
}
_context5.prev = 8;
_context5.next = 11;
return document.fonts.load("24px ".concat(this.fontFamily), 'L7text');
case 11:
_context5.next = 18;
break;
case 13:
_context5.prev = 13;
_context5.t0 = _context5["catch"](8);
console.warn('当前环境不支持 document.fonts !');
console.warn('当前环境不支持 iconfont !');
console.warn(_context5.t0);
case 18:
// FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
this.layerService.initLayers();

@@ -465,3 +438,3 @@ this.controlService.addControls();

case 23:
case 12:
// 尝试初始化未初始化的图层

@@ -473,3 +446,3 @@ this.layerService.updateLayerRenderList();

case 26:
case 15:
case "end":

@@ -479,3 +452,3 @@ return _context5.stop();

}
}, _callee5, this, [[8, 13]]);
}, _callee5, this);
}));

@@ -498,8 +471,3 @@

value: function addFontFace(fontFamily, fontPath) {
this.fontFamily = fontFamily;
var style = document.createElement('style');
style.type = 'text/css';
style.innerText = "\n @font-face{\n font-family: '".concat(fontFamily, "';\n src: url('").concat(fontPath, "') format('woff2'),\n url('").concat(fontPath, "') format('woff'),\n url('").concat(fontPath, "') format('truetype');\n }");
document.getElementsByTagName('head')[0].appendChild(style);
this.loadFont = true;
this.fontService.addFontFace(fontFamily, fontPath);
}

@@ -506,0 +474,0 @@ }, {

{
"name": "@antv/l7-core",
"version": "2.9.32-alpha.0",
"version": "2.9.32-alpha.1",
"description": "",

@@ -28,3 +28,3 @@ "main": "lib/index.js",

"@antv/async-hook": "^2.2.2",
"@antv/l7-utils": "2.9.32-alpha.0",
"@antv/l7-utils": "2.9.32-alpha.1",
"@babel/runtime": "^7.7.7",

@@ -52,3 +52,3 @@ "@turf/helpers": "^6.1.4",

},
"gitHead": "35a25538904d91b77e029539e3d9c9fc83bad399",
"gitHead": "3605ad7724ff58f38c6e22e195d103edfbcb5bc0",
"publishConfig": {

@@ -55,0 +55,0 @@ "access": "public"

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