makerjs 0.18.2 → 0.19.2

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.js CHANGED
@@ -58,29 +58,35 @@ var MakerJs;
58
58
  * @private
59
59
  */
60
60
  var EPSILON = Number.EPSILON || Math.pow(2, -52);
61
- /**
62
- * @private
63
- */
64
- function tryEval(name) {
65
- try {
66
- var value = eval(name);
67
- return value;
68
- }
69
- catch (e) { }
70
- return;
71
- }
72
61
  /**
73
62
  * @private
74
63
  */
75
64
  function detectEnvironment() {
76
- if (tryEval('WorkerGlobalScope') && tryEval('self')) {
65
+ // Use a function to get the global object to avoid TypeScript checking specific globals
66
+ var getGlobal = function () {
67
+ // In browsers and workers, 'self' refers to the global scope
68
+ if (typeof self !== 'undefined') {
69
+ return self;
70
+ }
71
+ // In Node.js, 'global' refers to the global scope
72
+ if (typeof global !== 'undefined') {
73
+ return global;
74
+ }
75
+ // Fallback for older environments
76
+ return this || {};
77
+ };
78
+ var globalObj = getGlobal();
79
+ // Check for Web Worker environment
80
+ // Workers have 'self' and 'WorkerGlobalScope' but not 'window'
81
+ if (globalObj['self'] && globalObj['WorkerGlobalScope'] && !globalObj['window']) {
77
82
  return MakerJs.environmentTypes.WebWorker;
78
83
  }
79
- if (tryEval('window') && tryEval('document')) {
84
+ // Check for Browser UI environment
85
+ if (globalObj['window'] && globalObj['document']) {
80
86
  return MakerJs.environmentTypes.BrowserUI;
81
87
  }
82
88
  //put node last since packagers usually add shims for it
83
- if (tryEval('global') && tryEval('process')) {
89
+ if (globalObj['global'] && globalObj['process']) {
84
90
  return MakerJs.environmentTypes.NodeJs;
85
91
  }
86
92
  return MakerJs.environmentTypes.Unknown;
@@ -245,7 +251,9 @@ var MakerJs;
245
251
  function extendObject(target, other) {
246
252
  if (target && other) {
247
253
  for (var key in other) {
248
- if (typeof other[key] !== 'undefined') {
254
+ if (other.hasOwnProperty(key) && typeof other[key] !== 'undefined') {
255
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype')
256
+ continue;
249
257
  target[key] = other[key];
250
258
  }
251
259
  }
@@ -7167,20 +7175,29 @@ var MakerJs;
7167
7175
  /**
7168
7176
  * Convert a chain to SVG path data.
7169
7177
  *
7170
- * @param chain Chain to convert.
7178
+ * @param c Chain to convert.
7171
7179
  * @param offset IPoint relative offset point.
7172
7180
  * @param accuracy Optional accuracy of SVG path data.
7181
+ * @param clockwise Optional flag to specify desired winding direction for nonzero fill rule.
7173
7182
  * @returns String of SVG path data.
7174
7183
  */
7175
- function chainToSVGPathData(chain, offset, accuracy) {
7184
+ function chainToSVGPathData(c, offset, accuracy, clockwise) {
7176
7185
  function offsetPoint(p) {
7177
7186
  return MakerJs.point.add(p, offset);
7178
7187
  }
7179
- var first = chain.links[0];
7188
+ // If clockwise direction is specified, check if chain needs to be reversed
7189
+ if (clockwise !== undefined) {
7190
+ var isClockwise = MakerJs.measure.isChainClockwise(c);
7191
+ if (isClockwise !== null && isClockwise !== clockwise) {
7192
+ c = MakerJs.cloneObject(c);
7193
+ MakerJs.chain.reverse(c);
7194
+ }
7195
+ }
7196
+ var first = c.links[0];
7180
7197
  var firstPoint = offsetPoint(svgCoords(first.endPoints[first.reversed ? 1 : 0]));
7181
7198
  var d = ['M', MakerJs.round(firstPoint[0], accuracy), MakerJs.round(firstPoint[1], accuracy)];
7182
- for (var i = 0; i < chain.links.length; i++) {
7183
- var link = chain.links[i];
7199
+ for (var i = 0; i < c.links.length; i++) {
7200
+ var link = c.links[i];
7184
7201
  var pathContext = link.walkedPath.pathContext;
7185
7202
  var fn = chainLinkToPathDataMap[pathContext.type];
7186
7203
  if (fn) {
@@ -7192,7 +7209,7 @@ var MakerJs;
7192
7209
  fn(fixedPath, offsetPoint(svgCoords(link.endPoints[link.reversed ? 0 : 1])), link.reversed, d, accuracy);
7193
7210
  }
7194
7211
  }
7195
- if (chain.endless) {
7212
+ if (c.endless) {
7196
7213
  d.push('Z');
7197
7214
  }
7198
7215
  return d.join(' ');
@@ -7268,16 +7285,16 @@ var MakerJs;
7268
7285
  }
7269
7286
  pathDataByLayer[layer] = [];
7270
7287
  function doChains(cs, clockwise) {
7271
- cs.forEach(function (chain) {
7272
- if (chain.links.length > 1) {
7273
- var pathData = chainToSVGPathData(chain, offset, accuracy);
7288
+ cs.forEach(function (c) {
7289
+ if (c.links.length > 1) {
7290
+ var pathData = chainToSVGPathData(c, offset, accuracy, clockwise);
7274
7291
  pathDataByLayer[layer].push(pathData);
7275
7292
  }
7276
7293
  else {
7277
- single(chain.links[0].walkedPath, clockwise);
7294
+ single(c.links[0].walkedPath, clockwise);
7278
7295
  }
7279
- if (chain.contains) {
7280
- doChains(chain.contains, !clockwise);
7296
+ if (c.contains) {
7297
+ doChains(c.contains, !clockwise);
7281
7298
  }
7282
7299
  });
7283
7300
  }
@@ -9807,6 +9824,7 @@ var MakerJs;
9807
9824
  ];
9808
9825
  })(models = MakerJs.models || (MakerJs.models = {}));
9809
9826
  })(MakerJs || (MakerJs = {}));
9827
+ /// <reference types="fontkit" />
9810
9828
  var MakerJs;
9811
9829
  (function (MakerJs) {
9812
9830
  var models;
@@ -9814,13 +9832,13 @@ var MakerJs;
9814
9832
  var Text = /** @class */ (function () {
9815
9833
  /**
9816
9834
  * Renders text in a given font to a model.
9817
- * @param font OpenType.Font object.
9835
+ * @param font OpenType.Font object or fontkit font object.
9818
9836
  * @param text String of text to render.
9819
9837
  * @param fontSize Font size.
9820
9838
  * @param combine Flag (default false) to perform a combineUnion upon each character with characters to the left and right.
9821
9839
  * @param centerCharacterOrigin Flag (default false) to move the x origin of each character to the center. Useful for rotating text characters.
9822
9840
  * @param bezierAccuracy Optional accuracy of Bezier curves.
9823
- * @param opentypeOptions Optional opentype.RenderOptions object.
9841
+ * @param opentypeOptions Optional opentype.RenderOptions object or fontkit layout options.
9824
9842
  * @returns Model of the text.
9825
9843
  */
9826
9844
  function Text(font, text, fontSize, combine, centerCharacterOrigin, bezierAccuracy, opentypeOptions) {
@@ -9832,7 +9850,7 @@ var MakerJs;
9832
9850
  var prevDeleted;
9833
9851
  var prevChar;
9834
9852
  var cb = function (glyph, x, y, _fontSize, options) {
9835
- var charModel = Text.glyphToModel(glyph, _fontSize, bezierAccuracy);
9853
+ var charModel = Text.glyphToModel(glyph, _fontSize, bezierAccuracy, font);
9836
9854
  charModel.origin = [x, 0];
9837
9855
  if (centerCharacterOrigin && (charModel.paths || charModel.models)) {
9838
9856
  var m = MakerJs.measure.modelExtents(charModel);
@@ -9864,62 +9882,227 @@ var MakerJs;
9864
9882
  charIndex++;
9865
9883
  prevChar = charModel;
9866
9884
  };
9867
- font.forEachGlyph(text, 0, 0, fontSize, opentypeOptions, cb);
9885
+ // Detect if font is fontkit (has layout method) or opentype.js (has forEachGlyph)
9886
+ if (font.layout && typeof font.layout === 'function') {
9887
+ // fontkit font - use layout engine
9888
+ var fontkitFont = font;
9889
+ var layoutOpts = opentypeOptions;
9890
+ var run = fontkitFont.layout(text, layoutOpts === null || layoutOpts === void 0 ? void 0 : layoutOpts.features, layoutOpts === null || layoutOpts === void 0 ? void 0 : layoutOpts.script, layoutOpts === null || layoutOpts === void 0 ? void 0 : layoutOpts.language, layoutOpts === null || layoutOpts === void 0 ? void 0 : layoutOpts.direction);
9891
+ var scale = fontSize / fontkitFont.unitsPerEm;
9892
+ var currentX = 0;
9893
+ for (var i = 0; i < run.glyphs.length; i++) {
9894
+ var glyph = run.glyphs[i];
9895
+ var position = run.positions[i];
9896
+ var glyphX = currentX + (position.xOffset || 0) * scale;
9897
+ var glyphY = (position.yOffset || 0) * scale;
9898
+ cb(glyph, glyphX, glyphY, fontSize, opentypeOptions);
9899
+ currentX += (position.xAdvance || 0) * scale;
9900
+ }
9901
+ }
9902
+ else {
9903
+ // opentype.js font - use forEachGlyph
9904
+ var opentypeFont = font;
9905
+ opentypeFont.forEachGlyph(text, 0, 0, fontSize, opentypeOptions, cb);
9906
+ }
9868
9907
  }
9869
9908
  /**
9870
- * Convert an opentype glyph to a model.
9871
- * @param glyph Opentype.Glyph object.
9909
+ * Convert an opentype glyph or fontkit glyph to a model.
9910
+ * @param glyph Opentype.Glyph object or fontkit glyph.
9872
9911
  * @param fontSize Font size.
9873
9912
  * @param bezierAccuracy Optional accuracy of Bezier curves.
9913
+ * @param font Optional font object (needed for fontkit to get scale).
9874
9914
  * @returns Model of the glyph.
9875
9915
  */
9876
- Text.glyphToModel = function (glyph, fontSize, bezierAccuracy) {
9916
+ Text.glyphToModel = function (glyph, fontSize, bezierAccuracy, font) {
9877
9917
  var charModel = {};
9878
9918
  var firstPoint;
9879
9919
  var currPoint;
9880
9920
  var pathCount = 0;
9881
- function addPath(p) {
9921
+ function addPath(p, layer) {
9882
9922
  if (!charModel.paths) {
9883
9923
  charModel.paths = {};
9884
9924
  }
9925
+ if (layer) {
9926
+ if (!charModel.layer)
9927
+ charModel.layer = layer;
9928
+ }
9885
9929
  charModel.paths['p_' + ++pathCount] = p;
9886
9930
  }
9887
- function addModel(m) {
9931
+ function addModel(m, layer) {
9888
9932
  if (!charModel.models) {
9889
9933
  charModel.models = {};
9890
9934
  }
9935
+ if (layer) {
9936
+ if (!charModel.layer)
9937
+ charModel.layer = layer;
9938
+ }
9891
9939
  charModel.models['p_' + ++pathCount] = m;
9892
9940
  }
9893
- var p = glyph.getPath(0, 0, fontSize);
9894
- p.commands.map(function (command, i) {
9895
- var points = [[command.x, command.y], [command.x1, command.y1], [command.x2, command.y2]].map(function (p) {
9896
- if (p[0] !== void 0) {
9897
- return MakerJs.point.mirror(p, false, true);
9898
- }
9899
- });
9900
- switch (command.type) {
9901
- case 'M':
9902
- firstPoint = points[0];
9903
- break;
9904
- case 'Z':
9905
- points[0] = firstPoint;
9906
- //fall through to line
9907
- case 'L':
9908
- if (!MakerJs.measure.isPointEqual(currPoint, points[0])) {
9909
- addPath(new MakerJs.paths.Line(currPoint, points[0]));
9941
+ // Detect if this is a fontkit glyph (has path property) or opentype.js glyph (has getPath method)
9942
+ var isFontkitGlyph = glyph.path && !glyph.getPath;
9943
+ var p;
9944
+ if (isFontkitGlyph && font) {
9945
+ // fontkit glyph
9946
+ var scale_1 = fontSize / font.unitsPerEm;
9947
+ p = glyph.path;
9948
+ // Check for color layers (COLR table support)
9949
+ if (glyph.layers && glyph.layers.length > 0) {
9950
+ // Handle color glyph with layers
9951
+ glyph.layers.forEach(function (layer, layerIndex) {
9952
+ var layerGlyph = font.getGlyph(layer.glyph);
9953
+ var layerPath = layerGlyph.path;
9954
+ if (layerPath && layerPath.commands) {
9955
+ // Get color from palette if available
9956
+ var layerColor = void 0;
9957
+ if (font['COLR'] && font['CPAL'] && layer.color !== undefined) {
9958
+ // CPAL table structure varies, try to access color palettes
9959
+ var cpal = font['CPAL'];
9960
+ var colorPalettes = cpal.colorPalettes || cpal.colorRecords;
9961
+ if (colorPalettes && colorPalettes.length > 0) {
9962
+ // Get the first palette
9963
+ var palette = colorPalettes[0];
9964
+ if (palette && palette.length > layer.color) {
9965
+ var color = palette[layer.color];
9966
+ if (color) {
9967
+ // Convert RGBA to hex color for layer name
9968
+ var red = color.red !== undefined ? color.red : color.r || 0;
9969
+ var green = color.green !== undefined ? color.green : color.g || 0;
9970
+ var blue = color.blue !== undefined ? color.blue : color.b || 0;
9971
+ layerColor = "color_".concat(red.toString(16).padStart(2, '0')).concat(green.toString(16).padStart(2, '0')).concat(blue.toString(16).padStart(2, '0'));
9972
+ }
9973
+ }
9974
+ }
9975
+ }
9976
+ // Process layer path commands
9977
+ var layerFirstPoint = void 0;
9978
+ var layerCurrPoint = void 0;
9979
+ for (var _i = 0, _a = layerPath.commands; _i < _a.length; _i++) {
9980
+ var cmd = _a[_i];
9981
+ var points = Text.convertFontkitCommand(cmd, scale_1);
9982
+ switch (cmd.command) {
9983
+ case 'moveTo':
9984
+ layerFirstPoint = points[0];
9985
+ layerCurrPoint = points[0];
9986
+ break;
9987
+ case 'closePath':
9988
+ points[0] = layerFirstPoint;
9989
+ // fall through to line
9990
+ case 'lineTo':
9991
+ if (layerCurrPoint && !MakerJs.measure.isPointEqual(layerCurrPoint, points[0])) {
9992
+ addPath(new MakerJs.paths.Line(layerCurrPoint, points[0]), layerColor);
9993
+ }
9994
+ layerCurrPoint = points[0];
9995
+ break;
9996
+ case 'bezierCurveTo':
9997
+ if (layerCurrPoint) {
9998
+ addModel(new models.BezierCurve(layerCurrPoint, points[0], points[1], points[2], bezierAccuracy), layerColor);
9999
+ }
10000
+ layerCurrPoint = points[2];
10001
+ break;
10002
+ case 'quadraticCurveTo':
10003
+ if (layerCurrPoint) {
10004
+ addModel(new models.BezierCurve(layerCurrPoint, points[0], points[1], bezierAccuracy), layerColor);
10005
+ }
10006
+ layerCurrPoint = points[1];
10007
+ break;
10008
+ }
10009
+ }
9910
10010
  }
9911
- break;
9912
- case 'C':
9913
- addModel(new models.BezierCurve(currPoint, points[1], points[2], points[0], bezierAccuracy));
9914
- break;
9915
- case 'Q':
9916
- addModel(new models.BezierCurve(currPoint, points[1], points[0], bezierAccuracy));
9917
- break;
10011
+ });
10012
+ return charModel;
10013
+ }
10014
+ // Standard fontkit glyph (no color layers)
10015
+ if (!p || !p.commands) {
10016
+ return charModel; // Empty glyph (e.g., space)
10017
+ }
10018
+ for (var _i = 0, _a = p.commands; _i < _a.length; _i++) {
10019
+ var cmd = _a[_i];
10020
+ var points = Text.convertFontkitCommand(cmd, scale_1);
10021
+ switch (cmd.command) {
10022
+ case 'moveTo':
10023
+ firstPoint = points[0];
10024
+ currPoint = points[0];
10025
+ break;
10026
+ case 'closePath':
10027
+ points[0] = firstPoint;
10028
+ // fall through to line
10029
+ case 'lineTo':
10030
+ if (!MakerJs.measure.isPointEqual(currPoint, points[0])) {
10031
+ addPath(new MakerJs.paths.Line(currPoint, points[0]));
10032
+ }
10033
+ currPoint = points[0];
10034
+ break;
10035
+ case 'bezierCurveTo':
10036
+ addModel(new models.BezierCurve(currPoint, points[0], points[1], points[2], bezierAccuracy));
10037
+ currPoint = points[2];
10038
+ break;
10039
+ case 'quadraticCurveTo':
10040
+ addModel(new models.BezierCurve(currPoint, points[0], points[1], bezierAccuracy));
10041
+ currPoint = points[1];
10042
+ break;
10043
+ }
9918
10044
  }
9919
- currPoint = points[0];
9920
- });
10045
+ }
10046
+ else {
10047
+ // opentype.js glyph
10048
+ p = glyph.getPath(0, 0, fontSize);
10049
+ p.commands.map(function (command, i) {
10050
+ var points = [[command.x, command.y], [command.x1, command.y1], [command.x2, command.y2]].map(function (p) {
10051
+ if (p[0] !== void 0) {
10052
+ return MakerJs.point.mirror(p, false, true);
10053
+ }
10054
+ });
10055
+ switch (command.type) {
10056
+ case 'M':
10057
+ firstPoint = points[0];
10058
+ break;
10059
+ case 'Z':
10060
+ points[0] = firstPoint;
10061
+ //fall through to line
10062
+ case 'L':
10063
+ if (!MakerJs.measure.isPointEqual(currPoint, points[0])) {
10064
+ addPath(new MakerJs.paths.Line(currPoint, points[0]));
10065
+ }
10066
+ break;
10067
+ case 'C':
10068
+ addModel(new models.BezierCurve(currPoint, points[1], points[2], points[0], bezierAccuracy));
10069
+ break;
10070
+ case 'Q':
10071
+ addModel(new models.BezierCurve(currPoint, points[1], points[0], bezierAccuracy));
10072
+ break;
10073
+ }
10074
+ currPoint = points[0];
10075
+ });
10076
+ }
9921
10077
  return charModel;
9922
10078
  };
10079
+ /**
10080
+ * Convert fontkit path command to points array
10081
+ * @param cmd Fontkit path command
10082
+ * @param scale Scale factor
10083
+ * @returns Array of points
10084
+ */
10085
+ Text.convertFontkitCommand = function (cmd, scale) {
10086
+ var points = [];
10087
+ switch (cmd.command) {
10088
+ case 'moveTo':
10089
+ case 'lineTo':
10090
+ points.push([cmd.args[0] * scale, cmd.args[1] * scale]);
10091
+ break;
10092
+ case 'quadraticCurveTo':
10093
+ // Control point, end point
10094
+ points.push([cmd.args[0] * scale, cmd.args[1] * scale]);
10095
+ points.push([cmd.args[2] * scale, cmd.args[3] * scale]);
10096
+ break;
10097
+ case 'bezierCurveTo':
10098
+ // Control point 1, control point 2, end point
10099
+ points.push([cmd.args[0] * scale, cmd.args[1] * scale]);
10100
+ points.push([cmd.args[2] * scale, cmd.args[3] * scale]);
10101
+ points.push([cmd.args[4] * scale, cmd.args[5] * scale]);
10102
+ break;
10103
+ }
10104
+ return points;
10105
+ };
9923
10106
  return Text;
9924
10107
  }());
9925
10108
  models.Text = Text;
@@ -9932,5 +10115,5 @@ var MakerJs;
9932
10115
  ];
9933
10116
  })(models = MakerJs.models || (MakerJs.models = {}));
9934
10117
  })(MakerJs || (MakerJs = {}));
9935
- MakerJs.version = "0.18.2";
10118
+ MakerJs.version = "0.19.2";
9936
10119
  var Bezier = require('bezier-js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makerjs",
3
- "version": "0.18.2",
3
+ "version": "0.19.2",
4
4
  "description": "Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -102,6 +102,7 @@
102
102
  "dependencies": {
103
103
  "@danmarshall/jscad-typings": "^1.0.0",
104
104
  "@types/bezier-js": "^0.0.6",
105
+ "@types/fontkit": "^2.0.8",
105
106
  "@types/node": "^7.0.5",
106
107
  "@types/opentype.js": "^0.7.0",
107
108
  "@types/pdfkit": "^0.7.34",
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "{}"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2015-2016 Microsoft
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-