@steedos/unpkg 2.2.50 → 2.2.51-beta.4

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.
Files changed (2) hide show
  1. package/package.json +2 -20
  2. package/package.service.js +1 -67
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/unpkg",
3
- "version": "2.2.50",
3
+ "version": "2.2.51-beta.4",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -8,23 +8,5 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "devDependencies": {
12
- "@salesforce-ux/design-system": "^2.17.5",
13
- "@steedos-builder/react": "^0.2.23",
14
- "@steedos-ui/amis": "^2.2.24",
15
- "@steedos-ui/builder-community": "^2.2.24",
16
- "@steedos-ui/builder-widgets": "^2.2.24",
17
- "@steedos-ui/design-system": "^2.2.24",
18
- "amis": "1.10.1",
19
- "axios": "^0.26.1",
20
- "crypto-js": "^4.1.1",
21
- "d3": "^3.5.17",
22
- "lodash": "^4.17.21",
23
- "moment": "^2.24.0",
24
- "monaco-editor": "^0.33.0",
25
- "prop-types": "^15.7.2",
26
- "react": "^17.0.2",
27
- "react-dom": "^17.0.2"
28
- },
29
- "gitHead": "7859a5ac5bcc9c0089d52ce9246eee1c83022816"
11
+ "gitHead": "975061203a5c8ee2ed2ab495cfed25a100304c96"
30
12
  }
@@ -30,23 +30,6 @@ module.exports = {
30
30
  isPackage: false
31
31
  },
32
32
  unpkgUrl: process.env.STEEDOS_UNPKG_URL ? process.env.STEEDOS_UNPKG_URL: 'https://unpkg.com',
33
- local_packages: [
34
- 'd3',
35
- 'react',
36
- 'react-dom',
37
- 'prop-types',
38
- 'lodash',
39
- 'moment',
40
- 'monaco-editor',
41
- 'amis',
42
- '@steedos-builder/react',
43
- '@steedos-ui/amis',
44
- '@steedos-ui/builder-community',
45
- '@steedos-ui/design-system',
46
- '@steedos-ui/builder-widgets',
47
- '@salesforce-ux/design-system',
48
- 'axios'
49
- ],
50
33
  },
51
34
 
52
35
  /**
@@ -72,59 +55,10 @@ module.exports = {
72
55
  * Methods
73
56
  */
74
57
  methods: {
75
-
76
- parsePackagePathname: function(pathname) {
77
-
78
- const packagePathnameFormat = /^\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(\/.*)?$/;
79
-
80
- try {
81
- pathname = decodeURIComponent(pathname);
82
- } catch (error) {
83
- return null;
84
- }
85
-
86
- const match = packagePathnameFormat.exec(pathname);
87
-
88
- // Disallow invalid pathnames.
89
- if (match == null) return null;
90
-
91
- const packageName = match[1];
92
- const packageVersion = match[2] || 'latest';
93
- const filename = (match[3] || '').replace(/\/\/+/g, '/');
94
-
95
- return {
96
- // If the pathname is /@scope/name@version/file.js:
97
- packageName, // @scope/name
98
- packageVersion, // version
99
- packageSpec: `${packageName}@${packageVersion}`, // @scope/name@version
100
- filename // /file.js
101
- };
102
- },
103
58
 
104
59
  loadUnpkgRoutes: function() {
105
60
  try {
106
61
  const router = express.Router();
107
- const cacheTime = 86400000 * 1; // one day
108
- this.settings.local_packages.forEach(packageName => {
109
- var packageDir = path.join(process.cwd(), 'node_modules', packageName);
110
- if (!fs.existsSync(packageDir)) {
111
- try {
112
- packageDir = path.dirname(require.resolve(packageName + '/package.json')).replace('/package.json', '')
113
- } catch (e) {}
114
- }
115
- if (fs.existsSync(packageDir)) {
116
- router.use(`/unpkg.com/${packageName}/`, express.static(packageDir, { maxAge: cacheTime }));
117
- // 内置模块,统一跳转到无版本号URL,防止浏览器端重复加载。
118
- router.get(`/unpkg.com/${packageName}@*`, (req, res) => {
119
- const packageUrl = req.path.split('/unpkg.com')[1]
120
- const parsed = this.parsePackagePathname(packageUrl)
121
- res.redirect(`/unpkg.com/${parsed.packageName}${parsed.filename}`);
122
- return
123
- })
124
- } else {
125
- this.logger.warn(`Package not found: ${packageName}, you should add to you project.`)
126
- }
127
- });
128
62
  if (this.settings.unpkgUrl) {
129
63
  router.get('/unpkg.com/*', (req, res) => {
130
64
  const packageUrl = req.path.split('/unpkg.com')[1]
@@ -160,4 +94,4 @@ module.exports = {
160
94
  async stopped() {
161
95
 
162
96
  }
163
- };
97
+ };