@castlabs/ui 6.0.0 → 6.0.2
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/castlabs-ui.core.js
CHANGED
|
@@ -1087,3 +1087,303 @@ function clRefClFieldGroup (ref) {
|
|
|
1087
1087
|
function clRefHTMLElement (ref) {
|
|
1088
1088
|
return ref
|
|
1089
1089
|
}
|
|
1090
|
+
|
|
1091
|
+
const NBSP = '✺' // non-breakable space for searching substrings
|
|
1092
|
+
|
|
1093
|
+
let cache = {}
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* Determine if a string matches our advanced search expression.
|
|
1097
|
+
*
|
|
1098
|
+
* @param {String} string String to match against (haystack).
|
|
1099
|
+
* @param {String} expression String to match for (needle).
|
|
1100
|
+
* @param {Boolean} caseSensitive Boolean to turn on/off case sensitive search.
|
|
1101
|
+
* @return {boolean} True if string matches expression.
|
|
1102
|
+
*/
|
|
1103
|
+
function clMatch (string, expression = '', caseSensitive = false) {
|
|
1104
|
+
const tree = cache[expression] ?? _tokenize(_sanitize(expression))
|
|
1105
|
+
if (Object.keys(cache).length > 100) cache = {} // clear too big caches
|
|
1106
|
+
cache[expression] = tree
|
|
1107
|
+
if (caseSensitive) {
|
|
1108
|
+
return matchSubtree(string.toLowerCase(), tree, caseSensitive)
|
|
1109
|
+
} else {
|
|
1110
|
+
return matchSubtree(string, tree, caseSensitive)
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// -----------------------------------------------------------------------------
|
|
1115
|
+
|
|
1116
|
+
function matchSubtree (string, subtree, caseSensitive) {
|
|
1117
|
+
if (typeof subtree === 'string') {
|
|
1118
|
+
const term = subtree.replaceAll(NBSP, ' ')
|
|
1119
|
+
if (term[0] === '-') return !matchSubtree(string, term.substring(1), caseSensitive)
|
|
1120
|
+
if (caseSensitive) {
|
|
1121
|
+
return string.includes(term)
|
|
1122
|
+
} else {
|
|
1123
|
+
return string.toLowerCase().includes(term.toLowerCase())
|
|
1124
|
+
}
|
|
1125
|
+
} else {
|
|
1126
|
+
switch (subtree[0]) {
|
|
1127
|
+
case '&':
|
|
1128
|
+
return matchSubtree(string, subtree[1]) && matchSubtree(string, subtree[2])
|
|
1129
|
+
case '|':
|
|
1130
|
+
return matchSubtree(string, subtree[1]) || matchSubtree(string, subtree[2])
|
|
1131
|
+
default:
|
|
1132
|
+
return false // invalid search syntax
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function _sanitize (expression) {
|
|
1138
|
+
// handle substrings/quotes
|
|
1139
|
+
const quoted = []
|
|
1140
|
+
let quoteMode = false
|
|
1141
|
+
for (let i = 0; i < expression.length; i++) {
|
|
1142
|
+
if (quoteMode) {
|
|
1143
|
+
if (expression[i] === quoteMode) {
|
|
1144
|
+
// string end found
|
|
1145
|
+
quoteMode = false
|
|
1146
|
+
} else {
|
|
1147
|
+
// char in substring found
|
|
1148
|
+
quoted.push([' '].includes(expression[i]) ? NBSP : expression[i])
|
|
1149
|
+
}
|
|
1150
|
+
} else {
|
|
1151
|
+
if (["'", '"'].includes(expression[i])) {
|
|
1152
|
+
// substring start found
|
|
1153
|
+
quoteMode = expression[i]
|
|
1154
|
+
} else {
|
|
1155
|
+
// regular non-substring character
|
|
1156
|
+
quoted.push(expression[i])
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// handle remaining whitespace
|
|
1162
|
+
const trimmed = quoted.join('').replace(/\s+/g, ' ').trim()
|
|
1163
|
+
if (trimmed.length <= 0) return ''
|
|
1164
|
+
|
|
1165
|
+
const token = trimmed.split(' ')
|
|
1166
|
+
if (token.length <= 0) return ''
|
|
1167
|
+
|
|
1168
|
+
const sanitized = []
|
|
1169
|
+
if (!['NOT', '-'].includes(token[0])) sanitized.push(token.shift())
|
|
1170
|
+
|
|
1171
|
+
for (let i = 0; i < token.length; i++) {
|
|
1172
|
+
switch (token[i]) {
|
|
1173
|
+
case 'AND':
|
|
1174
|
+
case '&':
|
|
1175
|
+
case '&&':
|
|
1176
|
+
switch (token[++i]) {
|
|
1177
|
+
case 'NOT':
|
|
1178
|
+
case '-':
|
|
1179
|
+
if (token[i + 1]) {
|
|
1180
|
+
sanitized.push('&')
|
|
1181
|
+
sanitized.push('-')
|
|
1182
|
+
sanitized.push(token[++i])
|
|
1183
|
+
}
|
|
1184
|
+
break
|
|
1185
|
+
case undefined:
|
|
1186
|
+
break
|
|
1187
|
+
default:
|
|
1188
|
+
sanitized.push('&')
|
|
1189
|
+
sanitized.push(token[i])
|
|
1190
|
+
}
|
|
1191
|
+
break
|
|
1192
|
+
case 'OR':
|
|
1193
|
+
case '|':
|
|
1194
|
+
case '||':
|
|
1195
|
+
switch (token[++i]) {
|
|
1196
|
+
case 'NOT':
|
|
1197
|
+
case '-':
|
|
1198
|
+
if (token[i + 1]) {
|
|
1199
|
+
sanitized.push('|')
|
|
1200
|
+
sanitized.push('-')
|
|
1201
|
+
sanitized.push(token[++i])
|
|
1202
|
+
}
|
|
1203
|
+
break
|
|
1204
|
+
case undefined:
|
|
1205
|
+
break
|
|
1206
|
+
default:
|
|
1207
|
+
sanitized.push('|')
|
|
1208
|
+
sanitized.push(token[i])
|
|
1209
|
+
}
|
|
1210
|
+
break
|
|
1211
|
+
case 'NOT':
|
|
1212
|
+
case '-':
|
|
1213
|
+
sanitized.push('-')
|
|
1214
|
+
sanitized.push(token[++i])
|
|
1215
|
+
break
|
|
1216
|
+
default:
|
|
1217
|
+
sanitized.push('&') // default operation = AND
|
|
1218
|
+
sanitized.push(token[i])
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
return ` ${sanitized.join(' ')} `.replace(/ - /g, ' -').trim()
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function _tokenize (expression) {
|
|
1225
|
+
const OR = expression.indexOf(' | ')
|
|
1226
|
+
if (OR >= 0) {
|
|
1227
|
+
return ['|', _tokenize(expression.substring(0, OR)), _tokenize(expression.substring(OR + 3))]
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
const AND = expression.indexOf(' & ')
|
|
1231
|
+
if (AND >= 0) {
|
|
1232
|
+
return ['&', _tokenize(expression.substring(0, AND)), _tokenize(expression.substring(AND + 3))]
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
const SPACE = expression.indexOf(' ')
|
|
1236
|
+
if (SPACE >= 0) {
|
|
1237
|
+
return [
|
|
1238
|
+
'&',
|
|
1239
|
+
_tokenize(expression.substring(0, SPACE)),
|
|
1240
|
+
_tokenize(expression.substring(SPACE + 1))
|
|
1241
|
+
]
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
return expression
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
const ENV = {
|
|
1248
|
+
DEV: 'DEV',
|
|
1249
|
+
TEST: 'TEST',
|
|
1250
|
+
STAG: 'STAG',
|
|
1251
|
+
PROD: 'PROD'
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
const CP = {
|
|
1255
|
+
id: 'CP',
|
|
1256
|
+
subtitle: 'Access the Content Platform, manage, encode and watermark assets',
|
|
1257
|
+
title: 'Content Platform',
|
|
1258
|
+
urlManage: function (env, oid) {
|
|
1259
|
+
if (env === ENV.PROD) {
|
|
1260
|
+
return `https://platform.content.castlabs.com/#/o/${oid ?? ''}`
|
|
1261
|
+
} else {
|
|
1262
|
+
return `https://platform.content-stag.castlabs.com/#/o/${oid ?? ''}`
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
sidenav: false
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
const CS = {
|
|
1269
|
+
id: 'CS',
|
|
1270
|
+
subtitle: 'Manage organizations, plans, downloads',
|
|
1271
|
+
title: 'Castlabs hub',
|
|
1272
|
+
urlManage: function (env, oid) {
|
|
1273
|
+
return isDevTest(
|
|
1274
|
+
env,
|
|
1275
|
+
`https://account.test.cs.castlabs.com/o/${oid ?? ''}`,
|
|
1276
|
+
`https://account.castlabs.com/o/${oid ?? ''}`
|
|
1277
|
+
)
|
|
1278
|
+
},
|
|
1279
|
+
sidenav: true
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
const DT = {
|
|
1283
|
+
id: 'DT',
|
|
1284
|
+
subtitle: 'Cloud DRM & CAS licensing',
|
|
1285
|
+
title: 'DRMtoday',
|
|
1286
|
+
urlManage: function (env, oid) {
|
|
1287
|
+
return isDevTest(
|
|
1288
|
+
env,
|
|
1289
|
+
`https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
|
|
1290
|
+
`https://fe.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
|
|
1291
|
+
)
|
|
1292
|
+
},
|
|
1293
|
+
sidenav: true
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
const DTO = {
|
|
1297
|
+
id: 'DTO',
|
|
1298
|
+
subtitle: '',
|
|
1299
|
+
title: 'DRMtoday Onboard (staging)',
|
|
1300
|
+
urlManage: function (env, oid) {
|
|
1301
|
+
return `https://onboard.castlabs.com/o/${oid ?? ''}/devices`
|
|
1302
|
+
},
|
|
1303
|
+
sidenav: false
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
const DTS = {
|
|
1307
|
+
id: 'DTS',
|
|
1308
|
+
subtitle: 'Cloud DRM & CAS licensing',
|
|
1309
|
+
title: 'DRMtoday (staging)',
|
|
1310
|
+
urlManage: function (env, oid) {
|
|
1311
|
+
return isDevTest(
|
|
1312
|
+
env,
|
|
1313
|
+
`https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
|
|
1314
|
+
`https://fe.staging.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
|
|
1315
|
+
)
|
|
1316
|
+
},
|
|
1317
|
+
sidenav: false
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
const PP = {
|
|
1321
|
+
id: 'PP',
|
|
1322
|
+
subtitle: 'Cross-platform video players (via Castlabs hub)',
|
|
1323
|
+
title: 'PRESTOplay',
|
|
1324
|
+
urlManage: function (env, oid) {
|
|
1325
|
+
if (env === ENV.PROD) {
|
|
1326
|
+
return `https://account.castlabs.com/o/${oid}/prestoplay`
|
|
1327
|
+
} else {
|
|
1328
|
+
return `https://account.test.cs.castlabs.com/o/${oid}/prestoplay`
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
sidenav: true
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
const VTK = {
|
|
1335
|
+
id: 'VTK',
|
|
1336
|
+
subtitle: 'Cloud encoding, packaging, watermarking',
|
|
1337
|
+
title: 'Video Toolkit',
|
|
1338
|
+
urlManage: function (env) {
|
|
1339
|
+
if (env === ENV.PROD) {
|
|
1340
|
+
return 'https://vtk.castlabs.com/'
|
|
1341
|
+
} else {
|
|
1342
|
+
return 'https://vtks.castlabs.com/'
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
sidenav: true
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
const WM = {
|
|
1349
|
+
id: 'WM',
|
|
1350
|
+
subtitle: 'Video & image forensic watermarking',
|
|
1351
|
+
title: 'STARDUSTmark',
|
|
1352
|
+
urlManage: function (env, oid) {
|
|
1353
|
+
if (env === ENV.PROD) {
|
|
1354
|
+
return `https://watermark.castlabs.com/#/o/${oid}`
|
|
1355
|
+
} else {
|
|
1356
|
+
return `https://demo-stag.fwm.castlabs.com/#/o/${oid}`
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
sidenav: true
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
function isDevTest (env = ENV.PROD, urlDevTest, urlOther) {
|
|
1363
|
+
return [ENV.DEV, ENV.TEST].includes(env) ? urlDevTest : urlOther
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function clGetServices () {
|
|
1367
|
+
return [
|
|
1368
|
+
// sorted alphabeticaly by title
|
|
1369
|
+
CS,
|
|
1370
|
+
CP,
|
|
1371
|
+
DT,
|
|
1372
|
+
DTS,
|
|
1373
|
+
DTO,
|
|
1374
|
+
PP,
|
|
1375
|
+
WM,
|
|
1376
|
+
VTK
|
|
1377
|
+
]
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
const NAV = {
|
|
1381
|
+
CP,
|
|
1382
|
+
CS,
|
|
1383
|
+
DT,
|
|
1384
|
+
DTS,
|
|
1385
|
+
DTO,
|
|
1386
|
+
PP,
|
|
1387
|
+
WM,
|
|
1388
|
+
VTK
|
|
1389
|
+
}
|