@concord-consortium/lara-interactive-api 1.12.0-pre.1 → 1.13.0-pre.0
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/index-bundle.d.ts +15 -0
- package/index.js +16 -89
- package/package.json +1 -1
package/index-bundle.d.ts
CHANGED
|
@@ -110,9 +110,24 @@ interface IThemeInfo {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
declare type InteractiveItemId = string;
|
|
113
|
+
/**
|
|
114
|
+
* Represents a linked interactive element within the LARA system.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* This interface defines the structure for referencing an interactive component
|
|
118
|
+
* that is linked to another interactive or question. The questionId field is
|
|
119
|
+
* intentionally transient and should not be persisted in interactive state
|
|
120
|
+
* as it may change over time. The questionId field is also only set in the
|
|
121
|
+
* initInteractive message and is ignored in the setLinkedInteractives message.
|
|
122
|
+
*
|
|
123
|
+
* @property id - Unique identifier for the interactive item
|
|
124
|
+
* @property label - Human-readable label for the interactive
|
|
125
|
+
* @property questionId - Optional question identifier that should not be saved in state
|
|
126
|
+
*/
|
|
113
127
|
interface ILinkedInteractive {
|
|
114
128
|
id: InteractiveItemId;
|
|
115
129
|
label: string;
|
|
130
|
+
questionId?: string;
|
|
116
131
|
}
|
|
117
132
|
interface IAuthoringInitInteractive<AuthoredState = {}> {
|
|
118
133
|
version: 1;
|
package/index.js
CHANGED
|
@@ -2286,109 +2286,39 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2286
2286
|
/* harmony import */ var _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url-alphabet/index.js */ "./node_modules/nanoid/url-alphabet/index.js");
|
|
2287
2287
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "urlAlphabet", function() { return _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__["urlAlphabet"]; });
|
|
2288
2288
|
|
|
2289
|
-
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
2290
|
-
// according to `browser` config in `package.json`.
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
if (true) {
|
|
2295
|
-
// All bundlers will remove this block in the production bundle.
|
|
2296
|
-
if (
|
|
2297
|
-
typeof navigator !== 'undefined' &&
|
|
2298
|
-
navigator.product === 'ReactNative' &&
|
|
2299
|
-
typeof crypto === 'undefined'
|
|
2300
|
-
) {
|
|
2301
|
-
throw new Error(
|
|
2302
|
-
'React Native does not have a built-in secure random generator. ' +
|
|
2303
|
-
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
|
|
2304
|
-
'For secure IDs, import `react-native-get-random-values` ' +
|
|
2305
|
-
'before Nano ID.'
|
|
2306
|
-
)
|
|
2307
|
-
}
|
|
2308
|
-
if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
|
|
2309
|
-
throw new Error(
|
|
2310
|
-
'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +
|
|
2311
|
-
' before importing Nano ID to fix IE 11 support'
|
|
2312
|
-
)
|
|
2313
|
-
}
|
|
2314
|
-
if (typeof crypto === 'undefined') {
|
|
2315
|
-
throw new Error(
|
|
2316
|
-
'Your browser does not have secure random generator. ' +
|
|
2317
|
-
'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'
|
|
2318
|
-
)
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
2289
|
|
|
2322
2290
|
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
|
2323
|
-
|
|
2324
|
-
let customRandom = (alphabet, size, getRandom) => {
|
|
2325
|
-
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
|
2326
|
-
// values closer to the alphabet size. The bitmask calculates the closest
|
|
2327
|
-
// `2^31 - 1` number, which exceeds the alphabet size.
|
|
2328
|
-
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
|
2329
|
-
// `Math.clz32` is not used, because it is not available in browsers.
|
|
2291
|
+
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
2330
2292
|
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
// the random bytes redundancy has to be satisfied.
|
|
2334
|
-
|
|
2335
|
-
// Note: every hardware random generator call is performance expensive,
|
|
2336
|
-
// because the system call for entropy collection takes a lot of time.
|
|
2337
|
-
// So, to avoid additional system calls, extra bytes are requested in advance.
|
|
2338
|
-
|
|
2339
|
-
// Next, a step determines how many random bytes to generate.
|
|
2340
|
-
// The number of random bytes gets decided upon the ID size, mask,
|
|
2341
|
-
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
|
2342
|
-
// according to benchmarks).
|
|
2343
|
-
|
|
2344
|
-
// `-~f => Math.ceil(f)` if f is a float
|
|
2345
|
-
// `-~i => i + 1` if i is an integer
|
|
2346
|
-
let step = -~((1.6 * mask * size) / alphabet.length)
|
|
2347
|
-
|
|
2348
|
-
return () => {
|
|
2293
|
+
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
|
2294
|
+
return (size = defaultSize) => {
|
|
2349
2295
|
let id = ''
|
|
2350
2296
|
while (true) {
|
|
2351
2297
|
let bytes = getRandom(step)
|
|
2352
|
-
|
|
2353
|
-
let j = step
|
|
2298
|
+
let j = step | 0
|
|
2354
2299
|
while (j--) {
|
|
2355
|
-
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
|
2356
2300
|
id += alphabet[bytes[j] & mask] || ''
|
|
2357
2301
|
if (id.length === size) return id
|
|
2358
2302
|
}
|
|
2359
2303
|
}
|
|
2360
2304
|
}
|
|
2361
2305
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
let bytes = crypto.getRandomValues(new Uint8Array(size))
|
|
2368
|
-
|
|
2369
|
-
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
2370
|
-
while (size--) {
|
|
2371
|
-
// It is incorrect to use bytes exceeding the alphabet size.
|
|
2372
|
-
// The following mask reduces the random byte in the 0-255 value
|
|
2373
|
-
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
2374
|
-
// as empty string fallback or magic numbers, is unneccessary because
|
|
2375
|
-
// the bitmask trims bytes down to the alphabet size.
|
|
2376
|
-
let byte = bytes[size] & 63
|
|
2306
|
+
let customAlphabet = (alphabet, size = 21) =>
|
|
2307
|
+
customRandom(alphabet, size, random)
|
|
2308
|
+
let nanoid = (size = 21) =>
|
|
2309
|
+
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
2310
|
+
byte &= 63
|
|
2377
2311
|
if (byte < 36) {
|
|
2378
|
-
// `0-9a-z`
|
|
2379
2312
|
id += byte.toString(36)
|
|
2380
2313
|
} else if (byte < 62) {
|
|
2381
|
-
// `A-Z`
|
|
2382
2314
|
id += (byte - 26).toString(36).toUpperCase()
|
|
2383
|
-
} else if (byte
|
|
2384
|
-
id += '_'
|
|
2385
|
-
} else {
|
|
2315
|
+
} else if (byte > 62) {
|
|
2386
2316
|
id += '-'
|
|
2317
|
+
} else {
|
|
2318
|
+
id += '_'
|
|
2387
2319
|
}
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2320
|
+
return id
|
|
2321
|
+
}, '')
|
|
2392
2322
|
|
|
2393
2323
|
|
|
2394
2324
|
|
|
@@ -2404,11 +2334,8 @@ let nanoid = (size = 21) => {
|
|
|
2404
2334
|
"use strict";
|
|
2405
2335
|
__webpack_require__.r(__webpack_exports__);
|
|
2406
2336
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "urlAlphabet", function() { return urlAlphabet; });
|
|
2407
|
-
// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
|
|
2408
|
-
// optimize the gzip compression for this alphabet.
|
|
2409
2337
|
let urlAlphabet =
|
|
2410
|
-
'
|
|
2411
|
-
|
|
2338
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
2412
2339
|
|
|
2413
2340
|
|
|
2414
2341
|
|
|
@@ -5982,7 +5909,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5982
5909
|
/*! exports provided: name, version, description, main, types, repository, author, license, bugs, homepage, dependencies, peerDependencies, default */
|
|
5983
5910
|
/***/ (function(module) {
|
|
5984
5911
|
|
|
5985
|
-
module.exports = JSON.parse("{\"name\":\"@concord-consortium/lara-interactive-api\",\"version\":\"1.
|
|
5912
|
+
module.exports = JSON.parse("{\"name\":\"@concord-consortium/lara-interactive-api\",\"version\":\"1.13.0-pre.0\",\"description\":\"LARA Interactive API client and types\",\"main\":\"./index.js\",\"types\":\"./index-bundle.d.ts\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/concord-consortium/lara.git\"},\"author\":\"Concord Consortium\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/concord-consortium/lara/issues\"},\"homepage\":\"https://github.com/concord-consortium/lara/tree/master/lara-typescript/src/interactive-api-client#readme\",\"dependencies\":{\"iframe-phone\":\"^1.3.1\",\"nanoid\":\"^3.3.7\"},\"peerDependencies\":{\"react\":\">=16.9.0\",\"react-dom\":\">=16.9.0\"}}");
|
|
5986
5913
|
|
|
5987
5914
|
/***/ }),
|
|
5988
5915
|
|