Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit 14d0730

Browse files
committed
docs: fix bugs, update
1 parent 093ee10 commit 14d0730

File tree

9 files changed

+3559
-5404
lines changed

9 files changed

+3559
-5404
lines changed

ghpages/docs/ast/source/index.js.json

Lines changed: 616 additions & 616 deletions
Large diffs are not rendered by default.

ghpages/docs/ast/source/wpPublicPath.js.json

Lines changed: 2693 additions & 4594 deletions
Large diffs are not rendered by default.

ghpages/docs/file/src/index.js.html

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,29 @@
6464

6565
/**
6666
* The public entry point
67-
* @param {Object} [userConfig] User's custom config
68-
* @param {String} [model.jsonPath = ''] Path to Live2D model's main json eg. https://test.com/miku.model.json
69-
* @param {Number} [model.scale = 1] Scale between the model and the canvas
70-
* @param {Number} [model.hHeadPos = 0.5] Horizontal position of model's head
71-
* @param {Number} [model.vHeadPos = 0.618] Vertical position of model's head
72-
* @param {Array} [model.myDefine = []] User's custom Defines which will override LDefine
73-
* @param {Number} [display.AA = 2] Antialiasing grade
74-
* @param {Number} [display.widget = 150] Widget to the canvas which shows the model
75-
* @param {Number} [display.height = 300] Height to the canvas which shows the model
76-
* @param {String} [display.position = 'right'] Left of right side to show
77-
* @param {Number} [display.hOffset = 0] Horizontal offset of the canvas
78-
* @param {Number} [display.vOffset = -20] Vertical offset of the canvas
79-
* @param {Boolean} [mobile.show = true] Whether to show on mobile device
80-
* @param {Number} [mobile.scale = 0.5] Scale on mobile device
81-
* @param {Boolean} [mobile.motion = true] Whether to enable motion detection on mobile devices
82-
* @param {String} [name.canvas = 'live2dcanvas'] ID name of the canvas
83-
* @param {String} [name.div = 'live2d-widget'] ID name of the div
84-
* @param {Number} [react.opacityDefault = 0.7] Default opacity
85-
* @param {Number} [react.opacityOnHover = 0.2] OnHover opacity
86-
* @param {Function} [react.myFunc = func(e)] Custom event handler, won't override main handler, will reveice the event type.
87-
* @param {Boolean} [dev.log = false] Whether to show log
88-
* @param {Boolean} [dev.mouseLog = false] Whether to show mouse log (tons of log), only work when dev.log is enabled
89-
* @param {Function} [dev.mouseFunc = func(x, y, ix, iy)] Custom logger, only work when dev.log is enabled, will receive (x, y, ix, iy), which presents the actucally position and vitural position
67+
* @param {Object} [userConfig] User's custom config 用户自定义设置
68+
* @param {String} [userConfig.model.jsonPath = ''] Path to Live2D model's main json eg. `https://test.com/miku.model.json` model主文件路径
69+
* @param {Number} [userConfig.model.scale = 1] Scale between the model and the canvas 模型与canvas的缩放
70+
* @param {Number} [userConfig.model.hHeadPos = 0.5] Horizontal position of model's head 模型头部横坐标
71+
* @param {Number} [userConfig.model.vHeadPos = 0.618] Vertical position of model's head 模型头部纵坐标
72+
* @param {Array} [userConfig.model.myDefine = []] User's custom Defines which will override LDefine 自定义的LDefine
73+
* @param {Number} [userConfig.display.AA = 2] Antialiasing grade 抗锯齿
74+
* @param {Number} [userConfig.display.widget = 150] Widget to the canvas which shows the model canvas的长度
75+
* @param {Number} [userConfig.display.height = 300] Height to the canvas which shows the model canvas的高度
76+
* @param {String} [userConfig.display.position = 'right'] Left of right side to show 显示位置:左或右
77+
* @param {Number} [userConfig.display.hOffset = 0] Horizontal offset of the canvas canvas水平偏移
78+
* @param {Number} [userConfig.display.vOffset = -20] Vertical offset of the canvas canvas垂直偏移
79+
* @param {Boolean} [userConfig.mobile.show = true] Whether to show on mobile device 是否在移动设备上显示
80+
* @param {Number} [userConfig.mobile.scale = 0.5] Scale on mobile device 移动设备上的缩放
81+
* @param {Boolean} [userConfig.mobile.motion = true] Whether to enable motion detection on mobile devices 移动设备是否开启重力感应
82+
* @param {String} [userConfig.name.canvas = 'live2dcanvas'] ID name of the canvas canvas元素的ID
83+
* @param {String} [userConfig.name.div = 'live2d-widget'] ID name of the div div元素的ID
84+
* @param {Number} [userConfig.react.opacityDefault = 0.7] Default opacity 默认透明度
85+
* @param {Number} [userConfig.react.opacityOnHover = 0.2] OnHover opacity 鼠标移上透明度
86+
* @param {Function} [userConfig.react.myFunc = func(e)] Custom event handler, won't override main handler, will reveice the event type. 自定义事件接收器
87+
* @param {Boolean} [userConfig.dev.log = false] Whether to show log 显示日志
88+
* @param {Boolean} [userConfig.dev.mouseLog = false] Whether to show mouse log (tons of log), only work when dev.log is enabled 显示鼠标移动
89+
* @param {Function} [userConfig.dev.mouseFunc = func(x, y, ix, iy)] Custom logger, only work when dev.log is enabled, will receive (x, y, ix, iy), which presents the actucally position and vitural position 自定义鼠标移动处理函数
9090
*/
9191

9292
function init(userConfig){

ghpages/docs/file/src/wpPublicPath.js.html

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,50 +55,95 @@
5555

5656
/**
5757
* Get current script path
58-
* @return {String} The accessable path of current script
58+
* @return {String} The path of current script
5959
* @example
60-
* get 'dev/' or 'https://www.host.com/test/js/'
60+
* get 'file:///C:/git/live2d-widget/dev/bundle.js' or 'https://www.host.com/test/js/bundle.js'
6161
*/
6262

6363
function getCurrentPath(){
6464

65-
let currentScriptPath = null;
66-
6765
try{
68-
// FF, Chrome
66+
67+
// FF, Chrome, Modern browsers
6968
// use their API to get the path of current script
7069

7170
// a.b();
72-
// console.log('Stage1');
73-
let currentScriptElement = document.currentScript;
74-
currentScriptPath = currentScriptElement.getAttribute('src').replace(/[^/\\\\]+$/, '');
71+
console.log('wpStage1');
72+
73+
return document.currentScript.src;
74+
75+
if(DOC.currentScript){ // FF 4+
76+
return DOC.currentScript.src;
77+
}
78+
7579
}catch(e){
76-
// IE 10 +, Safari and Opera 9
7780

78-
// console.log('Stage2');
79-
console.log(e);
81+
// document.currentScript doesn't supports
8082

81-
let stack = e.stack || e.sourceURL || e.stacktrace,
82-
rExtractUri = /(file:\/{3}\w:)(\/[^\/]*){3}\//;
83-
// TODO: Fix wrong RegExp: rExtractUri
84-
let absPath = rExtractUri.exec(stack);
85-
currentScriptPath = absPath[0];
83+
console.log('wpStage2');
8684

87-
if(currentScriptPath === ''){
88-
rExtractUri = /(?:http|https|file):\/\/.*?\/.+?.js/;
89-
absPath = rExtractUri.exec(stack);
90-
currentScriptPath = absPath[0];
91-
}
85+
// Method 1
86+
// https://github.com/mozilla/pdf.js/blob/e081a708c36cb2aacff7889048863723fcf23671/src/shared/compatibility.js#L97
87+
// IE, Chrome < 29
9288

93-
}
89+
let scripts = document.getElementsByTagName('script');
90+
return scripts[scripts.length - 1].src;
9491

95-
return currentScriptPath;
92+
/*
93+
// Method 2
94+
// parse the error stack trace maually
95+
// https://github.com/workhorsy/uncompress.js/blob/master/js/uncompress.js#L25
96+
97+
let stack = e.stack;
98+
let line = null;
99+
100+
// Chrome and IE
101+
if (stack.indexOf('@') !== -1) {
102+
line = stack.split('@')[1].split('\n')[0];
103+
// Firefox
104+
} else {
105+
line = stack.split('(')[1].split(')')[0];
106+
}
107+
line = line.substring(0, line.lastIndexOf('/')) + '/';
108+
return line;
109+
*/
110+
/*
111+
// Method 3
112+
// https://www.cnblogs.com/rubylouvre/archive/2013/01/23/2872618.html
113+
114+
let stack = e.stack;
115+
if(!stack && window.opera){
116+
// Opera 9没有e.stack,但有e.Backtrace,但不能直接取得,需要对e对象转字符串进行抽取
117+
stack = (String(e).match(/of linked script \S+/g) || []).join(' ');
118+
}
119+
if(stack){
120+
// e.stack最后一行在所有支持的浏览器大致如下:
121+
      // chrome23:
122+
      // @ http://113.93.50.63/data.js:4:1
123+
      // firefox17:
124+
      // @http://113.93.50.63/query.js:4
125+
      // opera12:
126+
      // @http://113.93.50.63/data.js:4
127+
      // IE10:
128+
      // @ Global code (http://113.93.50.63/data.js:4:1)
129+
     stack = stack.split(/[@ ]/g).pop(); // 取得最后一行,最后一个空格或@之后的部分
130+
stack = stack[0] == '(' ? stack.slice(1,-1) : stack;
131+
return stack.replace(/(:\d+)?:\d+$/i, ''); // 去掉行号与或许存在的出错字符起始位置
132+
}
133+
let nodes = head.getElementsByTagName('script'); // 只在head标签中寻找
134+
for(var i = 0, node; node = nodes[i++];){
135+
if(node.readyState === 'interactive'){
136+
return node.className = node.src;
137+
}
138+
}
139+
*/
140+
}
96141

97142
}
98143

99144
// expose the path to the global,
100145
// and wp will finish the following work
101-
__webpack_public_path__ = getCurrentPath();
146+
__webpack_public_path__ = getCurrentPath().replace(/[^/\\\\]+$/, '');
102147
if (process.env.NODE_ENV === 'development'){
103148
console.log(`wpPP: publicPath: ${__webpack_public_path__}`);
104149
}

0 commit comments

Comments
 (0)