@xpadev-net/niconicomments 0.2.28 → 0.2.29
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/bundle.d.ts +5 -3
- package/dist/bundle.js +153 -144
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -61,8 +61,9 @@ declare let imageCache: {
|
|
|
61
61
|
declare const resetImageCache: () => void;
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
declare
|
|
65
|
-
declare
|
|
64
|
+
declare let canvas: HTMLCanvasElement;
|
|
65
|
+
declare let context: CanvasRenderingContext2D;
|
|
66
|
+
declare const initCanvas: () => void;
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
declare let nicoScripts: nicoScript;
|
|
@@ -100,7 +101,8 @@ declare const colors: {
|
|
|
100
101
|
};
|
|
101
102
|
|
|
102
103
|
|
|
103
|
-
declare
|
|
104
|
+
declare let defaultConfig: Config;
|
|
105
|
+
declare const initConfig: () => void;
|
|
104
106
|
declare const defaultOptions: Options;
|
|
105
107
|
declare let config: Config;
|
|
106
108
|
declare let options: Options;
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.29
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -752,159 +752,162 @@
|
|
|
752
752
|
black2: "#666666",
|
|
753
753
|
};
|
|
754
754
|
|
|
755
|
-
var
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
html5: {
|
|
783
|
-
width: 512,
|
|
784
|
-
fullWidth: 683,
|
|
785
|
-
height: 384,
|
|
755
|
+
var defaultConfig;
|
|
756
|
+
var initConfig = function () {
|
|
757
|
+
var platform = (function (ua) {
|
|
758
|
+
if (ua.match(/windows nt 6\.[12]/i))
|
|
759
|
+
return "win7";
|
|
760
|
+
else if (ua.match(/windows nt (6\.3|10\.\d+)/i))
|
|
761
|
+
return "win8_1";
|
|
762
|
+
else if (ua.match(/windows nt/i))
|
|
763
|
+
return "win";
|
|
764
|
+
else if (ua.match(/mac os x 10(.|_)(9|10)/i))
|
|
765
|
+
return "mac10_9";
|
|
766
|
+
else if (ua.match(/mac os x 10(.|_)\d{2}/i))
|
|
767
|
+
return "mac10_11";
|
|
768
|
+
else if (ua.match(/mac os x/i))
|
|
769
|
+
return "mac";
|
|
770
|
+
return "other";
|
|
771
|
+
})(navigator.userAgent);
|
|
772
|
+
defaultConfig = {
|
|
773
|
+
colors: colors,
|
|
774
|
+
contextStrokeColor: "#000000",
|
|
775
|
+
contextStrokeInversionColor: "#FFFFFF",
|
|
776
|
+
contextStrokeOpacity: 0.4,
|
|
777
|
+
contextFillLiveOpacity: 0.5,
|
|
778
|
+
contextLineWidth: 2.8,
|
|
779
|
+
commentScale: {
|
|
780
|
+
html5: 1920 / 683,
|
|
781
|
+
flash: 1920 / 683,
|
|
786
782
|
},
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
783
|
+
commentStageSize: {
|
|
784
|
+
html5: {
|
|
785
|
+
width: 512,
|
|
786
|
+
fullWidth: 683,
|
|
787
|
+
height: 384,
|
|
788
|
+
},
|
|
789
|
+
flash: {
|
|
790
|
+
width: 512,
|
|
791
|
+
fullWidth: 610,
|
|
792
|
+
height: 385,
|
|
793
|
+
},
|
|
791
794
|
},
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
795
|
+
fontSize: {
|
|
796
|
+
html5: {
|
|
797
|
+
small: {
|
|
798
|
+
default: 18,
|
|
799
|
+
resized: 10,
|
|
800
|
+
},
|
|
801
|
+
medium: {
|
|
802
|
+
default: 27,
|
|
803
|
+
resized: 14,
|
|
804
|
+
},
|
|
805
|
+
big: {
|
|
806
|
+
default: 39,
|
|
807
|
+
resized: 20,
|
|
808
|
+
},
|
|
798
809
|
},
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
810
|
+
flash: {
|
|
811
|
+
small: {
|
|
812
|
+
default: 15,
|
|
813
|
+
resized: 7.5,
|
|
814
|
+
},
|
|
815
|
+
medium: {
|
|
816
|
+
default: 24,
|
|
817
|
+
resized: 12,
|
|
818
|
+
},
|
|
819
|
+
big: {
|
|
820
|
+
default: 31.4,
|
|
821
|
+
resized: 20,
|
|
822
|
+
},
|
|
802
823
|
},
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
824
|
+
},
|
|
825
|
+
lineCounts: {
|
|
826
|
+
default: {
|
|
827
|
+
big: 8.4,
|
|
828
|
+
medium: 13.1,
|
|
829
|
+
small: 21,
|
|
830
|
+
},
|
|
831
|
+
resized: {
|
|
832
|
+
big: 16,
|
|
833
|
+
medium: 25.4,
|
|
834
|
+
small: 38,
|
|
806
835
|
},
|
|
836
|
+
doubleResized: {
|
|
837
|
+
big: 7.8,
|
|
838
|
+
medium: 11.3,
|
|
839
|
+
small: 16.6,
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
hiResCommentCorrection: 20,
|
|
843
|
+
minFontSize: 10,
|
|
844
|
+
fonts: fonts[platform],
|
|
845
|
+
fpsInterval: 500,
|
|
846
|
+
cacheAge: 2000,
|
|
847
|
+
canvasWidth: 1920,
|
|
848
|
+
canvasHeight: 1080,
|
|
849
|
+
commentDrawRange: 1450,
|
|
850
|
+
commentDrawPadding: 235,
|
|
851
|
+
collisionRange: {
|
|
852
|
+
left: 235,
|
|
853
|
+
right: 1685,
|
|
854
|
+
},
|
|
855
|
+
sameCARange: 3600,
|
|
856
|
+
sameCAGap: 100,
|
|
857
|
+
sameCAMinScore: 10,
|
|
858
|
+
flashThreshold: 1499871600,
|
|
859
|
+
flashChar: {
|
|
860
|
+
gulim: "[\u0126\u0127\u0132\u0133\u0138\u013f\u0140\u0149-\u014b\u0166\u0167\u02d0\u02da\u2074\u207f\u2081-\u2084\u2113\u2153\u2154\u215c-\u215e\u2194\u2195\u223c\u249c-\u24b5\u24d0-\u24e9\u25a3-\u25a9\u25b6\u25b7\u25c0\u25c1\u25c8\u25d0\u25d1\u260e\u260f\u261c\u261e\u2660\u2661\u2663-\u2665\u2667-\u2669\u266c\u3131-\u316e\u3200-\u321c\u3260-\u327b\u3380-\u3384\u3388-\u338d\u3390-\u339b\u339f\u33a0\u33a2-\u33ca\u33cf\u33d0\u33d3\u33d6\u33d8\u33db-\u33dd\uf900-\uf928\uf92a-\uf994\uf996\ufa0b\uffe6]",
|
|
861
|
+
simsunStrong: "[\u01ce\u01d0\u01d2\u01d4\u01d6\u01d8\u01da\u01dc\u0251\u0261\u02ca\u02cb\u2016\u2035\u216a\u216b\u2223\u2236\u2237\u224c\u226e\u226f\u2295\u2483-\u249b\u2504-\u250b\u256d-\u2573\u2581-\u2583\u2585-\u2587\u2589-\u258b\u258d-\u258f\u2594\u2595\u25e2-\u25e5\u2609\u3016\u3017\u301e\u3021-\u3029\u3105-\u3129\u3220-\u3229\u32a3\u33ce\u33d1\u33d2\u33d5\ue758-\ue864\ufa0c\ufa0d\ufe30\ufe31\ufe33-\ufe44\ufe49-\ufe52\ufe54-\ufe57\ufe59-\ufe66\ufe68-\ufe6b]",
|
|
862
|
+
simsunWeak: "[\u02c9\u2105\u2109\u2196-\u2199\u220f\u2215\u2248\u2264\u2265\u2299\u2474-\u2482\u250d\u250e\u2511\u2512\u2515\u2516\u2519\u251a\u251e\u251f\u2521\u2522\u2526\u2527\u2529\u252a\u252d\u252e\u2531\u2532\u2535\u2536\u2539\u253a\u253d\u253e\u2540\u2541\u2543-\u254a\u2550-\u256c\u2584\u2588\u258c\u2593]",
|
|
863
|
+
gothic: "[\u03fb\uff9f]",
|
|
864
|
+
},
|
|
865
|
+
flashMode: "vista",
|
|
866
|
+
flashScriptChar: {
|
|
867
|
+
super: "[\u00aa\u00b2\u00b3\u00b9\u00ba\u02b0\u02b2\u02b3\u02b7\u02b8\u02e1-\u02e3\u0304\u1d2c-\u1d43\u1d45-\u1d61\u1d9b-\u1da1\u1da3-\u1dbf\u2070\u2071\u2074-\u207f\u2c7d]",
|
|
868
|
+
sub: "[\u0320\u1d62-\u1d6a\u2080-\u208e\u2090-\u209c\u2c7c]",
|
|
807
869
|
},
|
|
808
|
-
|
|
870
|
+
font: {
|
|
871
|
+
gulim: 'normal 600 [size]px gulim, "Microsoft JhengHei UI", Arial, "MS Pゴシック", "MS PGothic", MSPGothic, MS-PGothic',
|
|
872
|
+
simsun: 'normal 400 [size]px simsun, "游明朝体", "游明朝", "Yu Mincho", YuMincho, yumincho, YuMin-Medium',
|
|
873
|
+
},
|
|
874
|
+
lineHeight: {
|
|
809
875
|
small: {
|
|
810
|
-
default:
|
|
811
|
-
resized:
|
|
876
|
+
default: 1.1,
|
|
877
|
+
resized: 1,
|
|
812
878
|
},
|
|
813
879
|
medium: {
|
|
814
|
-
default:
|
|
815
|
-
resized:
|
|
880
|
+
default: 1.1,
|
|
881
|
+
resized: 1,
|
|
816
882
|
},
|
|
817
883
|
big: {
|
|
818
|
-
default:
|
|
819
|
-
resized:
|
|
884
|
+
default: 1.06,
|
|
885
|
+
resized: 1.1,
|
|
820
886
|
},
|
|
821
887
|
},
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
big: 8.4,
|
|
826
|
-
medium: 13.1,
|
|
827
|
-
small: 21,
|
|
828
|
-
},
|
|
829
|
-
resized: {
|
|
830
|
-
big: 16,
|
|
831
|
-
medium: 25.4,
|
|
832
|
-
small: 38,
|
|
833
|
-
},
|
|
834
|
-
doubleResized: {
|
|
835
|
-
big: 7.8,
|
|
836
|
-
medium: 11.3,
|
|
837
|
-
small: 16.6,
|
|
838
|
-
},
|
|
839
|
-
},
|
|
840
|
-
hiResCommentCorrection: 20,
|
|
841
|
-
minFontSize: 10,
|
|
842
|
-
fonts: fonts[platform],
|
|
843
|
-
fpsInterval: 500,
|
|
844
|
-
cacheAge: 2000,
|
|
845
|
-
canvasWidth: 1920,
|
|
846
|
-
canvasHeight: 1080,
|
|
847
|
-
commentDrawRange: 1450,
|
|
848
|
-
commentDrawPadding: 235,
|
|
849
|
-
collisionRange: {
|
|
850
|
-
left: 235,
|
|
851
|
-
right: 1685,
|
|
852
|
-
},
|
|
853
|
-
sameCARange: 3600,
|
|
854
|
-
sameCAGap: 100,
|
|
855
|
-
sameCAMinScore: 10,
|
|
856
|
-
flashThreshold: 1499871600,
|
|
857
|
-
flashChar: {
|
|
858
|
-
gulim: "[\u0126\u0127\u0132\u0133\u0138\u013f\u0140\u0149-\u014b\u0166\u0167\u02d0\u02da\u2074\u207f\u2081-\u2084\u2113\u2153\u2154\u215c-\u215e\u2194\u2195\u223c\u249c-\u24b5\u24d0-\u24e9\u25a3-\u25a9\u25b6\u25b7\u25c0\u25c1\u25c8\u25d0\u25d1\u260e\u260f\u261c\u261e\u2660\u2661\u2663-\u2665\u2667-\u2669\u266c\u3131-\u316e\u3200-\u321c\u3260-\u327b\u3380-\u3384\u3388-\u338d\u3390-\u339b\u339f\u33a0\u33a2-\u33ca\u33cf\u33d0\u33d3\u33d6\u33d8\u33db-\u33dd\uf900-\uf928\uf92a-\uf994\uf996\ufa0b\uffe6]",
|
|
859
|
-
simsunStrong: "[\u01ce\u01d0\u01d2\u01d4\u01d6\u01d8\u01da\u01dc\u0251\u0261\u02ca\u02cb\u2016\u2035\u216a\u216b\u2223\u2236\u2237\u224c\u226e\u226f\u2295\u2483-\u249b\u2504-\u250b\u256d-\u2573\u2581-\u2583\u2585-\u2587\u2589-\u258b\u258d-\u258f\u2594\u2595\u25e2-\u25e5\u2609\u3016\u3017\u301e\u3021-\u3029\u3105-\u3129\u3220-\u3229\u32a3\u33ce\u33d1\u33d2\u33d5\ue758-\ue864\ufa0c\ufa0d\ufe30\ufe31\ufe33-\ufe44\ufe49-\ufe52\ufe54-\ufe57\ufe59-\ufe66\ufe68-\ufe6b]",
|
|
860
|
-
simsunWeak: "[\u02c9\u2105\u2109\u2196-\u2199\u220f\u2215\u2248\u2264\u2265\u2299\u2474-\u2482\u250d\u250e\u2511\u2512\u2515\u2516\u2519\u251a\u251e\u251f\u2521\u2522\u2526\u2527\u2529\u252a\u252d\u252e\u2531\u2532\u2535\u2536\u2539\u253a\u253d\u253e\u2540\u2541\u2543-\u254a\u2550-\u256c\u2584\u2588\u258c\u2593]",
|
|
861
|
-
gothic: "[\u03fb\uff9f]",
|
|
862
|
-
},
|
|
863
|
-
flashMode: "vista",
|
|
864
|
-
flashScriptChar: {
|
|
865
|
-
super: "[\u00aa\u00b2\u00b3\u00b9\u00ba\u02b0\u02b2\u02b3\u02b7\u02b8\u02e1-\u02e3\u0304\u1d2c-\u1d43\u1d45-\u1d61\u1d9b-\u1da1\u1da3-\u1dbf\u2070\u2071\u2074-\u207f\u2c7d]",
|
|
866
|
-
sub: "[\u0320\u1d62-\u1d6a\u2080-\u208e\u2090-\u209c\u2c7c]",
|
|
867
|
-
},
|
|
868
|
-
font: {
|
|
869
|
-
gulim: 'normal 600 [size]px gulim, "Microsoft JhengHei UI", Arial, "MS Pゴシック", "MS PGothic", MSPGothic, MS-PGothic',
|
|
870
|
-
simsun: 'normal 400 [size]px simsun, "游明朝体", "游明朝", "Yu Mincho", YuMincho, yumincho, YuMin-Medium',
|
|
871
|
-
},
|
|
872
|
-
lineHeight: {
|
|
873
|
-
small: {
|
|
874
|
-
default: 1.1,
|
|
875
|
-
resized: 1,
|
|
888
|
+
doubleResizeMaxWidth: {
|
|
889
|
+
full: 1200,
|
|
890
|
+
normal: 940,
|
|
876
891
|
},
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
892
|
+
commentYPaddingTop: {
|
|
893
|
+
small: 0.126,
|
|
894
|
+
medium: 0.07,
|
|
895
|
+
big: 0.126,
|
|
880
896
|
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
897
|
+
commentYMarginBottom: {
|
|
898
|
+
small: 0.24,
|
|
899
|
+
medium: 0.28,
|
|
900
|
+
big: 0.24,
|
|
884
901
|
},
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
medium: 0.07,
|
|
893
|
-
big: 0.126,
|
|
894
|
-
},
|
|
895
|
-
commentYMarginBottom: {
|
|
896
|
-
small: 0.24,
|
|
897
|
-
medium: 0.28,
|
|
898
|
-
big: 0.24,
|
|
899
|
-
},
|
|
900
|
-
commentYOffset: {
|
|
901
|
-
small: { default: 0, resized: 0 },
|
|
902
|
-
medium: { default: 0, resized: 0 },
|
|
903
|
-
big: {
|
|
904
|
-
default: -1 / 22,
|
|
905
|
-
resized: 0,
|
|
902
|
+
commentYOffset: {
|
|
903
|
+
small: { default: 0, resized: 0 },
|
|
904
|
+
medium: { default: 0, resized: 0 },
|
|
905
|
+
big: {
|
|
906
|
+
default: -1 / 22,
|
|
907
|
+
resized: 0,
|
|
908
|
+
},
|
|
906
909
|
},
|
|
907
|
-
}
|
|
910
|
+
};
|
|
908
911
|
};
|
|
909
912
|
var defaultOptions = {
|
|
910
913
|
config: {},
|
|
@@ -1090,13 +1093,17 @@
|
|
|
1090
1093
|
};
|
|
1091
1094
|
};
|
|
1092
1095
|
|
|
1093
|
-
var canvas
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1096
|
+
var canvas;
|
|
1097
|
+
var context;
|
|
1098
|
+
var initCanvas = function () {
|
|
1099
|
+
canvas = document.createElement("canvas");
|
|
1100
|
+
var _context = canvas.getContext("2d");
|
|
1101
|
+
if (_context === null)
|
|
1102
|
+
throw new Error("fail to get Context2D");
|
|
1103
|
+
var context = _context;
|
|
1104
|
+
context.textAlign = "start";
|
|
1105
|
+
context.textBaseline = "alphabetic";
|
|
1106
|
+
};
|
|
1100
1107
|
|
|
1101
1108
|
var getLineHeight = function (fontSize, isFlash, resized) {
|
|
1102
1109
|
if (resized === void 0) { resized = false; }
|
|
@@ -2537,6 +2544,8 @@
|
|
|
2537
2544
|
function NiconiComments(canvas, data, initOptions) {
|
|
2538
2545
|
if (initOptions === void 0) { initOptions = {}; }
|
|
2539
2546
|
var constructorStart = performance.now();
|
|
2547
|
+
initConfig();
|
|
2548
|
+
initCanvas();
|
|
2540
2549
|
if (!typeGuard.config.initOptions(initOptions))
|
|
2541
2550
|
throw new Error("Please see document: https://xpadev-net.github.io/niconicomments/#p_options");
|
|
2542
2551
|
setOptions(Object.assign(defaultOptions, initOptions));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"types": "dist/bundle.d.ts",
|