@worldfirst/worldfirst-js 0.0.1 → 0.0.1775118337-dev.6

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/lib/index.js ADDED
@@ -0,0 +1,482 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), t = /* @__PURE__ */ e(((e) => {
3
+ var t = e && e.__extends || (function() {
4
+ var e = function(t, n) {
5
+ return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
6
+ e.__proto__ = t;
7
+ } || function(e, t) {
8
+ for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
9
+ }, e(t, n);
10
+ };
11
+ return function(t, n) {
12
+ if (typeof n != "function" && n !== null) throw TypeError("Class extends value " + String(n) + " is not a constructor or null");
13
+ e(t, n);
14
+ function r() {
15
+ this.constructor = t;
16
+ }
17
+ t.prototype = n === null ? Object.create(n) : (r.prototype = n.prototype, new r());
18
+ };
19
+ })();
20
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.LoaderError = void 0, e.loadScriptClass = r, e.loadScript = i;
21
+ var n = function(e) {
22
+ t(n, e);
23
+ function n(t, n) {
24
+ var r = e.call(this, n) || this;
25
+ return Object.defineProperty(r, "code", {
26
+ enumerable: !0,
27
+ configurable: !0,
28
+ writable: !0,
29
+ value: void 0
30
+ }), r.name = "LoaderError", r.code = t, r;
31
+ }
32
+ return Object.defineProperty(n, "unificationError", {
33
+ enumerable: !1,
34
+ configurable: !0,
35
+ writable: !0,
36
+ value: function(e) {
37
+ return e instanceof n || e instanceof Error && e.name === "LoaderError" ? e : new n("UNKNOWN_ERROR", e instanceof Error ? e.message : "An unknown error occurred.");
38
+ }
39
+ }), n;
40
+ }(Error);
41
+ e.LoaderError = n;
42
+ function r(e, t) {
43
+ return i(e, t);
44
+ }
45
+ function i(e, t) {
46
+ var r = function() {
47
+ if (typeof t == "function") return t();
48
+ var e = window[t];
49
+ return e?.default || e;
50
+ };
51
+ return new Promise(function(t, i) {
52
+ var a = r();
53
+ if (a) return t({
54
+ cache: !0,
55
+ variable: a
56
+ });
57
+ var o = document.querySelector(`script[src="${e}"]`), s = o || document.createElement("script");
58
+ s.src = e, s.async = !0, s.addEventListener("load", function() {
59
+ t({
60
+ cache: !1,
61
+ variable: r()
62
+ });
63
+ }), s.addEventListener("error", function(t) {
64
+ i(new n("LOAD_ERROR", `Load script ${e} failed: ${t.message}`));
65
+ }), o || document.head.appendChild(s);
66
+ });
67
+ }
68
+ })), n = /* @__PURE__ */ e(((e) => {
69
+ var n = e && e.__awaiter || function(e, t, n, r) {
70
+ function i(e) {
71
+ return e instanceof n ? e : new n(function(t) {
72
+ t(e);
73
+ });
74
+ }
75
+ return new (n ||= Promise)(function(n, a) {
76
+ function o(e) {
77
+ try {
78
+ c(r.next(e));
79
+ } catch (e) {
80
+ a(e);
81
+ }
82
+ }
83
+ function s(e) {
84
+ try {
85
+ c(r.throw(e));
86
+ } catch (e) {
87
+ a(e);
88
+ }
89
+ }
90
+ function c(e) {
91
+ e.done ? n(e.value) : i(e.value).then(o, s);
92
+ }
93
+ c((r = r.apply(e, t || [])).next());
94
+ });
95
+ }, r = e && e.__generator || function(e, t) {
96
+ var n = {
97
+ label: 0,
98
+ sent: function() {
99
+ if (a[0] & 1) throw a[1];
100
+ return a[1];
101
+ },
102
+ trys: [],
103
+ ops: []
104
+ }, r, i, a, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
105
+ return o.next = s(0), o.throw = s(1), o.return = s(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
106
+ return this;
107
+ }), o;
108
+ function s(e) {
109
+ return function(t) {
110
+ return c([e, t]);
111
+ };
112
+ }
113
+ function c(s) {
114
+ if (r) throw TypeError("Generator is already executing.");
115
+ for (; o && (o = 0, s[0] && (n = 0)), n;) try {
116
+ if (r = 1, i && (a = s[0] & 2 ? i.return : s[0] ? i.throw || ((a = i.return) && a.call(i), 0) : i.next) && !(a = a.call(i, s[1])).done) return a;
117
+ switch (i = 0, a && (s = [s[0] & 2, a.value]), s[0]) {
118
+ case 0:
119
+ case 1:
120
+ a = s;
121
+ break;
122
+ case 4: return n.label++, {
123
+ value: s[1],
124
+ done: !1
125
+ };
126
+ case 5:
127
+ n.label++, i = s[1], s = [0];
128
+ continue;
129
+ case 7:
130
+ s = n.ops.pop(), n.trys.pop();
131
+ continue;
132
+ default:
133
+ if ((a = n.trys, !(a = a.length > 0 && a[a.length - 1])) && (s[0] === 6 || s[0] === 2)) {
134
+ n = 0;
135
+ continue;
136
+ }
137
+ if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
138
+ n.label = s[1];
139
+ break;
140
+ }
141
+ if (s[0] === 6 && n.label < a[1]) {
142
+ n.label = a[1], a = s;
143
+ break;
144
+ }
145
+ if (a && n.label < a[2]) {
146
+ n.label = a[2], n.ops.push(s);
147
+ break;
148
+ }
149
+ a[2] && n.ops.pop(), n.trys.pop();
150
+ continue;
151
+ }
152
+ s = t.call(e, n);
153
+ } catch (e) {
154
+ s = [6, e], i = 0;
155
+ } finally {
156
+ r = a = 0;
157
+ }
158
+ if (s[0] & 5) throw s[1];
159
+ return {
160
+ value: s[0] ? s[1] : void 0,
161
+ done: !0
162
+ };
163
+ }
164
+ };
165
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.tracker = e.ScriptTracker = void 0;
166
+ var i = t(), a = "https://cdn.marmot-cloud.com/tnpm-package/@antintl-opensdk-debugger/1.0.1/dist/tracker.umd.js", o = function() {
167
+ function e(e) {
168
+ var t = this;
169
+ Object.defineProperty(this, "initOptions", {
170
+ enumerable: !0,
171
+ configurable: !0,
172
+ writable: !0,
173
+ value: void 0
174
+ }), Object.defineProperty(this, "tracker", {
175
+ enumerable: !0,
176
+ configurable: !0,
177
+ writable: !0,
178
+ value: void 0
179
+ }), this.initOptions = e, this.loadTacker().then(function(e) {
180
+ t.tracker = e;
181
+ });
182
+ }
183
+ return Object.defineProperty(e.prototype, "loadTacker", {
184
+ enumerable: !1,
185
+ configurable: !0,
186
+ writable: !0,
187
+ value: function() {
188
+ var e = this;
189
+ return (0, i.loadScript)(a, "intlSdkTracker").then(function(t) {
190
+ return (t?.variable)?.getTrackerInstance(e.initOptions);
191
+ });
192
+ }
193
+ }), Object.defineProperty(e.prototype, "getTracker", {
194
+ enumerable: !1,
195
+ configurable: !0,
196
+ writable: !0,
197
+ value: function() {
198
+ return n(this, void 0, void 0, function() {
199
+ var e;
200
+ return r(this, function(t) {
201
+ switch (t.label) {
202
+ case 0: return this.tracker ? [2, this.tracker] : [4, this.loadTacker()];
203
+ case 1: return e = t.sent(), e && (this.tracker = e), [2, e];
204
+ }
205
+ });
206
+ });
207
+ }
208
+ }), Object.defineProperty(e.prototype, "safeCall", {
209
+ enumerable: !1,
210
+ configurable: !0,
211
+ writable: !0,
212
+ value: function(e) {
213
+ return this.getTracker().then(e);
214
+ }
215
+ }), Object.defineProperty(e.prototype, "log", {
216
+ enumerable: !1,
217
+ configurable: !0,
218
+ writable: !0,
219
+ value: function() {
220
+ var e = [...arguments];
221
+ this.safeCall(function(t) {
222
+ return t?.log.apply(t, e);
223
+ });
224
+ }
225
+ }), e;
226
+ }();
227
+ e.ScriptTracker = o;
228
+ var s = "LOCAL"?.toUpperCase() || "PROD";
229
+ e.tracker = new o({
230
+ appId: "180020050100012557",
231
+ env: [
232
+ "DEV",
233
+ "SIT",
234
+ "PRE",
235
+ "PROD",
236
+ "LOCAL"
237
+ ].includes(s) ? s : "PROD",
238
+ server: "sg",
239
+ performance: !1,
240
+ error: !1
241
+ });
242
+ })), r = (0, (/* @__PURE__ */ e(((e) => {
243
+ var r = e && e.__awaiter || function(e, t, n, r) {
244
+ function i(e) {
245
+ return e instanceof n ? e : new n(function(t) {
246
+ t(e);
247
+ });
248
+ }
249
+ return new (n ||= Promise)(function(n, a) {
250
+ function o(e) {
251
+ try {
252
+ c(r.next(e));
253
+ } catch (e) {
254
+ a(e);
255
+ }
256
+ }
257
+ function s(e) {
258
+ try {
259
+ c(r.throw(e));
260
+ } catch (e) {
261
+ a(e);
262
+ }
263
+ }
264
+ function c(e) {
265
+ e.done ? n(e.value) : i(e.value).then(o, s);
266
+ }
267
+ c((r = r.apply(e, t || [])).next());
268
+ });
269
+ }, i = e && e.__generator || function(e, t) {
270
+ var n = {
271
+ label: 0,
272
+ sent: function() {
273
+ if (a[0] & 1) throw a[1];
274
+ return a[1];
275
+ },
276
+ trys: [],
277
+ ops: []
278
+ }, r, i, a, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
279
+ return o.next = s(0), o.throw = s(1), o.return = s(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
280
+ return this;
281
+ }), o;
282
+ function s(e) {
283
+ return function(t) {
284
+ return c([e, t]);
285
+ };
286
+ }
287
+ function c(s) {
288
+ if (r) throw TypeError("Generator is already executing.");
289
+ for (; o && (o = 0, s[0] && (n = 0)), n;) try {
290
+ if (r = 1, i && (a = s[0] & 2 ? i.return : s[0] ? i.throw || ((a = i.return) && a.call(i), 0) : i.next) && !(a = a.call(i, s[1])).done) return a;
291
+ switch (i = 0, a && (s = [s[0] & 2, a.value]), s[0]) {
292
+ case 0:
293
+ case 1:
294
+ a = s;
295
+ break;
296
+ case 4: return n.label++, {
297
+ value: s[1],
298
+ done: !1
299
+ };
300
+ case 5:
301
+ n.label++, i = s[1], s = [0];
302
+ continue;
303
+ case 7:
304
+ s = n.ops.pop(), n.trys.pop();
305
+ continue;
306
+ default:
307
+ if ((a = n.trys, !(a = a.length > 0 && a[a.length - 1])) && (s[0] === 6 || s[0] === 2)) {
308
+ n = 0;
309
+ continue;
310
+ }
311
+ if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
312
+ n.label = s[1];
313
+ break;
314
+ }
315
+ if (s[0] === 6 && n.label < a[1]) {
316
+ n.label = a[1], a = s;
317
+ break;
318
+ }
319
+ if (a && n.label < a[2]) {
320
+ n.label = a[2], n.ops.push(s);
321
+ break;
322
+ }
323
+ a[2] && n.ops.pop(), n.trys.pop();
324
+ continue;
325
+ }
326
+ s = t.call(e, n);
327
+ } catch (e) {
328
+ s = [6, e], i = 0;
329
+ } finally {
330
+ r = a = 0;
331
+ }
332
+ if (s[0] & 5) throw s[1];
333
+ return {
334
+ value: s[0] ? s[1] : void 0,
335
+ done: !0
336
+ };
337
+ }
338
+ };
339
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.loadScript = void 0, e.createLoader = u;
340
+ var a = n(), o = t();
341
+ Object.defineProperty(e, "loadScript", {
342
+ enumerable: !0,
343
+ get: function() {
344
+ return o.loadScript;
345
+ }
346
+ });
347
+ var s = null;
348
+ function c(e, t, n) {
349
+ return s || (s = l(e, t, n), s);
350
+ }
351
+ function l(e, t, n) {
352
+ var r = new e(t), i = Date.now();
353
+ return r.init().then(function(e) {
354
+ return n && a.tracker.log({
355
+ code: "7988",
356
+ msg: n,
357
+ d1: "initialized",
358
+ d2: "无",
359
+ d3: "无",
360
+ d4: r.version || "无版本号",
361
+ d5: "umd",
362
+ m1: Date.now() - i,
363
+ m2: Date.now() - i
364
+ }), e;
365
+ }).catch(function(e) {
366
+ var t = new o.LoaderError("INIT_ERROR", `Initialize Class failed: ${e.message}`);
367
+ throw n && a.tracker.log({
368
+ code: "7988",
369
+ msg: n,
370
+ d1: "createError",
371
+ d2: t.code,
372
+ d3: t.message,
373
+ d4: "无",
374
+ d5: "umd",
375
+ m1: Date.now() - i,
376
+ m2: 0
377
+ }), t;
378
+ });
379
+ }
380
+ function u(e) {
381
+ var t = this, n = e.sdkURL, s = e.globalName, u = e.timeout, f = u === void 0 ? 2e4 : u, p = e.onLoadComplete, m = e.onError, h = e.onLoadStart, g = e.onInitialized, _ = e.single, v = _ === void 0 ? !0 : _, y = e.namespace;
382
+ return function(e) {
383
+ return r(t, void 0, void 0, function() {
384
+ var t, u, _ = this;
385
+ return i(this, function(b) {
386
+ return h?.(), t = Date.now(), a.tracker.log({
387
+ code: "7988",
388
+ msg: y,
389
+ d1: "loadStart",
390
+ d2: "无",
391
+ d3: "无",
392
+ d4: "无",
393
+ d5: "npm",
394
+ m1: 0,
395
+ m2: 0
396
+ }), u = d(function() {
397
+ return (0, o.loadScriptClass)(n, s);
398
+ }, f), [2, u().then(function(n) {
399
+ return r(_, [n], void 0, function(n) {
400
+ var r, u, d, f, m = n.variable, h = n.cache;
401
+ return i(this, function(n) {
402
+ switch (n.label) {
403
+ case 0:
404
+ if (r = Date.now(), h || a.tracker.log({
405
+ code: "7988",
406
+ msg: y,
407
+ d1: "loadComplete",
408
+ d2: "无",
409
+ d3: "无",
410
+ d4: m.version || "无",
411
+ d5: "npm",
412
+ m1: Date.now() - t,
413
+ m2: 0
414
+ }), p?.(), !m) throw new o.LoaderError("NO_REMOTE_CLASS", `No variables ${s} were found. Cannot be initialized the Class ${s}`);
415
+ n.label = 1;
416
+ case 1: return n.trys.push([
417
+ 1,
418
+ 3,
419
+ ,
420
+ 4
421
+ ]), u = v ? c : l, [4, u(m, e, void 0)];
422
+ case 2: return d = n.sent(), a.tracker.log({
423
+ code: "7988",
424
+ msg: y,
425
+ d1: "initialized",
426
+ d2: "无",
427
+ d3: "无",
428
+ d4: d.version || "无版本号",
429
+ d5: "npm",
430
+ m1: Date.now() - t,
431
+ m2: Date.now() - r
432
+ }), g?.(d, window.location.href), [2, d];
433
+ case 3: throw f = n.sent(), new o.LoaderError("INIT_ERROR", `Initialize Class ${s} failed: ${f.message}`);
434
+ case 4: return [2];
435
+ }
436
+ });
437
+ });
438
+ }).catch(function(e) {
439
+ var n = o.LoaderError.unificationError(e);
440
+ return a.tracker.log({
441
+ code: "7988",
442
+ msg: y,
443
+ d1: "createError",
444
+ d2: n.code,
445
+ d3: n.message,
446
+ d4: "无",
447
+ d5: "npm",
448
+ m1: Date.now() - t,
449
+ m2: 0
450
+ }), m?.(n), Promise.reject(e);
451
+ })];
452
+ });
453
+ });
454
+ };
455
+ }
456
+ function d(e, t) {
457
+ return function() {
458
+ var n = [...arguments];
459
+ return Promise.race([new Promise(function(e, n) {
460
+ setTimeout(function() {
461
+ n(new o.LoaderError("LOAD_TIMEOUT", `Load timeout: ${t}`));
462
+ }, t);
463
+ }), e.apply(void 0, n)]);
464
+ };
465
+ }
466
+ })))().createLoader)({
467
+ sdkURL: {
468
+ DEV: "https://sdk-dev.marmot-cloud.com/package/worldfirst-js/dev-1775118337/index.js",
469
+ LOCAL: "http://localhost:7981/index.js",
470
+ PROD: "https://js.worldfirst.com/v2/index.js"
471
+ }.LOCAL,
472
+ globalName: "WorldFirstSDK",
473
+ namespace: "WorldFirstSDK"
474
+ }), i = async (e) => {
475
+ let { env: t, ...n } = e || {}, i = t || "prod";
476
+ return r({
477
+ ...n,
478
+ env: i
479
+ });
480
+ };
481
+ //#endregion
482
+ export { i as loadWorldFirst };
@@ -0,0 +1,3 @@
1
+ type StageName = 'DEV' | 'PROD' | 'LOCAL';
2
+ export declare const stageName: StageName;
3
+ export {};
package/package.json CHANGED
@@ -1,15 +1,106 @@
1
1
  {
2
2
  "name": "@worldfirst/worldfirst-js",
3
- "version": "0.0.1",
4
- "description": "a opensdk js for worldfirst",
5
- "main": "index.js",
6
- "private": false,
3
+ "version": "0.0.1775118337-dev.6",
4
+ "description": "worldfirst sdk",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./lib/index.d.ts",
8
+ "import": "./lib/index.js",
9
+ "require": "./lib/index.cjs",
10
+ "default": "./lib/index.js"
11
+ },
12
+ "./react-js": {
13
+ "types": "./react-js.d.ts",
14
+ "import": "./react-js.js",
15
+ "require": "./react-js.cjs"
16
+ },
17
+ "./cdn": "./cdn.d.ts",
18
+ "./types": "./types.d.ts",
19
+ "./interface": "./types.untrimmed.d.ts"
20
+ },
21
+ "main": "./lib/index.cjs",
22
+ "module": "./lib/index.js",
23
+ "types": "./lib/index.d.ts",
24
+ "files": [
25
+ "lib",
26
+ "dist",
27
+ "package.json",
28
+ "LEGAL.md",
29
+ "LICENSE",
30
+ "README.md",
31
+ "types.d.ts",
32
+ "types.untrimmed.d.ts",
33
+ "react-js.cjs",
34
+ "react-js.js",
35
+ "react-js.d.ts",
36
+ "cdn.d.ts"
37
+ ],
7
38
  "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
39
+ "build": "opensdk build",
40
+ "clean": "rm -rf dist esm types.d.ts types.untrimmed.d.ts tsdoc-metadata.json",
41
+ "copy:core": "mkdir -p public && cp dist/worldfirst.min.js public/",
42
+ "dev": "opensdk dev",
43
+ "doc": "dumi dev",
44
+ "docs:build": "dumi build",
45
+ "docs:preview": "dumi preview",
46
+ "lint": "npm run lint:es && npm run lint:css",
47
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
48
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
49
+ "prepare": "husky install || true",
50
+ "start": "opensdk dev"
51
+ },
52
+ "commitlint": {
53
+ "extends": [
54
+ "@commitlint/config-conventional"
55
+ ]
56
+ },
57
+ "lint-staged": {
58
+ "*.{md,json}": [
59
+ "prettier --write --no-error-on-unmatched-pattern"
60
+ ],
61
+ "*.{css,less}": [
62
+ "stylelint --fix",
63
+ "prettier --write"
64
+ ],
65
+ "*.{js,jsx}": [
66
+ "eslint --fix",
67
+ "prettier --write"
68
+ ],
69
+ "*.{ts,tsx}": [
70
+ "eslint --fix",
71
+ "prettier --parser=typescript --write"
72
+ ]
73
+ },
74
+ "devDependencies": {
75
+ "@antglobal/create-sdk-loader": "^1.0.4",
76
+ "@commitlint/cli": "^17.1.2",
77
+ "@commitlint/config-conventional": "^17.1.0",
78
+ "@types/react": "^18.0.0",
79
+ "@types/react-dom": "^18.0.0",
80
+ "@umijs/lint": "^4.0.0",
81
+ "dumi": "^2.4.21",
82
+ "eslint": "^8.23.0",
83
+ "husky": "^8.0.1",
84
+ "lint-staged": "^13.0.3",
85
+ "prettier": "^2.7.1",
86
+ "prettier-plugin-organize-imports": "^3.0.0",
87
+ "prettier-plugin-packagejson": "^2.2.18",
88
+ "react": "^18.0.0",
89
+ "react-dom": "^18.0.0",
90
+ "stylelint": "^14.9.1",
91
+ "ts-patch": "^3.3.0",
92
+ "typescript": "~5.9.3",
93
+ "typescript-transform-paths": "^3.5.6"
94
+ },
95
+ "peerDependencies": {
96
+ "react": ">=16.9.0",
97
+ "react-dom": ">=16.9.0"
98
+ },
99
+ "publishConfig": {
100
+ "access": "public"
9
101
  },
10
- "keywords": [
11
- "worldfirst"
102
+ "authors": [
103
+ "Ant Group"
12
104
  ],
13
- "author": "likun7981",
14
- "license": "ISC"
105
+ "marmotId": "180020050100012484"
15
106
  }