ru.Bee 1.3.2 → 1.4.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.
- checksums.yaml +4 -4
- data/bin/rubee +114 -88
- data/lib/app/views/app.tsx +27 -0
- data/lib/app/views/index.html +47 -0
- data/lib/app/views/layout.erb +3 -3
- data/lib/app/views/utils/redirectToBackend.tsx +9 -0
- data/lib/app/views/welcome_show.erb +1 -1
- data/lib/config/base_configuration.rb +15 -6
- data/lib/config/routes.rb +2 -1
- data/lib/db/create_accounts.rb +8 -8
- data/lib/db/create_comments.rb +7 -7
- data/lib/db/create_posts.rb +8 -8
- data/lib/db/create_users.rb +8 -8
- data/lib/db/structure.rb +42 -42
- data/lib/esbuild.config.js +33 -0
- data/lib/inits/print_colors.rb +1 -1
- data/lib/js/app.js +13 -0
- data/lib/js/app.js.map +7 -0
- data/lib/js/bundle.js +26157 -0
- data/lib/js/bundle.js.map +7 -0
- data/lib/node_modules/@types/cookie/LICENSE +21 -0
- data/lib/node_modules/@types/cookie/README.md +15 -0
- data/lib/node_modules/@types/cookie/index.d.ts +154 -0
- data/lib/node_modules/@types/cookie/package.json +30 -0
- data/lib/node_modules/cookie/LICENSE +24 -0
- data/lib/node_modules/cookie/README.md +248 -0
- data/lib/node_modules/cookie/dist/index.d.ts +114 -0
- data/lib/node_modules/cookie/dist/index.js +239 -0
- data/lib/node_modules/cookie/dist/index.js.map +1 -0
- data/lib/node_modules/cookie/package.json +42 -0
- data/lib/node_modules/js-tokens/CHANGELOG.md +151 -0
- data/lib/node_modules/js-tokens/LICENSE +21 -0
- data/lib/node_modules/js-tokens/README.md +240 -0
- data/lib/node_modules/js-tokens/index.js +23 -0
- data/lib/node_modules/js-tokens/package.json +30 -0
- data/lib/node_modules/loose-envify/LICENSE +21 -0
- data/lib/node_modules/loose-envify/README.md +45 -0
- data/lib/node_modules/loose-envify/cli.js +16 -0
- data/lib/node_modules/loose-envify/custom.js +4 -0
- data/lib/node_modules/loose-envify/index.js +3 -0
- data/lib/node_modules/loose-envify/loose-envify.js +36 -0
- data/lib/node_modules/loose-envify/package.json +36 -0
- data/lib/node_modules/loose-envify/replace.js +65 -0
- data/lib/node_modules/react/LICENSE +21 -0
- data/lib/node_modules/react/README.md +37 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1315 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +10 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +10 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.development.js +1333 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.production.min.js +11 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +11 -0
- data/lib/node_modules/react/cjs/react.development.js +2740 -0
- data/lib/node_modules/react/cjs/react.production.min.js +26 -0
- data/lib/node_modules/react/cjs/react.shared-subset.development.js +20 -0
- data/lib/node_modules/react/cjs/react.shared-subset.production.min.js +10 -0
- data/lib/node_modules/react/index.js +7 -0
- data/lib/node_modules/react/jsx-dev-runtime.js +7 -0
- data/lib/node_modules/react/jsx-runtime.js +7 -0
- data/lib/node_modules/react/package.json +47 -0
- data/lib/node_modules/react/react.shared-subset.js +7 -0
- data/lib/node_modules/react/umd/react.development.js +3343 -0
- data/lib/node_modules/react/umd/react.production.min.js +31 -0
- data/lib/node_modules/react/umd/react.profiling.min.js +31 -0
- data/lib/node_modules/react-dom/LICENSE +21 -0
- data/lib/node_modules/react-dom/README.md +60 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +7029 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +93 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +7093 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js +101 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.browser.development.js +7014 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +96 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.node.development.js +7070 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +102 -0
- data/lib/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1763 -0
- data/lib/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +40 -0
- data/lib/node_modules/react-dom/cjs/react-dom.development.js +29923 -0
- data/lib/node_modules/react-dom/cjs/react-dom.production.min.js +322 -0
- data/lib/node_modules/react-dom/cjs/react-dom.profiling.min.js +366 -0
- data/lib/node_modules/react-dom/client.js +25 -0
- data/lib/node_modules/react-dom/index.js +38 -0
- data/lib/node_modules/react-dom/package.json +62 -0
- data/lib/node_modules/react-dom/profiling.js +38 -0
- data/lib/node_modules/react-dom/server.browser.js +17 -0
- data/lib/node_modules/react-dom/server.js +3 -0
- data/lib/node_modules/react-dom/server.node.js +17 -0
- data/lib/node_modules/react-dom/test-utils.js +7 -0
- data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js +7026 -0
- data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.production.min.js +75 -0
- data/lib/node_modules/react-dom/umd/react-dom-server.browser.development.js +7011 -0
- data/lib/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +76 -0
- data/lib/node_modules/react-dom/umd/react-dom-test-utils.development.js +1759 -0
- data/lib/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +33 -0
- data/lib/node_modules/react-dom/umd/react-dom.development.js +29924 -0
- data/lib/node_modules/react-dom/umd/react-dom.production.min.js +267 -0
- data/lib/node_modules/react-dom/umd/react-dom.profiling.min.js +285 -0
- data/lib/node_modules/react-router/CHANGELOG.md +1526 -0
- data/lib/node_modules/react-router/LICENSE.md +23 -0
- data/lib/node_modules/react-router/README.md +7 -0
- data/lib/node_modules/react-router/dist/development/chunk-KNED5TY2.mjs +10476 -0
- data/lib/node_modules/react-router/dist/development/dom-export.d.mts +23 -0
- data/lib/node_modules/react-router/dist/development/dom-export.d.ts +23 -0
- data/lib/node_modules/react-router/dist/development/dom-export.js +6111 -0
- data/lib/node_modules/react-router/dist/development/dom-export.mjs +234 -0
- data/lib/node_modules/react-router/dist/development/fog-of-war-1hWhK5ey.d.mts +1690 -0
- data/lib/node_modules/react-router/dist/development/fog-of-war-oa9CGk10.d.ts +1690 -0
- data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.mts +21 -0
- data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.ts +21 -0
- data/lib/node_modules/react-router/dist/development/index.d.mts +841 -0
- data/lib/node_modules/react-router/dist/development/index.d.ts +841 -0
- data/lib/node_modules/react-router/dist/development/index.js +10624 -0
- data/lib/node_modules/react-router/dist/development/index.mjs +242 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.mts +209 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.ts +209 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.js +28 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.mjs +10 -0
- data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.mts +1716 -0
- data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.ts +1716 -0
- data/lib/node_modules/react-router/dist/production/chunk-ZIM7OIE3.mjs +10476 -0
- data/lib/node_modules/react-router/dist/production/dom-export.d.mts +23 -0
- data/lib/node_modules/react-router/dist/production/dom-export.d.ts +23 -0
- data/lib/node_modules/react-router/dist/production/dom-export.js +6111 -0
- data/lib/node_modules/react-router/dist/production/dom-export.mjs +234 -0
- data/lib/node_modules/react-router/dist/production/fog-of-war-1hWhK5ey.d.mts +1690 -0
- data/lib/node_modules/react-router/dist/production/fog-of-war-oa9CGk10.d.ts +1690 -0
- data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.mts +21 -0
- data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.ts +21 -0
- data/lib/node_modules/react-router/dist/production/index.d.mts +841 -0
- data/lib/node_modules/react-router/dist/production/index.d.ts +841 -0
- data/lib/node_modules/react-router/dist/production/index.js +10624 -0
- data/lib/node_modules/react-router/dist/production/index.mjs +242 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.mts +209 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.ts +209 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.js +28 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.mjs +10 -0
- data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.mts +1716 -0
- data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.ts +1716 -0
- data/lib/node_modules/react-router/package.json +116 -0
- data/lib/node_modules/react-router-dom/LICENSE.md +23 -0
- data/lib/node_modules/react-router-dom/README.md +6 -0
- data/lib/node_modules/react-router-dom/dist/index.d.mts +2 -0
- data/lib/node_modules/react-router-dom/dist/index.d.ts +2 -0
- data/lib/node_modules/react-router-dom/dist/index.js +45 -0
- data/lib/node_modules/react-router-dom/dist/index.mjs +18 -0
- data/lib/node_modules/react-router-dom/package.json +82 -0
- data/lib/node_modules/scheduler/LICENSE +21 -0
- data/lib/node_modules/scheduler/README.md +9 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +700 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.development.js +207 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.production.min.js +14 -0
- data/lib/node_modules/scheduler/cjs/scheduler.development.js +634 -0
- data/lib/node_modules/scheduler/cjs/scheduler.production.min.js +19 -0
- data/lib/node_modules/scheduler/index.js +7 -0
- data/lib/node_modules/scheduler/package.json +36 -0
- data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +699 -0
- data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +19 -0
- data/lib/node_modules/scheduler/umd/scheduler.development.js +152 -0
- data/lib/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
- data/lib/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
- data/lib/node_modules/scheduler/unstable_mock.js +7 -0
- data/lib/node_modules/scheduler/unstable_post_task.js +7 -0
- data/lib/node_modules/set-cookie-parser/LICENSE +21 -0
- data/lib/node_modules/set-cookie-parser/README.md +202 -0
- data/lib/node_modules/set-cookie-parser/lib/set-cookie.js +224 -0
- data/lib/node_modules/set-cookie-parser/package.json +45 -0
- data/lib/node_modules/turbo-stream/LICENSE +7 -0
- data/lib/node_modules/turbo-stream/README.md +31 -0
- data/lib/node_modules/turbo-stream/dist/flatten.d.ts +2 -0
- data/lib/node_modules/turbo-stream/dist/flatten.js +203 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.d.ts +13 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.js +207 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.mjs +673 -0
- data/lib/node_modules/turbo-stream/dist/unflatten.d.ts +2 -0
- data/lib/node_modules/turbo-stream/dist/unflatten.js +243 -0
- data/lib/node_modules/turbo-stream/dist/utils.d.ts +44 -0
- data/lib/node_modules/turbo-stream/dist/utils.js +55 -0
- data/lib/node_modules/turbo-stream/package.json +50 -0
- data/lib/package-lock.json +133 -0
- data/lib/package.json +12 -0
- data/lib/rubee/async/asyncable.rb +2 -2
- data/lib/rubee/async/sidekiq_async.rb +11 -11
- data/lib/rubee/async/thread_async.rb +1 -1
- data/lib/rubee/async/thread_pool.rb +2 -2
- data/lib/rubee/controllers/base_controller.rb +44 -21
- data/lib/rubee/controllers/extensions/auth_tokenable.rb +10 -8
- data/lib/rubee/controllers/extensions/middlewarable.rb +1 -1
- data/lib/rubee/controllers/middlewares/auth_token_middleware.rb +12 -8
- data/lib/rubee/extensions/hookable.rb +3 -6
- data/lib/rubee/extensions/serializable.rb +3 -3
- data/lib/rubee/models/database_objectable.rb +11 -12
- data/lib/rubee/models/sequel_object.rb +23 -24
- data/lib/rubee.rb +106 -55
- data/lib/tests/account_model_test.rb +4 -4
- data/lib/tests/auth_tokenable_test.rb +6 -6
- data/lib/tests/comment_model_test.rb +7 -7
- data/lib/tests/example_models/account.rb +1 -0
- data/lib/tests/example_models/comment.rb +1 -0
- data/lib/tests/example_models/post.rb +1 -0
- data/lib/tests/example_models/user.rb +1 -0
- data/lib/tests/rubeeapp_test.rb +21 -6
- data/lib/tests/test.db +0 -0
- data/lib/tests/test_helper.rb +3 -5
- data/lib/tests/user_model_test.rb +71 -54
- data/readme.md +104 -2
- metadata +170 -3
@@ -0,0 +1,240 @@
|
|
1
|
+
Overview [](https://travis-ci.org/lydell/js-tokens)
|
2
|
+
========
|
3
|
+
|
4
|
+
A regex that tokenizes JavaScript.
|
5
|
+
|
6
|
+
```js
|
7
|
+
var jsTokens = require("js-tokens").default
|
8
|
+
|
9
|
+
var jsString = "var foo=opts.foo;\n..."
|
10
|
+
|
11
|
+
jsString.match(jsTokens)
|
12
|
+
// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
Installation
|
17
|
+
============
|
18
|
+
|
19
|
+
`npm install js-tokens`
|
20
|
+
|
21
|
+
```js
|
22
|
+
import jsTokens from "js-tokens"
|
23
|
+
// or:
|
24
|
+
var jsTokens = require("js-tokens").default
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
Usage
|
29
|
+
=====
|
30
|
+
|
31
|
+
### `jsTokens` ###
|
32
|
+
|
33
|
+
A regex with the `g` flag that matches JavaScript tokens.
|
34
|
+
|
35
|
+
The regex _always_ matches, even invalid JavaScript and the empty string.
|
36
|
+
|
37
|
+
The next match is always directly after the previous.
|
38
|
+
|
39
|
+
### `var token = matchToToken(match)` ###
|
40
|
+
|
41
|
+
```js
|
42
|
+
import {matchToToken} from "js-tokens"
|
43
|
+
// or:
|
44
|
+
var matchToToken = require("js-tokens").matchToToken
|
45
|
+
```
|
46
|
+
|
47
|
+
Takes a `match` returned by `jsTokens.exec(string)`, and returns a `{type:
|
48
|
+
String, value: String}` object. The following types are available:
|
49
|
+
|
50
|
+
- string
|
51
|
+
- comment
|
52
|
+
- regex
|
53
|
+
- number
|
54
|
+
- name
|
55
|
+
- punctuator
|
56
|
+
- whitespace
|
57
|
+
- invalid
|
58
|
+
|
59
|
+
Multi-line comments and strings also have a `closed` property indicating if the
|
60
|
+
token was closed or not (see below).
|
61
|
+
|
62
|
+
Comments and strings both come in several flavors. To distinguish them, check if
|
63
|
+
the token starts with `//`, `/*`, `'`, `"` or `` ` ``.
|
64
|
+
|
65
|
+
Names are ECMAScript IdentifierNames, that is, including both identifiers and
|
66
|
+
keywords. You may use [is-keyword-js] to tell them apart.
|
67
|
+
|
68
|
+
Whitespace includes both line terminators and other whitespace.
|
69
|
+
|
70
|
+
[is-keyword-js]: https://github.com/crissdev/is-keyword-js
|
71
|
+
|
72
|
+
|
73
|
+
ECMAScript support
|
74
|
+
==================
|
75
|
+
|
76
|
+
The intention is to always support the latest ECMAScript version whose feature
|
77
|
+
set has been finalized.
|
78
|
+
|
79
|
+
If adding support for a newer version requires changes, a new version with a
|
80
|
+
major verion bump will be released.
|
81
|
+
|
82
|
+
Currently, ECMAScript 2018 is supported.
|
83
|
+
|
84
|
+
|
85
|
+
Invalid code handling
|
86
|
+
=====================
|
87
|
+
|
88
|
+
Unterminated strings are still matched as strings. JavaScript strings cannot
|
89
|
+
contain (unescaped) newlines, so unterminated strings simply end at the end of
|
90
|
+
the line. Unterminated template strings can contain unescaped newlines, though,
|
91
|
+
so they go on to the end of input.
|
92
|
+
|
93
|
+
Unterminated multi-line comments are also still matched as comments. They
|
94
|
+
simply go on to the end of the input.
|
95
|
+
|
96
|
+
Unterminated regex literals are likely matched as division and whatever is
|
97
|
+
inside the regex.
|
98
|
+
|
99
|
+
Invalid ASCII characters have their own capturing group.
|
100
|
+
|
101
|
+
Invalid non-ASCII characters are treated as names, to simplify the matching of
|
102
|
+
names (except unicode spaces which are treated as whitespace). Note: See also
|
103
|
+
the [ES2018](#es2018) section.
|
104
|
+
|
105
|
+
Regex literals may contain invalid regex syntax. They are still matched as
|
106
|
+
regex literals. They may also contain repeated regex flags, to keep the regex
|
107
|
+
simple.
|
108
|
+
|
109
|
+
Strings may contain invalid escape sequences.
|
110
|
+
|
111
|
+
|
112
|
+
Limitations
|
113
|
+
===========
|
114
|
+
|
115
|
+
Tokenizing JavaScript using regexes—in fact, _one single regex_—won’t be
|
116
|
+
perfect. But that’s not the point either.
|
117
|
+
|
118
|
+
You may compare jsTokens with [esprima] by using `esprima-compare.js`.
|
119
|
+
See `npm run esprima-compare`!
|
120
|
+
|
121
|
+
[esprima]: http://esprima.org/
|
122
|
+
|
123
|
+
### Template string interpolation ###
|
124
|
+
|
125
|
+
Template strings are matched as single tokens, from the starting `` ` `` to the
|
126
|
+
ending `` ` ``, including interpolations (whose tokens are not matched
|
127
|
+
individually).
|
128
|
+
|
129
|
+
Matching template string interpolations requires recursive balancing of `{` and
|
130
|
+
`}`—something that JavaScript regexes cannot do. Only one level of nesting is
|
131
|
+
supported.
|
132
|
+
|
133
|
+
### Division and regex literals collision ###
|
134
|
+
|
135
|
+
Consider this example:
|
136
|
+
|
137
|
+
```js
|
138
|
+
var g = 9.82
|
139
|
+
var number = bar / 2/g
|
140
|
+
|
141
|
+
var regex = / 2/g
|
142
|
+
```
|
143
|
+
|
144
|
+
A human can easily understand that in the `number` line we’re dealing with
|
145
|
+
division, and in the `regex` line we’re dealing with a regex literal. How come?
|
146
|
+
Because humans can look at the whole code to put the `/` characters in context.
|
147
|
+
A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also
|
148
|
+
look backwards. See the [ES2018](#es2018) section).
|
149
|
+
|
150
|
+
When the `jsTokens` regex scans throught the above, it will see the following
|
151
|
+
at the end of both the `number` and `regex` rows:
|
152
|
+
|
153
|
+
```js
|
154
|
+
/ 2/g
|
155
|
+
```
|
156
|
+
|
157
|
+
It is then impossible to know if that is a regex literal, or part of an
|
158
|
+
expression dealing with division.
|
159
|
+
|
160
|
+
Here is a similar case:
|
161
|
+
|
162
|
+
```js
|
163
|
+
foo /= 2/g
|
164
|
+
foo(/= 2/g)
|
165
|
+
```
|
166
|
+
|
167
|
+
The first line divides the `foo` variable with `2/g`. The second line calls the
|
168
|
+
`foo` function with the regex literal `/= 2/g`. Again, since `jsTokens` only
|
169
|
+
sees forwards, it cannot tell the two cases apart.
|
170
|
+
|
171
|
+
There are some cases where we _can_ tell division and regex literals apart,
|
172
|
+
though.
|
173
|
+
|
174
|
+
First off, we have the simple cases where there’s only one slash in the line:
|
175
|
+
|
176
|
+
```js
|
177
|
+
var foo = 2/g
|
178
|
+
foo /= 2
|
179
|
+
```
|
180
|
+
|
181
|
+
Regex literals cannot contain newlines, so the above cases are correctly
|
182
|
+
identified as division. Things are only problematic when there are more than
|
183
|
+
one non-comment slash in a single line.
|
184
|
+
|
185
|
+
Secondly, not every character is a valid regex flag.
|
186
|
+
|
187
|
+
```js
|
188
|
+
var number = bar / 2/e
|
189
|
+
```
|
190
|
+
|
191
|
+
The above example is also correctly identified as division, because `e` is not a
|
192
|
+
valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*`
|
193
|
+
(any letter) as flags, but it is not worth it since it increases the amount of
|
194
|
+
ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are
|
195
|
+
allowed. This means that the above example will be identified as division as
|
196
|
+
long as you don’t rename the `e` variable to some permutation of `gmiyus` 1 to 6
|
197
|
+
characters long.
|
198
|
+
|
199
|
+
Lastly, we can look _forward_ for information.
|
200
|
+
|
201
|
+
- If the token following what looks like a regex literal is not valid after a
|
202
|
+
regex literal, but is valid in a division expression, then the regex literal
|
203
|
+
is treated as division instead. For example, a flagless regex cannot be
|
204
|
+
followed by a string, number or name, but all of those three can be the
|
205
|
+
denominator of a division.
|
206
|
+
- Generally, if what looks like a regex literal is followed by an operator, the
|
207
|
+
regex literal is treated as division instead. This is because regexes are
|
208
|
+
seldomly used with operators (such as `+`, `*`, `&&` and `==`), but division
|
209
|
+
could likely be part of such an expression.
|
210
|
+
|
211
|
+
Please consult the regex source and the test cases for precise information on
|
212
|
+
when regex or division is matched (should you need to know). In short, you
|
213
|
+
could sum it up as:
|
214
|
+
|
215
|
+
If the end of a statement looks like a regex literal (even if it isn’t), it
|
216
|
+
will be treated as one. Otherwise it should work as expected (if you write sane
|
217
|
+
code).
|
218
|
+
|
219
|
+
### ES2018 ###
|
220
|
+
|
221
|
+
ES2018 added some nice regex improvements to the language.
|
222
|
+
|
223
|
+
- [Unicode property escapes] should allow telling names and invalid non-ASCII
|
224
|
+
characters apart without blowing up the regex size.
|
225
|
+
- [Lookbehind assertions] should allow matching telling division and regex
|
226
|
+
literals apart in more cases.
|
227
|
+
- [Named capture groups] might simplify some things.
|
228
|
+
|
229
|
+
These things would be nice to do, but are not critical. They probably have to
|
230
|
+
wait until the oldest maintained Node.js LTS release supports those features.
|
231
|
+
|
232
|
+
[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html
|
233
|
+
[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html
|
234
|
+
[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html
|
235
|
+
|
236
|
+
|
237
|
+
License
|
238
|
+
=======
|
239
|
+
|
240
|
+
[MIT](LICENSE).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
2
|
+
// License: MIT. (See LICENSE.)
|
3
|
+
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
})
|
7
|
+
|
8
|
+
// This regex comes from regex.coffee, and is inserted here by generate-index.js
|
9
|
+
// (run `npm run build`).
|
10
|
+
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
|
11
|
+
|
12
|
+
exports.matchToToken = function(match) {
|
13
|
+
var token = {type: "invalid", value: match[0], closed: undefined}
|
14
|
+
if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
|
15
|
+
else if (match[ 5]) token.type = "comment"
|
16
|
+
else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
|
17
|
+
else if (match[ 8]) token.type = "regex"
|
18
|
+
else if (match[ 9]) token.type = "number"
|
19
|
+
else if (match[10]) token.type = "name"
|
20
|
+
else if (match[11]) token.type = "punctuator"
|
21
|
+
else if (match[12]) token.type = "whitespace"
|
22
|
+
return token
|
23
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "js-tokens",
|
3
|
+
"version": "4.0.0",
|
4
|
+
"author": "Simon Lydell",
|
5
|
+
"license": "MIT",
|
6
|
+
"description": "A regex that tokenizes JavaScript.",
|
7
|
+
"keywords": [
|
8
|
+
"JavaScript",
|
9
|
+
"js",
|
10
|
+
"token",
|
11
|
+
"tokenize",
|
12
|
+
"regex"
|
13
|
+
],
|
14
|
+
"files": [
|
15
|
+
"index.js"
|
16
|
+
],
|
17
|
+
"repository": "lydell/js-tokens",
|
18
|
+
"scripts": {
|
19
|
+
"test": "mocha --ui tdd",
|
20
|
+
"esprima-compare": "node esprima-compare ./index.js everything.js/es5.js",
|
21
|
+
"build": "node generate-index.js",
|
22
|
+
"dev": "npm run build && npm test"
|
23
|
+
},
|
24
|
+
"devDependencies": {
|
25
|
+
"coffeescript": "2.1.1",
|
26
|
+
"esprima": "4.0.0",
|
27
|
+
"everything.js": "1.0.3",
|
28
|
+
"mocha": "5.0.0"
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andres Suarez <zertosh@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# loose-envify
|
2
|
+
|
3
|
+
[](https://travis-ci.org/zertosh/loose-envify)
|
4
|
+
|
5
|
+
Fast (and loose) selective `process.env` replacer using [js-tokens](https://github.com/lydell/js-tokens) instead of an AST. Works just like [envify](https://github.com/hughsk/envify) but much faster.
|
6
|
+
|
7
|
+
## Gotchas
|
8
|
+
|
9
|
+
* Doesn't handle broken syntax.
|
10
|
+
* Doesn't look inside embedded expressions in template strings.
|
11
|
+
- **this won't work:**
|
12
|
+
```js
|
13
|
+
console.log(`the current env is ${process.env.NODE_ENV}`);
|
14
|
+
```
|
15
|
+
* Doesn't replace oddly-spaced or oddly-commented expressions.
|
16
|
+
- **this won't work:**
|
17
|
+
```js
|
18
|
+
console.log(process./*won't*/env./*work*/NODE_ENV);
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage/Options
|
22
|
+
|
23
|
+
loose-envify has the exact same interface as [envify](https://github.com/hughsk/envify), including the CLI.
|
24
|
+
|
25
|
+
## Benchmark
|
26
|
+
|
27
|
+
```
|
28
|
+
envify:
|
29
|
+
|
30
|
+
$ for i in {1..5}; do node bench/bench.js 'envify'; done
|
31
|
+
708ms
|
32
|
+
727ms
|
33
|
+
791ms
|
34
|
+
719ms
|
35
|
+
720ms
|
36
|
+
|
37
|
+
loose-envify:
|
38
|
+
|
39
|
+
$ for i in {1..5}; do node bench/bench.js '../'; done
|
40
|
+
51ms
|
41
|
+
52ms
|
42
|
+
52ms
|
43
|
+
52ms
|
44
|
+
52ms
|
45
|
+
```
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var looseEnvify = require('./');
|
5
|
+
var fs = require('fs');
|
6
|
+
|
7
|
+
if (process.argv[2]) {
|
8
|
+
fs.createReadStream(process.argv[2], {encoding: 'utf8'})
|
9
|
+
.pipe(looseEnvify(process.argv[2]))
|
10
|
+
.pipe(process.stdout);
|
11
|
+
} else {
|
12
|
+
process.stdin.resume()
|
13
|
+
process.stdin
|
14
|
+
.pipe(looseEnvify(__filename))
|
15
|
+
.pipe(process.stdout);
|
16
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var stream = require('stream');
|
4
|
+
var util = require('util');
|
5
|
+
var replace = require('./replace');
|
6
|
+
|
7
|
+
var jsonExtRe = /\.json$/;
|
8
|
+
|
9
|
+
module.exports = function(rootEnv) {
|
10
|
+
rootEnv = rootEnv || process.env;
|
11
|
+
return function (file, trOpts) {
|
12
|
+
if (jsonExtRe.test(file)) {
|
13
|
+
return stream.PassThrough();
|
14
|
+
}
|
15
|
+
var envs = trOpts ? [rootEnv, trOpts] : [rootEnv];
|
16
|
+
return new LooseEnvify(envs);
|
17
|
+
};
|
18
|
+
};
|
19
|
+
|
20
|
+
function LooseEnvify(envs) {
|
21
|
+
stream.Transform.call(this);
|
22
|
+
this._data = '';
|
23
|
+
this._envs = envs;
|
24
|
+
}
|
25
|
+
util.inherits(LooseEnvify, stream.Transform);
|
26
|
+
|
27
|
+
LooseEnvify.prototype._transform = function(buf, enc, cb) {
|
28
|
+
this._data += buf;
|
29
|
+
cb();
|
30
|
+
};
|
31
|
+
|
32
|
+
LooseEnvify.prototype._flush = function(cb) {
|
33
|
+
var replaced = replace(this._data, this._envs);
|
34
|
+
this.push(replaced);
|
35
|
+
cb();
|
36
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"name": "loose-envify",
|
3
|
+
"version": "1.4.0",
|
4
|
+
"description": "Fast (and loose) selective `process.env` replacer using js-tokens instead of an AST",
|
5
|
+
"keywords": [
|
6
|
+
"environment",
|
7
|
+
"variables",
|
8
|
+
"browserify",
|
9
|
+
"browserify-transform",
|
10
|
+
"transform",
|
11
|
+
"source",
|
12
|
+
"configuration"
|
13
|
+
],
|
14
|
+
"homepage": "https://github.com/zertosh/loose-envify",
|
15
|
+
"license": "MIT",
|
16
|
+
"author": "Andres Suarez <zertosh@gmail.com>",
|
17
|
+
"main": "index.js",
|
18
|
+
"bin": {
|
19
|
+
"loose-envify": "cli.js"
|
20
|
+
},
|
21
|
+
"repository": {
|
22
|
+
"type": "git",
|
23
|
+
"url": "git://github.com/zertosh/loose-envify.git"
|
24
|
+
},
|
25
|
+
"scripts": {
|
26
|
+
"test": "tap test/*.js"
|
27
|
+
},
|
28
|
+
"dependencies": {
|
29
|
+
"js-tokens": "^3.0.0 || ^4.0.0"
|
30
|
+
},
|
31
|
+
"devDependencies": {
|
32
|
+
"browserify": "^13.1.1",
|
33
|
+
"envify": "^3.4.0",
|
34
|
+
"tap": "^8.0.0"
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var jsTokens = require('js-tokens').default;
|
4
|
+
|
5
|
+
var processEnvRe = /\bprocess\.env\.[_$a-zA-Z][$\w]+\b/;
|
6
|
+
var spaceOrCommentRe = /^(?:\s|\/[/*])/;
|
7
|
+
|
8
|
+
function replace(src, envs) {
|
9
|
+
if (!processEnvRe.test(src)) {
|
10
|
+
return src;
|
11
|
+
}
|
12
|
+
|
13
|
+
var out = [];
|
14
|
+
var purge = envs.some(function(env) {
|
15
|
+
return env._ && env._.indexOf('purge') !== -1;
|
16
|
+
});
|
17
|
+
|
18
|
+
jsTokens.lastIndex = 0
|
19
|
+
var parts = src.match(jsTokens);
|
20
|
+
|
21
|
+
for (var i = 0; i < parts.length; i++) {
|
22
|
+
if (parts[i ] === 'process' &&
|
23
|
+
parts[i + 1] === '.' &&
|
24
|
+
parts[i + 2] === 'env' &&
|
25
|
+
parts[i + 3] === '.') {
|
26
|
+
var prevCodeToken = getAdjacentCodeToken(-1, parts, i);
|
27
|
+
var nextCodeToken = getAdjacentCodeToken(1, parts, i + 4);
|
28
|
+
var replacement = getReplacementString(envs, parts[i + 4], purge);
|
29
|
+
if (prevCodeToken !== '.' &&
|
30
|
+
nextCodeToken !== '.' &&
|
31
|
+
nextCodeToken !== '=' &&
|
32
|
+
typeof replacement === 'string') {
|
33
|
+
out.push(replacement);
|
34
|
+
i += 4;
|
35
|
+
continue;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
out.push(parts[i]);
|
39
|
+
}
|
40
|
+
|
41
|
+
return out.join('');
|
42
|
+
}
|
43
|
+
|
44
|
+
function getAdjacentCodeToken(dir, parts, i) {
|
45
|
+
while (true) {
|
46
|
+
var part = parts[i += dir];
|
47
|
+
if (!spaceOrCommentRe.test(part)) {
|
48
|
+
return part;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function getReplacementString(envs, name, purge) {
|
54
|
+
for (var j = 0; j < envs.length; j++) {
|
55
|
+
var env = envs[j];
|
56
|
+
if (typeof env[name] !== 'undefined') {
|
57
|
+
return JSON.stringify(env[name]);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
if (purge) {
|
61
|
+
return 'undefined';
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = replace;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# `react`
|
2
|
+
|
3
|
+
React is a JavaScript library for creating user interfaces.
|
4
|
+
|
5
|
+
The `react` package contains only the functionality necessary to define React components. It is typically used together with a React renderer like `react-dom` for the web, or `react-native` for the native environments.
|
6
|
+
|
7
|
+
**Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. Don't forget to use the [production build](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) when deploying your application.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```js
|
12
|
+
import { useState } from 'react';
|
13
|
+
import { createRoot } from 'react-dom/client';
|
14
|
+
|
15
|
+
function Counter() {
|
16
|
+
const [count, setCount] = useState(0);
|
17
|
+
return (
|
18
|
+
<>
|
19
|
+
<h1>{count}</h1>
|
20
|
+
<button onClick={() => setCount(count + 1)}>
|
21
|
+
Increment
|
22
|
+
</button>
|
23
|
+
</>
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
const root = createRoot(document.getElementById('root'));
|
28
|
+
root.render(<App />);
|
29
|
+
```
|
30
|
+
|
31
|
+
## Documentation
|
32
|
+
|
33
|
+
See https://reactjs.org/
|
34
|
+
|
35
|
+
## API
|
36
|
+
|
37
|
+
See https://reactjs.org/docs/react-api.html
|