@flowfuse/nr-launcher 1.13.3
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/CHANGELOG.md +182 -0
- package/LICENSE +178 -0
- package/README.md +28 -0
- package/index.js +148 -0
- package/lib/admin.js +95 -0
- package/lib/auditLogger/index.js +41 -0
- package/lib/auth/adminAuth.js +77 -0
- package/lib/auth/httpAuthMiddleware.js +71 -0
- package/lib/auth/httpAuthPlugin.js +10 -0
- package/lib/auth/strategy.js +34 -0
- package/lib/context/FFContextStorage.js +422 -0
- package/lib/context/index.js +9 -0
- package/lib/context/memoryCache.js +156 -0
- package/lib/launcher.js +695 -0
- package/lib/logBuffer.js +57 -0
- package/lib/resources/resourcePlugin.js +20 -0
- package/lib/resources/sample.js +57 -0
- package/lib/resources/sampleBuffer.js +85 -0
- package/lib/runtimeSettings.js +320 -0
- package/lib/storage/index.js +92 -0
- package/lib/storage/libraryPlugin.js +90 -0
- package/lib/theme/LICENSE +178 -0
- package/lib/theme/README.md +24 -0
- package/lib/theme/common/forge-common.css +108 -0
- package/lib/theme/common/forge-common.js +75 -0
- package/lib/theme/forge-dark/forge-dark-custom.css +2 -0
- package/lib/theme/forge-dark/forge-dark-custom.js +1 -0
- package/lib/theme/forge-dark/forge-dark-monaco.json +213 -0
- package/lib/theme/forge-dark/forge-dark-theme.css +12 -0
- package/lib/theme/forge-dark/forge-dark.js +61 -0
- package/lib/theme/forge-light/forge-light-custom.css +2 -0
- package/lib/theme/forge-light/forge-light-custom.js +1 -0
- package/lib/theme/forge-light/forge-light-monaco.json +227 -0
- package/lib/theme/forge-light/forge-light-theme.css +12 -0
- package/lib/theme/forge-light/forge-light.js +62 -0
- package/package.json +72 -0
- package/resources/favicon-16x16.png +0 -0
- package/resources/favicon-32x32.png +0 -0
- package/resources/favicon.ico +0 -0
- package/resources/ff-nr.png +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const util = require('@node-red/util').util
|
|
2
|
+
|
|
3
|
+
function Memory (config) {
|
|
4
|
+
this.data = config.data || {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Memory.prototype.open = function () {
|
|
8
|
+
return Promise.resolve()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Memory.prototype.close = function () {
|
|
12
|
+
return Promise.resolve()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Memory.prototype._getOne = function (scope, key) {
|
|
16
|
+
let value
|
|
17
|
+
if (this.data[scope]) {
|
|
18
|
+
try {
|
|
19
|
+
value = util.getObjectProperty(this.data[scope], key)
|
|
20
|
+
} catch (err) {
|
|
21
|
+
if (err.code === 'INVALID_EXPR') {
|
|
22
|
+
throw err
|
|
23
|
+
}
|
|
24
|
+
value = undefined
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return value
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Memory.prototype.get = function (scope, key, callback) {
|
|
31
|
+
let value
|
|
32
|
+
let error
|
|
33
|
+
if (!Array.isArray(key)) {
|
|
34
|
+
try {
|
|
35
|
+
value = this._getOne(scope, key)
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (!callback) {
|
|
38
|
+
throw err
|
|
39
|
+
}
|
|
40
|
+
error = err
|
|
41
|
+
}
|
|
42
|
+
if (callback) {
|
|
43
|
+
callback(error, value)
|
|
44
|
+
return
|
|
45
|
+
} else {
|
|
46
|
+
return value
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
value = []
|
|
51
|
+
for (let i = 0; i < key.length; i++) {
|
|
52
|
+
try {
|
|
53
|
+
value.push(this._getOne(scope, key[i]))
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (!callback) {
|
|
56
|
+
throw err
|
|
57
|
+
} else {
|
|
58
|
+
callback(err)
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (callback) {
|
|
64
|
+
callback.apply(null, [undefined].concat(value))
|
|
65
|
+
} else {
|
|
66
|
+
return value
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Memory.prototype.set = function (scope, key, value, callback) {
|
|
71
|
+
if (!this.data[scope]) {
|
|
72
|
+
this.data[scope] = {}
|
|
73
|
+
}
|
|
74
|
+
let error
|
|
75
|
+
if (!Array.isArray(key)) {
|
|
76
|
+
key = [key]
|
|
77
|
+
value = [value]
|
|
78
|
+
} else if (!Array.isArray(value)) {
|
|
79
|
+
// key is an array, but value is not - wrap it as an array
|
|
80
|
+
value = [value]
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
for (let i = 0; i < key.length; i++) {
|
|
84
|
+
let v = null
|
|
85
|
+
if (i < value.length) {
|
|
86
|
+
v = value[i]
|
|
87
|
+
}
|
|
88
|
+
util.setObjectProperty(this.data[scope], key[i], v)
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (callback) {
|
|
92
|
+
error = err
|
|
93
|
+
} else {
|
|
94
|
+
throw err
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (callback) {
|
|
98
|
+
callback(error)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Memory.prototype.keys = function (scope, callback) {
|
|
103
|
+
let values = []
|
|
104
|
+
let error
|
|
105
|
+
try {
|
|
106
|
+
if (this.data[scope]) {
|
|
107
|
+
if (scope !== 'global') {
|
|
108
|
+
values = Object.keys(this.data[scope])
|
|
109
|
+
} else {
|
|
110
|
+
values = Object.keys(this.data[scope]).filter(function (key) {
|
|
111
|
+
return key !== 'set' && key !== 'get' && key !== 'keys'
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
if (callback) {
|
|
117
|
+
error = err
|
|
118
|
+
} else {
|
|
119
|
+
throw err
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (callback) {
|
|
123
|
+
if (error) {
|
|
124
|
+
callback(error)
|
|
125
|
+
} else {
|
|
126
|
+
callback(null, values)
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
return values
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Memory.prototype.delete = function (scope) {
|
|
134
|
+
delete this.data[scope]
|
|
135
|
+
return Promise.resolve()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Memory.prototype.clean = function (activeNodes) {
|
|
139
|
+
for (const id in this.data) {
|
|
140
|
+
if (Object.hasOwn(this.data, id) && id !== 'global') {
|
|
141
|
+
const idParts = id.split(':')
|
|
142
|
+
if (activeNodes.indexOf(idParts[0]) === -1) {
|
|
143
|
+
delete this.data[id]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return Promise.resolve()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Memory.prototype._export = function () {
|
|
151
|
+
return this.data
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
module.exports = function (config) {
|
|
155
|
+
return new Memory(config)
|
|
156
|
+
}
|