@qodalis/cli-browser-storage 0.0.3 → 2.0.0-beta.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/package.json +16 -24
- package/public-api.d.mts +29 -0
- package/public-api.d.ts +29 -2
- package/public-api.js +254 -0
- package/public-api.js.map +1 -0
- package/public-api.mjs +250 -0
- package/public-api.mjs.map +1 -0
- package/umd/index.global.js +2896 -0
- package/README.md +0 -24
- package/esm2022/lib/cli-browser-storage.module.mjs +0 -26
- package/esm2022/lib/index.mjs +0 -3
- package/esm2022/lib/processors/cli-cookies-command-processor.mjs +0 -99
- package/esm2022/lib/processors/cli-local-storage-command-processor.mjs +0 -76
- package/esm2022/lib/version.mjs +0 -3
- package/esm2022/public-api.mjs +0 -6
- package/esm2022/qodalis-cli-browser-storage.mjs +0 -5
- package/fesm2022/qodalis-cli-browser-storage.mjs +0 -204
- package/fesm2022/qodalis-cli-browser-storage.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/cli-browser-storage.module.d.ts +0 -6
- package/lib/index.d.ts +0 -2
- package/lib/processors/cli-cookies-command-processor.d.ts +0 -15
- package/lib/processors/cli-local-storage-command-processor.d.ts +0 -15
- package/lib/version.d.ts +0 -1
- package/umd/index.js +0 -207
package/umd/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@qodalis/cli-core'), require('@angular/core')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['@qodalis/cli-core', '@angular/core'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.cliCore, global.ngCore));
|
|
5
|
-
})(this, (function (cliCore, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/******************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function __decorate(decorators, target, key, desc) {
|
|
25
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
27
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
28
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
-
var e = new Error(message);
|
|
33
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// Automatically generated during build
|
|
37
|
-
const LIBRARY_VERSION = '0.0.3';
|
|
38
|
-
|
|
39
|
-
let CliCookiesCommandProcessor = class CliCookiesCommandProcessor {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.command = 'cookies';
|
|
42
|
-
this.description = 'Interact with the cookies';
|
|
43
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
44
|
-
this.processors = [];
|
|
45
|
-
this.version = LIBRARY_VERSION;
|
|
46
|
-
this.metadata = {
|
|
47
|
-
requiredCoreVersion: '0.0.16',
|
|
48
|
-
requiredCliVersion: '1.0.37',
|
|
49
|
-
};
|
|
50
|
-
this.processors = [
|
|
51
|
-
{
|
|
52
|
-
command: 'list',
|
|
53
|
-
allowUnlistedCommands: true,
|
|
54
|
-
description: 'List all cookies',
|
|
55
|
-
processCommand: async (command, context) => {
|
|
56
|
-
const cookies = document.cookie.split('; ').reduce((acc, cookie) => {
|
|
57
|
-
const [cookieKey, cookieValue] = cookie.split('=');
|
|
58
|
-
acc[cookieKey] = decodeURIComponent(cookieValue || '');
|
|
59
|
-
return acc;
|
|
60
|
-
}, {});
|
|
61
|
-
for (const [key, value] of Object.entries(cookies)) {
|
|
62
|
-
context.writer.writeln(`${key}: ${value}`);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
command: 'get',
|
|
68
|
-
allowUnlistedCommands: true,
|
|
69
|
-
description: 'Get the value of a key',
|
|
70
|
-
processCommand: async (command, context) => {
|
|
71
|
-
const [key] = command.chainCommands.slice(2);
|
|
72
|
-
const cookies = document.cookie.split('; ').reduce((acc, cookie) => {
|
|
73
|
-
const [cookieKey, cookieValue] = cookie.split('=');
|
|
74
|
-
acc[cookieKey] = decodeURIComponent(cookieValue || '');
|
|
75
|
-
return acc;
|
|
76
|
-
}, {});
|
|
77
|
-
const value = cookies[key];
|
|
78
|
-
context.writer.writeln(value || 'null');
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
command: 'set',
|
|
83
|
-
allowUnlistedCommands: true,
|
|
84
|
-
description: 'Set the value of a key',
|
|
85
|
-
processCommand: async (command, context) => {
|
|
86
|
-
const [key, ...value] = command.chainCommands.slice(1);
|
|
87
|
-
const expires = new Date();
|
|
88
|
-
expires.setFullYear(expires.getFullYear() + 1);
|
|
89
|
-
document.cookie = `${key}=${encodeURIComponent(value.join(' '))};expires=${expires.toUTCString()};path=/`;
|
|
90
|
-
context.writer.writeSuccess('Cookie set successfully');
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
command: 'remove',
|
|
95
|
-
allowUnlistedCommands: true,
|
|
96
|
-
description: 'Remove a key',
|
|
97
|
-
processCommand: async (command, context) => {
|
|
98
|
-
const [key] = command.chainCommands.slice(1);
|
|
99
|
-
document.cookie = `${key}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;
|
|
100
|
-
context.writer.writeSuccess('Cookie removed successfully');
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
}
|
|
105
|
-
async processCommand(command, context) {
|
|
106
|
-
await context.executor.showHelp(command, context);
|
|
107
|
-
}
|
|
108
|
-
writeDescription(context) {
|
|
109
|
-
const { writer } = context;
|
|
110
|
-
writer.writeln('Read, write, and delete browser cookies');
|
|
111
|
-
writer.writeln();
|
|
112
|
-
writer.writeln('📋 Commands:');
|
|
113
|
-
writer.writeln(` ${writer.wrapInColor('cookies list', cliCore.CliForegroundColor.Cyan)} 🍪 List all cookies`);
|
|
114
|
-
writer.writeln(` ${writer.wrapInColor('cookies get <key>', cliCore.CliForegroundColor.Cyan)} Read a cookie value`);
|
|
115
|
-
writer.writeln(` ${writer.wrapInColor('cookies set <key> <value>', cliCore.CliForegroundColor.Cyan)} Write a cookie`);
|
|
116
|
-
writer.writeln(` ${writer.wrapInColor('cookies remove <key>', cliCore.CliForegroundColor.Cyan)} Delete a cookie`);
|
|
117
|
-
writer.writeln();
|
|
118
|
-
writer.writeln('📝 Examples:');
|
|
119
|
-
writer.writeln(` cookies set lang en ${writer.wrapInColor('# Set a cookie', cliCore.CliForegroundColor.Green)}`);
|
|
120
|
-
writer.writeln(` cookies get lang ${writer.wrapInColor('# Read a cookie', cliCore.CliForegroundColor.Green)}`);
|
|
121
|
-
writer.writeln(` cookies list ${writer.wrapInColor('# Show all cookies', cliCore.CliForegroundColor.Green)}`);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
CliCookiesCommandProcessor = __decorate([
|
|
125
|
-
core.Injectable({
|
|
126
|
-
providedIn: 'root',
|
|
127
|
-
})
|
|
128
|
-
], CliCookiesCommandProcessor);
|
|
129
|
-
|
|
130
|
-
let CliLocalStorageCommandProcessor = class CliLocalStorageCommandProcessor {
|
|
131
|
-
constructor() {
|
|
132
|
-
this.command = 'local-storage';
|
|
133
|
-
this.description = 'Interact with the local storage';
|
|
134
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
135
|
-
this.processors = [];
|
|
136
|
-
this.version = LIBRARY_VERSION;
|
|
137
|
-
this.metadata = {
|
|
138
|
-
requiredCoreVersion: '0.0.16',
|
|
139
|
-
requiredCliVersion: '1.0.37',
|
|
140
|
-
};
|
|
141
|
-
this.processors = [
|
|
142
|
-
{
|
|
143
|
-
command: 'get',
|
|
144
|
-
allowUnlistedCommands: true,
|
|
145
|
-
description: 'Get the value of a key',
|
|
146
|
-
processCommand: async (command, context) => {
|
|
147
|
-
const [key] = command.chainCommands.slice(1);
|
|
148
|
-
const value = localStorage.getItem(key);
|
|
149
|
-
context.writer.writeln(value || 'null');
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
command: 'set',
|
|
154
|
-
allowUnlistedCommands: true,
|
|
155
|
-
description: 'Set the value of a key',
|
|
156
|
-
processCommand: async (command, context) => {
|
|
157
|
-
const [key, ...value] = command.chainCommands.slice(1);
|
|
158
|
-
localStorage.setItem(key, value.join(' '));
|
|
159
|
-
context.writer.writeSuccess('Value set successfully');
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
command: 'remove',
|
|
164
|
-
allowUnlistedCommands: true,
|
|
165
|
-
description: 'Remove a key',
|
|
166
|
-
processCommand: async (command, context) => {
|
|
167
|
-
const [key] = command.chainCommands.slice(2);
|
|
168
|
-
localStorage.removeItem(key);
|
|
169
|
-
context.writer.writeSuccess('Key removed successfully');
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
}
|
|
174
|
-
async processCommand(command, context) {
|
|
175
|
-
await context.executor.showHelp(command, context);
|
|
176
|
-
}
|
|
177
|
-
writeDescription(context) {
|
|
178
|
-
const { writer } = context;
|
|
179
|
-
writer.writeln('Read, write, and delete keys from the browser local storage');
|
|
180
|
-
writer.writeln();
|
|
181
|
-
writer.writeln('📋 Commands:');
|
|
182
|
-
writer.writeln(` ${writer.wrapInColor('local-storage get <key>', cliCore.CliForegroundColor.Cyan)} Read a value`);
|
|
183
|
-
writer.writeln(` ${writer.wrapInColor('local-storage set <key> <value>', cliCore.CliForegroundColor.Cyan)} Write a value`);
|
|
184
|
-
writer.writeln(` ${writer.wrapInColor('local-storage remove <key>', cliCore.CliForegroundColor.Cyan)} Delete a key`);
|
|
185
|
-
writer.writeln();
|
|
186
|
-
writer.writeln('📝 Examples:');
|
|
187
|
-
writer.writeln(` local-storage set theme dark ${writer.wrapInColor('# Store a value', cliCore.CliForegroundColor.Green)}`);
|
|
188
|
-
writer.writeln(` local-storage get theme ${writer.wrapInColor('# Read a value', cliCore.CliForegroundColor.Green)}`);
|
|
189
|
-
writer.writeln(` local-storage remove theme ${writer.wrapInColor('# Delete a key', cliCore.CliForegroundColor.Green)}`);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
CliLocalStorageCommandProcessor = __decorate([
|
|
193
|
-
core.Injectable({
|
|
194
|
-
providedIn: 'root',
|
|
195
|
-
})
|
|
196
|
-
], CliLocalStorageCommandProcessor);
|
|
197
|
-
|
|
198
|
-
const module = {
|
|
199
|
-
name: '@qodalis/cli-browser-storage',
|
|
200
|
-
processors: [
|
|
201
|
-
new CliCookiesCommandProcessor(),
|
|
202
|
-
new CliLocalStorageCommandProcessor(),
|
|
203
|
-
],
|
|
204
|
-
};
|
|
205
|
-
cliCore.bootUmdModule(module);
|
|
206
|
-
|
|
207
|
-
}));
|