summaryrefslogtreecommitdiffstats
path: root/rust/wolfree_sed_in_place/src/include_str.tsx
blob: 3c8ff4e5b6d12b34889f90345fcb54394e6fff16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
 * @license
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * This file is part of Wolfree.
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 */

// @ts-check

const wolfreeLexicalScopeName = (() => {
  const possibleLetters = Array();

  for (let i = 32; i < 127; i++) {
    possibleLetters.push(String.fromCharCode(i));
  }

  const possibleNames = possibleLetters.flatMap((x) =>
    possibleLetters.map((y) => x + y)
  );

  const isValid = (name = String()) => {
    try {
      return (
        typeof eval(name).value === "string" &&
        typeof eval(name).i2d === "boolean"
      );
    } catch (error) {
      return false;
    }
  };

  const wolfreeLexicalScopeName = possibleNames.find(isValid);

  if (typeof wolfreeLexicalScopeName !== "string") {
    console.error({ wolfreeLexicalScopeName });
    return "";
  }

  return wolfreeLexicalScopeName;
})();

(() => {
  const get = (params = String()) => {
    return new URLSearchParams(location.search).get(params);
  };

  eval(wolfreeLexicalScopeName).value = get("i") || "topic mathematics";
  eval(wolfreeLexicalScopeName).i2d = get("i2d") === "true";
})();

/**
 * Regex in regex - Rust
 * https://docs.rs/regex/latest/regex/struct.Regex.html#replacement-string-syntax
 * All instances of $ref in the replacement string are replaced with the substring corresponding to the capture group identified by ref.
 * ref may be an integer corresponding to the index of the capture group (counted by order of opening parenthesis where 0 is the entire match) or it can be a name (consisting of letters, digits or underscores) corresponding to a named capture group.
 */
// @ts-ignore
$0;

(async () => {
  (
    await import(
      // @ts-ignore
      "../../../ajax/libs/wolfree/23.7.8/js/Entrypoint.js"
    )
  ).default({
    input: eval(wolfreeLexicalScopeName).value,
    i2d: eval(wolfreeLexicalScopeName).i2d,
    extraPodstates: [],
  });
})();