bigbluebutton-html-plugin-sdk 0.0.78 → 0.0.79
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/cjs/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.js +28 -33
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.js.map +1 -1
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.d.ts +3 -0
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.js +72 -0
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,50 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
var
|
|
3
|
+
var react_1 = require("react");
|
|
27
4
|
var ui_data_hooks_1 = require("../../../../ui-data-hooks");
|
|
28
5
|
var utils_1 = require("../../../../utils");
|
|
6
|
+
var utils_2 = require("./utils");
|
|
29
7
|
function useLocaleMessagesAuxiliary(_a) {
|
|
30
8
|
var pluginApi = _a.pluginApi, fetchConfigs = _a.fetchConfigs;
|
|
31
9
|
var currentLocale = pluginApi.useUiData(ui_data_hooks_1.IntlLocaleUiDataNames.CURRENT_LOCALE, {
|
|
32
10
|
locale: 'en',
|
|
33
11
|
fallbackLocale: 'en',
|
|
34
12
|
});
|
|
35
|
-
var _b =
|
|
36
|
-
var _c =
|
|
37
|
-
|
|
13
|
+
var _b = (0, react_1.useState)(true), loading = _b[0], setLoading = _b[1];
|
|
14
|
+
var _c = (0, react_1.useState)({}), messages = _c[0], setMessages = _c[1];
|
|
15
|
+
var _d = (0, react_1.useState)(), fallbackMessages = _d[0], setFallbackMessages = _d[1];
|
|
16
|
+
(0, react_1.useEffect)(function () {
|
|
38
17
|
if ((pluginApi === null || pluginApi === void 0 ? void 0 : pluginApi.localesBaseUrl) && currentLocale.locale) {
|
|
39
18
|
var localesBaseUrl = pluginApi.localesBaseUrl;
|
|
40
|
-
var locale = currentLocale.locale;
|
|
19
|
+
var locale = currentLocale.locale, fallbackLocale = currentLocale.fallbackLocale;
|
|
41
20
|
var localeUrl_1 = "".concat(localesBaseUrl, "/").concat(locale, ".json");
|
|
42
|
-
|
|
21
|
+
var fallbackLocaleUrl_1 = "".concat(localesBaseUrl, "/").concat(fallbackLocale, ".json");
|
|
22
|
+
Promise.all([
|
|
23
|
+
localeUrl_1,
|
|
24
|
+
fallbackLocaleUrl_1,
|
|
25
|
+
].map(function (url) {
|
|
26
|
+
if (url !== fallbackLocaleUrl_1 || !fallbackMessages) {
|
|
27
|
+
try {
|
|
28
|
+
return (0, utils_2.fetchLocaleAndStore)(url, fetchConfigs);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
utils_1.pluginLogger.error("Something went wrong while trying to fetch ".concat(localeUrl_1, ": "), err);
|
|
32
|
+
return Promise.reject(err);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return Promise.resolve(fallbackMessages);
|
|
36
|
+
})).then(function (values) {
|
|
37
|
+
var desiredLocale = values[0], fallbackLocaleMessages = values[1];
|
|
38
|
+
setMessages((0, utils_2.mergeLocaleMessages)(desiredLocale, fallbackLocaleMessages));
|
|
39
|
+
if (!fallbackMessages)
|
|
40
|
+
setFallbackMessages(fallbackLocaleMessages);
|
|
41
|
+
}).finally(function () {
|
|
43
42
|
setLoading(false);
|
|
44
|
-
setMessages(localeMessages);
|
|
45
|
-
}).catch(function (err) {
|
|
46
|
-
setLoading(false);
|
|
47
|
-
utils_1.pluginLogger.error("Something went wrong while trying to fetch ".concat(localeUrl_1, ": "), err);
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
}, [currentLocale]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleMessages.js","sourceRoot":"","sources":["../../../../../../src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleMessages.js","sourceRoot":"","sources":["../../../../../../src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts"],"names":[],"mappings":";;AAAA,+BAA4C;AAC5C,2DAAkE;AAClE,2CAAiD;AAEjD,iCAAmE;AAEnE,SAAS,0BAA0B,CACjC,EAAmD;QAAjD,SAAS,eAAA,EAAE,YAAY,kBAAA;IAEzB,IAAM,aAAa,GAAG,SAAS,CAAC,SAAU,CAAC,qCAAqB,CAAC,cAAc,EAAE;QAC/E,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE,IAAI;KACrB,CAAC,CAAC;IAEG,IAAA,KAAwB,IAAA,gBAAQ,EAAC,IAAI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EAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC;gBACxE,IAAI,CAAC,gBAAgB;oBAAE,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC,OAAO,CAAC;gBACT,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACpB,OAAO;QACL,QAAQ,UAAA;QACR,OAAO,SAAA;QACP,aAAa,EAAE,aAAa,CAAC,MAAM;KACpC,CAAC;AACJ,CAAC;AAED,kBAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare function fetchLocaleAndStore(localeUrl: string, fetchConfigs?: RequestInit): Promise<Record<string, string>>;
|
|
2
|
+
declare function mergeLocaleMessages(desiredMessages: Record<string, string>, fallbackMessages: Record<string, string>): Record<string, string>;
|
|
3
|
+
export { fetchLocaleAndStore, mergeLocaleMessages };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.mergeLocaleMessages = exports.fetchLocaleAndStore = void 0;
|
|
51
|
+
function fetchLocaleAndStore(localeUrl, fetchConfigs) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var result, localeMessages;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, fetch(localeUrl, fetchConfigs)];
|
|
57
|
+
case 1:
|
|
58
|
+
result = _a.sent();
|
|
59
|
+
return [4 /*yield*/, result.json()];
|
|
60
|
+
case 2:
|
|
61
|
+
localeMessages = _a.sent();
|
|
62
|
+
return [2 /*return*/, localeMessages];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.fetchLocaleAndStore = fetchLocaleAndStore;
|
|
68
|
+
function mergeLocaleMessages(desiredMessages, fallbackMessages) {
|
|
69
|
+
return __assign(__assign({}, fallbackMessages), desiredMessages);
|
|
70
|
+
}
|
|
71
|
+
exports.mergeLocaleMessages = mergeLocaleMessages;
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../src/core/auxiliary/plugin-information/locale-messages/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAe,mBAAmB,CAChC,SAAiB,EACjB,YAA0B;;;;;wBAEX,qBAAM,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,EAAA;;oBAA7C,MAAM,GAAG,SAAoC;oBAC5B,qBAAM,MAAM,CAAC,IAAI,EAAE,EAAA;;oBAApC,cAAc,GAAG,SAAmB;oBAC1C,sBAAO,cAAc,EAAC;;;;CACvB;AASQ,kDAAmB;AAP5B,SAAS,mBAAmB,CAC1B,eAAuC,EACvC,gBAAwC;IAExC,6BAAY,gBAAgB,GAAK,eAAe,EAAG;AACrD,CAAC;AAE6B,kDAAmB"}
|