viewlogic 1.2.6 → 1.2.7
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/README.md +35 -7
- package/dist/viewlogic-router.esm.js +4 -0
- package/dist/{viewlogic-router.js.map → viewlogic-router.esm.js.map} +3 -3
- package/dist/viewlogic-router.min.js +9 -52
- package/dist/viewlogic-router.min.js.map +4 -4
- package/package.json +7 -9
- package/dist/viewlogic-router.js +0 -2984
- package/dist/viewlogic-router.umd.js +0 -139
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ViewLogic Router - UMD Bundle
|
|
3
|
-
* Optimized version with cleaner Promise handling
|
|
4
|
-
*/
|
|
5
|
-
(function (root, factory) {
|
|
6
|
-
if (typeof define === 'function' && define.amd) {
|
|
7
|
-
define([], factory);
|
|
8
|
-
} else if (typeof module === 'object' && module.exports) {
|
|
9
|
-
module.exports = factory();
|
|
10
|
-
} else {
|
|
11
|
-
var api = factory();
|
|
12
|
-
root.createRouter = api.createRouter;
|
|
13
|
-
root.ViewLogicRouter = api.ViewLogicRouter;
|
|
14
|
-
}
|
|
15
|
-
}(typeof self !== 'undefined' ? self : this, function () {
|
|
16
|
-
'use strict';
|
|
17
|
-
|
|
18
|
-
let RouterClass = null;
|
|
19
|
-
let loadPromise = null;
|
|
20
|
-
|
|
21
|
-
function detectEnvironment(options) {
|
|
22
|
-
return (options && options.environment) || 'development';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getBaseUrl() {
|
|
26
|
-
// Try to detect current script URL to determine base path
|
|
27
|
-
if (typeof document !== 'undefined') {
|
|
28
|
-
const scripts = Array.from(document.scripts);
|
|
29
|
-
const currentScript = scripts.find(script =>
|
|
30
|
-
script.src && script.src.includes('viewlogic-router.umd.js')
|
|
31
|
-
);
|
|
32
|
-
if (currentScript) {
|
|
33
|
-
const url = new URL(currentScript.src);
|
|
34
|
-
const baseUrl = url.origin + url.pathname.replace(/\/[^\/]*$/, '/');
|
|
35
|
-
return baseUrl;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return 'https://cdn.jsdelivr.net/npm/viewlogic/dist/';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getRouterPath(environment) {
|
|
43
|
-
const baseUrl = getBaseUrl();
|
|
44
|
-
return environment === 'production' ? baseUrl + 'viewlogic-router.min.js' : baseUrl + 'viewlogic-router.js';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function setGlobalRouter(router) {
|
|
48
|
-
try {
|
|
49
|
-
root.router = router;
|
|
50
|
-
} catch(_) {
|
|
51
|
-
try {
|
|
52
|
-
window.router = router;
|
|
53
|
-
} catch(__) {}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function loadRouterClass(options) {
|
|
58
|
-
if (RouterClass) return RouterClass;
|
|
59
|
-
|
|
60
|
-
if (!loadPromise) {
|
|
61
|
-
const environment = detectEnvironment(options);
|
|
62
|
-
const routerPath = getRouterPath(environment);
|
|
63
|
-
|
|
64
|
-
loadPromise = import(routerPath)
|
|
65
|
-
.then(module => {
|
|
66
|
-
RouterClass = module.ViewLogicRouter;
|
|
67
|
-
return RouterClass;
|
|
68
|
-
})
|
|
69
|
-
.catch(error => {
|
|
70
|
-
// More robust error checking for failed module loading
|
|
71
|
-
const isLoadError = error?.message?.includes('Failed to fetch') ||
|
|
72
|
-
error?.message?.includes('404') ||
|
|
73
|
-
error?.message?.includes('Cannot find module') ||
|
|
74
|
-
error?.message?.includes('Failed to resolve');
|
|
75
|
-
|
|
76
|
-
if (environment === 'production' && isLoadError) {
|
|
77
|
-
console.warn('Failed to load minified version, falling back to regular version');
|
|
78
|
-
const baseUrl = getBaseUrl();
|
|
79
|
-
return import(baseUrl + 'viewlogic-router.js').then(module => {
|
|
80
|
-
RouterClass = module.ViewLogicRouter;
|
|
81
|
-
return RouterClass;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
throw error;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return loadPromise;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function createRouter(options = {}) {
|
|
92
|
-
const RouterConstructor = await loadRouterClass(options);
|
|
93
|
-
const router = new RouterConstructor(options);
|
|
94
|
-
|
|
95
|
-
// 라우터 생성 즉시 전역에 설정
|
|
96
|
-
setGlobalRouter(router);
|
|
97
|
-
|
|
98
|
-
if (!router.mount) {
|
|
99
|
-
router.mount = function(el) {
|
|
100
|
-
// mount 시에도 다시 설정 (안전장치)
|
|
101
|
-
setGlobalRouter(router);
|
|
102
|
-
return router;
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return router;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function ViewLogicRouter(options = {}) {
|
|
110
|
-
const routerPromise = createRouter(options);
|
|
111
|
-
|
|
112
|
-
// Promise 완료 시 즉시 전역 설정 확인
|
|
113
|
-
routerPromise.then(router => {
|
|
114
|
-
setGlobalRouter(router);
|
|
115
|
-
}).catch(error => {
|
|
116
|
-
console.error('Failed to create ViewLogic router:', error);
|
|
117
|
-
throw error;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
routerPromise.mount = function(el) {
|
|
121
|
-
return routerPromise.then(router => {
|
|
122
|
-
// mount 시에도 다시 설정 (안전장치)
|
|
123
|
-
setGlobalRouter(router);
|
|
124
|
-
|
|
125
|
-
if (router.mount) {
|
|
126
|
-
return router.mount(el);
|
|
127
|
-
}
|
|
128
|
-
return router;
|
|
129
|
-
}).catch(error => {
|
|
130
|
-
console.error('Failed to mount ViewLogic router:', error);
|
|
131
|
-
throw error;
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
return routerPromise;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return { createRouter, ViewLogicRouter };
|
|
139
|
-
}));
|