squared 0.3.13 → 0.3.14
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/CHANGELOG.md +64 -40
- data/README.md +387 -1274
- data/lib/squared/common/base.rb +1 -1
- data/lib/squared/common/format.rb +2 -2
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +8 -3
- data/lib/squared/workspace/project/base.rb +25 -2
- data/lib/squared/workspace/project/node.rb +4 -1
- data/lib/squared/workspace/project/ruby.rb +1 -1
- data/squared.gemspec +4 -4
- metadata +5 -6
- data/README.ruby.md +0 -466
data/README.md
CHANGED
@@ -1,1351 +1,464 @@
|
|
1
|
-
# squared
|
1
|
+
# squared 0.3
|
2
2
|
|
3
|
-
|
3
|
+
* [source](https://github.com/anpham6/squared-ruby)
|
4
|
+
* [manifest](https://github.com/anpham6/squared-repo)
|
5
|
+
* [docs](https://squared.readthedocs.io)
|
4
6
|
|
5
|
-
|
7
|
+
## Version Compatibility
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
| Date | squared | Min | Max | Git |
|
10
|
+
| :--------: | ------: | -----: | -----: | -----: |
|
11
|
+
| 2024-12-07 | 0.1.0 | 2.4.0 | 3.3.6 | 2.39 |
|
12
|
+
| 2025-01-07 | 0.2.0 | 2.4.0 | 3.4.0 | 2.39 |
|
13
|
+
| 2025-02-07 | 0.3.0 | 2.4.0 | 3.4.1 | 2.39 |
|
9
14
|
|
10
|
-
|
11
|
-
> Content in the README was migrated into `Read the Docs`. The file is no longer fully maintained.
|
12
|
-
|
13
|
-
### README
|
14
|
-
|
15
|
-
* [squared-express](https://github.com/anpham6/squared-express#readme)
|
16
|
-
* [E-mc](https://github.com/anpham6/e-mc#readme)
|
17
|
-
* [Pi-r](https://github.com/anpham6/pi-r#readme)
|
15
|
+
The range chart indicates the latest Ruby tested against at the time of release.
|
18
16
|
|
19
17
|
## Installation
|
20
18
|
|
21
|
-
* NodeJS 16 LTS
|
22
|
-
|
23
|
-
### NPX
|
24
|
-
|
25
19
|
```sh
|
26
|
-
|
27
|
-
> npm i sqd-cli sqd-serve
|
28
|
-
|
29
|
-
> npx sqd init
|
30
|
-
# OR
|
31
|
-
> npx sqd init --public --local-serve # Same as squared-express
|
32
|
-
|
33
|
-
> npx sqd serve --access-all
|
34
|
-
# OR
|
35
|
-
> node serve.cjs --access-all
|
36
|
-
```
|
37
|
-
|
38
|
-
```sh
|
39
|
-
> npm init
|
40
|
-
> npm i squared sqd-serve
|
41
|
-
|
42
|
-
> mkdir dist html
|
43
|
-
> cp -r ./node_modules/squared/dist/* ./dist
|
44
|
-
> cp ./node_modules/squared/html/* ./html # optional
|
45
|
-
> cp ./node_modules/sqd-serve/config/json/* . # yaml
|
46
|
-
|
47
|
-
> npx serve
|
20
|
+
gem install squared
|
48
21
|
```
|
49
22
|
|
50
|
-
###
|
51
|
-
|
52
|
-
```sh
|
53
|
-
> git clone https://github.com/anpham6/squared
|
54
|
-
> cd squared
|
55
|
-
|
56
|
-
> npm i
|
57
|
-
> npm run prod
|
58
|
-
|
59
|
-
> cd ..
|
60
|
-
|
61
|
-
> git clone https://github.com/anpham6/squared-express
|
62
|
-
> cd squared-express
|
63
|
-
|
64
|
-
> npm i
|
65
|
-
> npm run prod
|
66
|
-
> npm run deploy # deploy:yaml
|
67
|
-
|
68
|
-
> cd ../squared
|
69
|
-
|
70
|
-
> node serve.cjs --access-all # squared.{json,yml}
|
71
|
-
```
|
72
|
-
|
73
|
-
### Repo
|
74
|
-
|
75
|
-
* Python 3.6+
|
76
|
-
* [Commands](https://source.android.com/docs/setup/reference/repo)
|
23
|
+
### Optional
|
77
24
|
|
78
|
-
|
25
|
+
* [Repo](https://source.android.com/docs/setup/reference/repo)
|
26
|
+
* Python 3.6
|
27
|
+
* Not compatible with Windows
|
79
28
|
|
80
29
|
```sh
|
81
|
-
mkdir -p
|
82
|
-
PATH="${HOME}
|
83
|
-
|
84
|
-
|
85
|
-
chmod a+rx ~/bin/repo
|
86
|
-
# OR
|
87
|
-
scripts/repo-install.sh ~/bin
|
30
|
+
mkdir -p ~/.bin
|
31
|
+
PATH="${HOME}/.bin:${PATH}"
|
32
|
+
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
|
33
|
+
chmod a+rx ~/.bin/repo
|
88
34
|
```
|
89
35
|
|
90
|
-
|
91
|
-
|
92
|
-
```sh
|
93
|
-
mkdir workspaces
|
94
|
-
cd workspaces
|
95
|
-
|
96
|
-
repo init -u https://github.com/anpham6/squared-repo -m latest.xml
|
97
|
-
repo sync -j4
|
98
|
-
|
99
|
-
cd squared
|
100
|
-
npm i
|
101
|
-
```
|
36
|
+
## Example - Rakefile
|
102
37
|
|
103
|
-
|
38
|
+
Projects from any accessible folder can be added relative to the parent directory (e.g. *REPO_ROOT*) or absolutely. The same Rakefile can also manage other similarly cloned `Repo` repositories remotely by setting the `REPO_ROOT` environment variable to the location. Missing projects will simply be excluded from the task runner.
|
104
39
|
|
105
|
-
|
40
|
+
```ruby
|
41
|
+
require "squared"
|
106
42
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
rake -T # List tasks
|
114
|
-
|
115
|
-
# REPO_BUILD={dev,prod}
|
116
|
-
# PIPE_FAIL=1
|
117
|
-
rake repo:init # nightly
|
118
|
-
rake repo:init[latest] # squared
|
119
|
-
rake repo:init[0.11.x] # e-mc
|
43
|
+
require "squared/workspace"
|
44
|
+
require "squared/workspace/repo" # Optional
|
45
|
+
require "squared/workspace/project/node" #
|
46
|
+
require "squared/workspace/project/python" #
|
47
|
+
require "squared/workspace/project/ruby" #
|
120
48
|
# OR
|
121
|
-
|
122
|
-
# OR - without Repo
|
123
|
-
rake clone:node # master
|
124
|
-
rake clone # node + docs
|
125
|
-
```
|
126
|
-
|
127
|
-
> [!TIP]
|
128
|
-
> Use the supplied Rakefile inside the **squared** project folder once the source has been downloaded.
|
49
|
+
require "squared/app" # All workspace related modules
|
129
50
|
|
130
|
-
|
51
|
+
# NODE_ENV = production
|
131
52
|
|
132
|
-
|
133
|
-
#
|
134
|
-
#
|
135
|
-
# MANIFEST=nightly,staging,prod,android
|
136
|
-
# BUILD={dev,prod}
|
137
|
-
# DEV={0,1,local}
|
138
|
-
# DOCS=any
|
139
|
-
# PIPE_FAIL={0,1}
|
140
|
-
docker build -t squared --build-arg MANIFEST=prod --build-arg SQUARED=prod .
|
141
|
-
docker build -t node --build-arg NODE_TAG=20 --build-arg NODE_INSTALL=pnpm -f Dockerfile.slim . # no docs
|
53
|
+
# REPO_ROOT = /workspaces #
|
54
|
+
# REPO_HOME = /workspaces/squared # Dir.pwd
|
55
|
+
# rake = /workspaces/squared/Rakefile # main?
|
142
56
|
# OR
|
143
|
-
#
|
144
|
-
#
|
145
|
-
|
146
|
-
|
147
|
-
#
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
#
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
projectId: "project-1", // Default is "_"
|
215
|
-
resourceQualifier: "land", // "res/*" folder suffix
|
216
|
-
/* OR */
|
217
|
-
resourceQualifier: {
|
218
|
-
suffix: "land", // Used for "true" or "undefined" groups (optional)
|
219
|
-
layout: true, // Will copy to "res/layout-land" when "suffix" is defined
|
220
|
-
string: undefined, // Will copy to default location "res/values" when "suffix" is undefined
|
221
|
-
font: false, // Will not copy anything to "res/font" or "res/font-land"
|
222
|
-
image: "hdpi", // Will copy to "res/drawable-hdpi"
|
223
|
-
video: "w720dp", // Will copy to "res/raw-w720dp"
|
224
|
-
audio: "w720dp", // Same as "video" and treated separately
|
225
|
-
animation: "v34", // Will copy to "res/anim-v34"
|
226
|
-
menu: "" // Will copy to default location "res/menu"
|
227
|
-
/* integer + fraction + array + color + dimension + style + theme = Same as "string" */
|
228
|
-
},
|
229
|
-
enabledMultiline: false,
|
230
|
-
enabledSubstitute: true,
|
231
|
-
include: ["android.substitute"], // Automatically removed after finalize
|
232
|
-
exclude: ["squared.list", "squared.grid"], // Disabled only during parseDocument
|
233
|
-
excludeQuery: [{
|
234
|
-
selector: "main > article", // Hide elements
|
235
|
-
/* OR */
|
236
|
-
resource: squared.base.lib.constant.NODE_RESOURCE.BOX_STYLE, // Exclusions during processing
|
237
|
-
procedure: squared.base.lib.constant.NODE_PROCEDURE.OPTIMIZATION,
|
238
|
-
section: squared.base.lib.constant.APP_SECTION.DOM_TRAVERSE
|
239
|
-
}],
|
240
|
-
customizationsBaseAPI: -1,
|
241
|
-
observe(mutations, observer, settings) { // Uses MutationObserver
|
242
|
-
squared.reset(); // Required when calling "parseDocument" after a File action
|
243
|
-
squared.parseDocument(settings).then(() => {
|
244
|
-
squared.copyTo("/path/project", { modified: true }).then(response => console.log(response));
|
245
|
-
});
|
246
|
-
},
|
247
|
-
afterCascade(sessionId, node) {/* Restore previous state */},
|
248
|
-
beforeRender(layout: LayoutUI) {/* Edit initial values */},
|
249
|
-
afterFinalize(node: NodeUI) {/* Edit controller values */}
|
250
|
-
},
|
251
|
-
{ // Only "element" is required
|
252
|
-
element: "fragment-1",
|
253
|
-
projectId: "project-1", // Implicit once projectId is not "_"
|
254
|
-
resourceQualifier: "land",
|
255
|
-
pathname: "app/src/main/res/layout-hdpi", // Will not be overridden by resourceQualifier "land"
|
256
|
-
filename: "fragment.xml",
|
257
|
-
baseLayoutAsFragment: {
|
258
|
-
name: "androidx.navigation.fragment.NavHostFragment",
|
259
|
-
documentId: "main_content",
|
260
|
-
app: {
|
261
|
-
navGraph: "@navigation/product_list_graph",
|
262
|
-
defaultNavHost: "true"
|
263
|
-
}
|
264
|
-
},
|
265
|
-
beforeCascade(sessionId) {
|
266
|
-
document.getElementById("fragment-id").style.display = "block"; // Use inline styles
|
267
|
-
}
|
268
|
-
}
|
269
|
-
);
|
270
|
-
await squared.parseDocument({
|
271
|
-
element: "fragment-2",
|
272
|
-
projectId: "sqd2", // Explicit
|
273
|
-
resourceQualifier: "port", // Will not conflict with projectId "project-1"
|
274
|
-
enabledFragment: true,
|
275
|
-
fragmentableElements: [
|
276
|
-
{
|
277
|
-
selector: "main", // querySelector
|
278
|
-
name: "androidx.navigation.fragment.NavHostFragment",
|
279
|
-
filename: "navigation.xml",
|
280
|
-
documentId: "main_content"
|
281
|
-
},
|
282
|
-
"main > article" // Declarative double nested fragments are invalid (querySelectorAll)
|
283
|
-
],
|
284
|
-
options: {
|
285
|
-
"android.resource.fragment": {
|
286
|
-
dynamicNestedFragments: true // FragmentContainerView or FrameLayout as the container (name and tag are ignored)
|
287
|
-
}
|
288
|
-
}
|
289
|
-
});
|
290
|
-
// OR - Chromium
|
291
|
-
squared.prefetch("css").then(() => squared.parseDocument()); // Cross-origin support
|
292
|
-
Promise.all(
|
293
|
-
squared.prefetch("css", true), // All stylesheets
|
294
|
-
squared.prefetch("css", "./undetected.css", element.shadowRoot),
|
295
|
-
squared.prefetch("svg", "http://embedded.example.com/icon.svg", "../images/android.svg")
|
296
|
-
)
|
297
|
-
.then(() => squared.parseDocument());
|
298
|
-
|
299
|
-
// Modify attributes
|
300
|
-
|
301
|
-
const body = squared.findDocumentNode(document.body);
|
302
|
-
body.android("layout_width", "match_parent");
|
303
|
-
body.lockAttr("android", "layout_width");
|
304
|
-
|
305
|
-
await squared.close(/* projectId */); // Next call to parseDocument will reset project (optional)
|
306
|
-
|
307
|
-
squared.kill("30s").then(result => {/* killed when result > 0 */}); // Abort next request in 30 seconds
|
308
|
-
|
309
|
-
// File actions - implicitly calls "close"
|
310
|
-
|
311
|
-
await squared.save(/* "project-1" */, /* broadcastId | timeout */); // Uses defaults from settings
|
312
|
-
// OR
|
313
|
-
await squared.saveAs(/* archive filename */, { projectId: "project-1" });
|
314
|
-
await squared.saveAs(/* archive filename */, { timeout: 10 }); // Kills request if not complete in 10 seconds
|
315
|
-
await squared.saveAs(/* archive filename */, { throwErrors: true }).catch(err => console.log(err)); // Will cancel partial archive download
|
316
|
-
// OR
|
317
|
-
await squared.copyTo(/* directory */, {/* options */});
|
318
|
-
await squared.copyTo(/* directory */, { modified: true }); // Can be used with observe
|
319
|
-
// OR
|
320
|
-
await squared.appendTo(/* archive location */, {/* options */});
|
321
|
-
|
322
|
-
// Other features
|
323
|
-
|
324
|
-
squared.observe();
|
325
|
-
// OR
|
326
|
-
await squared.observeSrc(
|
327
|
-
"link[rel=stylesheet]", // HTMLElement
|
328
|
-
(ev, element) => {
|
329
|
-
squared.reset();
|
330
|
-
squared.parseDocument().then(() => squared.copyTo("/path/project"));
|
331
|
-
},
|
332
|
-
{ port: 8080, secure: false, action: "reload" /* "hot" */, expires: "1h" } // squared.json: "observe"
|
333
|
-
);
|
334
|
-
|
335
|
-
squared.reset(/* projectId */); // Start new "parseDocument" session (optional)
|
336
|
-
});
|
337
|
-
</script>
|
338
|
-
```
|
339
|
-
|
340
|
-
> [!CAUTION]
|
341
|
-
> Calling `saveAs` or `copyTo` methods before the images have completely loaded can cause them to be excluded from the generated layout. In these cases you should use the asynchronous `parseDocument` method to set a callback for your commands.
|
342
|
-
|
343
|
-
### Example: chrome
|
344
|
-
|
345
|
-
Used primarly for developing single page layouts but can also bundle assets using query selector syntax. It is adequate for most projects and gives you the ability to develop your application as a module in place.
|
346
|
-
|
347
|
-
* ES2020
|
348
|
-
|
349
|
-
```html
|
350
|
-
<script src="/dist/squared.min.js"></script>
|
351
|
-
<script src="/dist/squared.base.min.js"></script>
|
352
|
-
<script src="/dist/chrome.framework.min.js"></script>
|
353
|
-
<script>
|
354
|
-
document.addEventListener("DOMContentLoaded", async () => {
|
355
|
-
squared.setFramework(chrome, {/* settings */});
|
356
|
-
|
357
|
-
await squared.save(); // Uses defaults from settings
|
358
|
-
// OR
|
359
|
-
await squared.saveAs(/* archive filename */, {/* options */});
|
360
|
-
// OR
|
361
|
-
await squared.copyTo(/* directory */, {/* options */});
|
362
|
-
// OR
|
363
|
-
await squared.appendTo(/* archive location */, {/* options */});
|
364
|
-
|
365
|
-
// Observe
|
366
|
-
await squared.copyTo(/* directory */, { useOriginalHtmlPage: false, observe: /* Same as Android */ | true /* Auto-reload */}).then(() => squared.observe());
|
367
|
-
});
|
368
|
-
</script>
|
369
|
-
```
|
370
|
-
|
371
|
-
### Example: vdom
|
372
|
-
|
373
|
-
The most minimal framework possible (*55kb gzipped*) and can be useful when debugging through DevTools. The `lite` version is about half the bundle size and is recommended for most browser applications.
|
374
|
-
|
375
|
-
* ES2018
|
376
|
-
|
377
|
-
```html
|
378
|
-
<script src="/dist/squared.min.js"></script>
|
379
|
-
<script src="/dist/squared.base-dom.min.js"></script>
|
380
|
-
<script src="/dist/vdom.framework.min.js"></script>
|
381
|
-
<script>
|
382
|
-
document.addEventListener("DOMContentLoaded", async () => {
|
383
|
-
squared.setFramework(vdom, {/* settings */});
|
384
|
-
|
385
|
-
const element = squared.querySelector("body", true /* synchronous */);
|
386
|
-
// OR
|
387
|
-
const elements = await squared.querySelectorAll("*");
|
388
|
-
// OR
|
389
|
-
const element = squared.fromElement(document.body, true /* synchronous */);
|
390
|
-
// OR
|
391
|
-
const elements = await squared.getElementById("content-id").querySelectorAll("*");
|
392
|
-
});
|
393
|
-
</script>
|
394
|
-
```
|
395
|
-
|
396
|
-
There are **ES2018** minified versions (\*.min.js) and also **ES2018** non-minified versions.
|
397
|
-
|
398
|
-
## User Settings
|
399
|
-
|
400
|
-
These settings are available in the global variable `squared` to customize your desired output structure. Each framework shares a common set of settings and also a subset of their own settings.
|
401
|
-
|
402
|
-
### Example: android
|
403
|
-
|
404
|
-
- [Read the Docs](https://squared.readthedocs.io/en/latest/settings/android.html)
|
405
|
-
|
406
|
-
```javascript
|
407
|
-
squared.settings = {
|
408
|
-
targetAPI: 35,
|
409
|
-
supportRTL: true,
|
410
|
-
supportNegativeLeftTop: true,
|
411
|
-
preloadImages: true,
|
412
|
-
preloadFonts: true,
|
413
|
-
preloadLocalFonts: true, // Chromium
|
414
|
-
preloadCustomElements: true,
|
415
|
-
enabledSVG: true,
|
416
|
-
enabledMultiline: true,
|
417
|
-
enabledViewModel: true,
|
418
|
-
enabledIncludes: false,
|
419
|
-
enabledFragment: false,
|
420
|
-
enabledSubstitute: false,
|
421
|
-
enabledCompose: false,
|
422
|
-
dataBindableElements: [], // { selector, attr, expression, namespace?, twoWay? } (see Data Binding section)
|
423
|
-
includableElements: [], // { selectorStart, selectorEnd, pathname?, filename?, merge?, viewModel? }
|
424
|
-
substitutableElements: [], // { selector, tag, tagChild?, renderChildren?, autoLayout? }
|
425
|
-
fragmentableElements: [], // selector | ExtensionFragmentElement
|
426
|
-
composableElements: [], // selector or property (see Jetpack Compose section)
|
427
|
-
baseLayoutAsFragment: false | "fragment-name" | ["fragment-name", "fragment-tag"] | { selector, pathname?, filename?, name?, tag? }, // ExtensionFragmentElement
|
428
|
-
baseLayoutToolsIgnore: "", // Android Studio (e.g. "TooManyViews, HardcodedText")
|
429
|
-
fontMeasureAdjust: 0.75, // thicker < 0 | thinner > 0 (data-android-font-measure-adjust)
|
430
|
-
lineHeightAdjust: 1.1, // shorter < 1 | taller > 1 (data-android-line-height-adjust)
|
431
|
-
preferMaterialDesign: false | "MaterialComponents" | "Material3", // Default is "Material3"
|
432
|
-
createDownloadableFonts: true,
|
433
|
-
createElementMap: false,
|
434
|
-
pierceShadowRoot: true,
|
435
|
-
adaptStyleMap: true, // Use rendered values for output
|
436
|
-
lockElementSettings: true,
|
437
|
-
customizationsBaseAPI: 0, // 0 - All | -1 - None
|
438
|
-
customizationsBaseAPI: [0, 33, 34], // Multiple
|
439
|
-
removeDeprecatedAttributes: true, // Remove all
|
440
|
-
removeDeprecatedAttributes: ["enabled", "singleLine"], // Remove all except "enabled" + "singleLine"
|
441
|
-
removeUnusedResourceViewId: false,
|
442
|
-
idNamingStyle: "android",
|
443
|
-
idNamingStyle: "html", // Use element tagName
|
444
|
-
idNamingStyle: {
|
445
|
-
"__default__": "html", // Optional
|
446
|
-
"DIV": "comments", // HTML is uppercase (comments_1 then comments_2)
|
447
|
-
"svg": ["vector", 0], // SVG elements areis lowercase (vector_0 then vector_1)
|
448
|
-
"#text": "text", // Plain text
|
449
|
-
"::first-letter": "dropcap", // Pseudo element
|
450
|
-
"main > section": ["content", 1, 2], // content_1 then content_3
|
451
|
-
"form input[type=submit]": function(node) {
|
452
|
-
return "submit_" + node.id;
|
453
|
-
}
|
454
|
-
},
|
455
|
-
customizationsOverwritePrivilege: true,
|
456
|
-
outputMainFileName: "activity_main.xml",
|
457
|
-
outputFragmentFileName: "fragment_main.xml",
|
458
|
-
/* Project - parseDocument (first only) */
|
459
|
-
resourceQualifier: "", // "land" -> "res/layout-land" | "port" -> "res/layout-port" (appended to every "res" folder)
|
460
|
-
resourceSystemColors: {
|
461
|
-
"system_accent1_100": "white", // Will be converted to ARGB
|
462
|
-
"system_accent1_200": ['#ff0000', 0.75], // opacity
|
463
|
-
"system_accent1_300": squared.lib.color.parseColor("#000", 1)
|
464
|
-
},
|
465
|
-
manifestPackage: "", // OR: RequestData<{ namespace: "android.application.id" }>
|
466
|
-
manifestLabelAppName: "android",
|
467
|
-
manifestThemeName: "AppTheme",
|
468
|
-
manifestParentThemeName: "Theme.AppCompat.Light.NoActionBar",
|
469
|
-
manifestActivityName: ".MainActivity",
|
470
|
-
outputDocumentEditing: true,
|
471
|
-
outputDocumentCSS: [], // CSS properties to be processed at server (e.g. "boxShadow")
|
472
|
-
outputDirectory: "app/src/main",
|
473
|
-
createManifest: false, // Update AndroidManifest.xml
|
474
|
-
createBuildDependencies: false | "ktx" | "baseline-profile" | ["ktx", "baseline-profile"], // Update build.gradle
|
475
|
-
|
476
|
-
// Not customizable with parseDocument
|
477
|
-
builtInExtensions: [
|
478
|
-
"squared.accessibility",
|
479
|
-
"android.delegate.background",
|
480
|
-
"android.delegate.negative-x",
|
481
|
-
"android.delegate.positive-x",
|
482
|
-
"android.delegate.max-width-height",
|
483
|
-
"android.delegate.percent",
|
484
|
-
"android.delegate.content",
|
485
|
-
"android.delegate.scrollbar",
|
486
|
-
"android.delegate.radiogroup",
|
487
|
-
"android.delegate.multiline",
|
488
|
-
"squared.relative",
|
489
|
-
"squared.css-grid",
|
490
|
-
"squared.flexbox",
|
491
|
-
"squared.table",
|
492
|
-
"squared.column",
|
493
|
-
"squared.list",
|
494
|
-
"squared.grid",
|
495
|
-
"squared.sprite",
|
496
|
-
"squared.whitespace",
|
497
|
-
"android.resource.background",
|
498
|
-
"android.resource.svg",
|
499
|
-
"android.resource.strings",
|
500
|
-
"android.resource.fonts",
|
501
|
-
"android.resource.dimens",
|
502
|
-
"android.resource.styles",
|
503
|
-
"android.resource.data",
|
504
|
-
|
505
|
-
/* EXCLUDED (breaks layout) */
|
506
|
-
"android.resource.includes", // enabledIncludes
|
507
|
-
"android.substitute", // enabledSubstitute
|
508
|
-
"android.resource.fragment", // enabledFragment
|
509
|
-
"jetpack.compose.view" // enabledCompose
|
510
|
-
],
|
511
|
-
compressImages: false, // TinyPNG API Key <https://tinypng.com/developers>
|
512
|
-
compressImages: "****************", // API key
|
513
|
-
convertImages: "", // png | jpeg | webp | gif | bmp
|
514
|
-
showAttributes: true,
|
515
|
-
showAttributes: {
|
516
|
-
"hyphenationFrequency": "full", // Replace all ("android" is the default namespace)
|
517
|
-
"android:fontFeatureSettings": null, // Delete all
|
518
|
-
"app:menu": [
|
519
|
-
"@menu/menu_1", "@menu/menu_2", // Replace with "@menu/menu_2" when value is "@menu/menu_1"
|
520
|
-
"@menu/menu_3", null // Delete attribute when value is "@menu/menu_3"
|
521
|
-
],
|
522
|
-
/* OR */
|
523
|
-
"app:menu": {
|
524
|
-
"@menu/menu_1": "@menu/menu_2",
|
525
|
-
"@menu/menu_3": null
|
526
|
-
}
|
527
|
-
},
|
528
|
-
showComments: false | ["boxShadow"] | { self: ["boxShadow"], nextSibling: ["marginBottom"], previousSibling: ["marginTop"], parent: ["position", "top", "left"] }, // TODO in layout.xml
|
529
|
-
showComments: { include: { tagName: true | ["button"], attributes: true | ["style"], dataset: false, bounds: true }, self: ["boxShadow", ".className"] },
|
530
|
-
showErrorMessages: false,
|
531
|
-
convertPixels: "dp", // "sp" | "pt" | "in" | "mm"
|
532
|
-
convertLineHeight: "sp", // "dp" | "pt" | "in" | "mm"
|
533
|
-
convertEntities: ["numeric"], // v5.4
|
534
|
-
convertEntities: ["codepoints", {/* JSON (last) */}], // https://html.spec.whatwg.org/entities.json
|
535
|
-
insertSpaces: 4,
|
536
|
-
outputDocumentHandler: "android",
|
537
|
-
outputEmptyCopyDirectory: false, // Sub directories within target directory (OR: RequestData<{ emptyDir: false }>)
|
538
|
-
outputSummaryModal: false | "path/summary.css" | ".status-4 { color: purple; }",
|
539
|
-
outputTasks: {
|
540
|
-
"**/drawable/*.xml": { handler: "gulp", task: "minify" }
|
541
|
-
},
|
542
|
-
outputWatch: {
|
543
|
-
"**/drawable/*.png": true,
|
544
|
-
"**/drawable/*.jpg": { interval: 1000, expires: "2h" }
|
545
|
-
},
|
546
|
-
outputArchiveName: "android-xml",
|
547
|
-
outputArchiveFormat: "zip", // tar | 7z | gz
|
548
|
-
outputArchiveCache: false // Downloadable URL in ResponseData<downloadUrl>
|
549
|
-
};
|
550
|
-
|
551
|
-
// Optional
|
552
|
-
squared.settings = {
|
553
|
-
resolutionDPI: 160, // 320dpi = 2560x1600
|
554
|
-
resolutionScreenWidth: 1280,
|
555
|
-
resolutionScreenHeight: 800,
|
556
|
-
framesPerSecond: 60,
|
557
|
-
useShapeGeometryBox: true, // Bounding box uses native SVG method getBbox
|
558
|
-
formatUUID: "8-4-4-4-12", // UUID: 8-4-[12345]3-[89ab]3-12
|
559
|
-
formatDictionary: "0123456789abcdef",
|
560
|
-
outputConfigName: "sqd.config",
|
561
|
-
observePort: 8080,
|
562
|
-
observeSecurePort: 8443,
|
563
|
-
observeExpires: "1h", // Server defaults will be used
|
564
|
-
broadcastPort: 3080,
|
565
|
-
broadcastSecurePort: 3443
|
566
|
-
};
|
567
|
-
```
|
568
|
-
|
569
|
-
### Example: chrome
|
570
|
-
|
571
|
-
- [Read the Docs](https://squared.readthedocs.io/en/latest/settings/chrome.html)
|
572
|
-
|
573
|
-
```javascript
|
574
|
-
squared.settings = {
|
575
|
-
preloadImages: false,
|
576
|
-
preloadFonts: false,
|
577
|
-
preloadLocalFonts: false,
|
578
|
-
preloadCustomElements: false,
|
579
|
-
excludePlainText: true,
|
580
|
-
createElementMap: true,
|
581
|
-
pierceShadowRoot: true,
|
582
|
-
adaptStyleMap: false,
|
583
|
-
builtInExtensions: [],
|
584
|
-
showErrorMessages: false,
|
585
|
-
webSocketPort: 80,
|
586
|
-
webSocketSecurePort: 443,
|
587
|
-
outputDocumentHandler: "chrome",
|
588
|
-
outputEmptyCopyDirectory: false,
|
589
|
-
outputSummaryModal: false,
|
590
|
-
outputTasks: {
|
591
|
-
"*.js": [{ handler: "gulp", task: "minify" }, { handler: "gulp", task: "beautify" }]
|
592
|
-
},
|
593
|
-
outputWatch: { "*": true },
|
594
|
-
outputArchiveName: "chrome-data",
|
595
|
-
outputArchiveFormat: "zip",
|
596
|
-
outputArchiveCache: false
|
597
|
-
};
|
598
|
-
|
599
|
-
// Optional (Same as Android)
|
600
|
-
|
601
|
-
```
|
602
|
-
|
603
|
-
### Example: vdom
|
604
|
-
|
605
|
-
- [Read the Docs](https://squared.readthedocs.io/en/latest/settings/vdom.html)
|
606
|
-
|
607
|
-
```javascript
|
608
|
-
squared.settings = {
|
609
|
-
createElementMap: true,
|
610
|
-
pierceShadowRoot: false,
|
611
|
-
adaptStyleMap: false,
|
612
|
-
builtInExtensions: [],
|
613
|
-
showErrorMessages: false
|
614
|
-
};
|
615
|
-
```
|
616
|
-
|
617
|
-
## Local Storage
|
618
|
-
|
619
|
-
Custom named user settings per framework can be saved to local storage as JSON and reused across all pages in the same domain. Extensions are configured using the same procedure.
|
620
|
-
|
621
|
-
```javascript
|
622
|
-
// Save
|
623
|
-
squared.setFramework(android, { compressImages: true }, "android-example");
|
624
|
-
|
625
|
-
// Load
|
626
|
-
squared.setFramework(android, "android-example");
|
627
|
-
```
|
628
|
-
|
629
|
-
```javascript
|
630
|
-
// Save
|
631
|
-
await squared.copyTo("/path/project", {/* options will be saved */}, "copy-example", true); // Will overwrite and not merge with previously saved settings
|
632
|
-
|
633
|
-
// Load
|
634
|
-
await squared.copyTo("/path/project", {/* takes precedence */}, "http://localhost:3000/copy-to/base-config.json"); // Object.assign({ base-config.json }, options)
|
635
|
-
await squared.copyTo("/path/project", {/* takes precedence */}, "copy-example"); // Object.assign({ copy-example }, options)
|
636
|
-
|
637
|
-
await squared.copyTo("/path/project", "http://localhost:3000/copy-to/base-config.json"); // options = { base-config.json }
|
638
|
-
await squared.copyTo("/path/project", "copy-example"); // options = { copy_example }
|
639
|
-
```
|
640
|
-
|
641
|
-
## Public Properties and Methods
|
642
|
-
|
643
|
-
- [Read the Docs](https://squared.readthedocs.io/en/latest/methods/squared.html)
|
644
|
-
|
645
|
-
```javascript
|
646
|
-
.settings // See user preferences section
|
647
|
-
|
648
|
-
setFramework(app: {}, options?: PlainObject, setting?: string, cache?: boolean) // Install application interpreter
|
649
|
-
setFramework(app: {}, loadName: string, cache?: boolean) // Load settings from local storage
|
650
|
-
|
651
|
-
// http - hostname(:port)? | https - hostname:443
|
652
|
-
setHostname(value: string /* http(s)://hostname(:port) */) // Use another cors-enabled server for processing files (--cors <origin>)
|
653
|
-
|
654
|
-
setEndpoint(name: string, value: string) // Set alternate pathname for API v1 functions (ASSETS_COPY | ASSETS_ARCHIVE | LOADER_DATA | THREADS_KILL | WEBSOCKET_OBSERVE)
|
655
|
-
setLocalAddress(...values: (string | URL | Location)[]) // Additional hostnames which are interpreted as localhost (e.g. http://127.0.0.1)
|
656
|
-
|
657
|
-
prefetch(type: "css" | "javascript" | "image" | "svg", all?: boolean, ...targets: unknown[]) // Cross-origin support for CSS
|
658
|
-
|
659
|
-
parseDocument(...elements: (HTMLElement | string | ElementSettings)[]) // See installation section (Promise)
|
660
|
-
parseDocumentSync(...elements: (HTMLElement | string | ElementSettings)[]) // Skips preloadImages and preloadFonts (synchronous)
|
661
|
-
|
662
|
-
latest(count?: number) // Most recent parseDocument session ids (1 newest / -1 oldest: string, other: string[])
|
663
|
-
|
664
|
-
auth(token: string) // Set JWT authorization token for all requests
|
665
|
-
|
666
|
-
save(projectId?: string) // Save current session to a new archive using default settings
|
667
|
-
save(projectId?: string, broadcastId?: string)
|
668
|
-
save(projectId?: string, timeout?: number)
|
669
|
-
|
670
|
-
close(projectId?: string) // Close current session
|
671
|
-
reset(projectId?: string) // Clear cache and reopen new session
|
672
|
-
clear() // Clear all data stored in memory
|
673
|
-
|
674
|
-
toString() // Current framework loaded
|
675
|
-
toString(projectId: string) // await squared.close(projectId) (required)
|
676
|
-
|
677
|
-
add(...names: (string | Extension | ExtensionRequestObject)[]) // See extension configuration section
|
678
|
-
remove(...names: (string | Extension)[]) // Remove extensions by namespace or control
|
679
|
-
get(...names: string[]) // Retrieve extensions by namespace
|
680
|
-
attr(name: string | Extension, attrName: string, value?: unknown) // Set or get extension options attribute value
|
681
|
-
apply(name: string | Extension, options: PlainObject, setting?: string) // See extension configuration section
|
682
|
-
|
683
|
-
extend(functionMap: {}, framework?: /* 0 - ALL | 1 - vdom | 2 - android | 4 - chrome */) // Add extension functions and properties to Node prototype
|
684
|
-
|
685
|
-
observe(value?: boolean | MutationObserverInit) // Start after DOM and third-party libraries initialization
|
686
|
-
broadcast(callback: BroadcastMessageCallback, options: FileBroadcastOptions | string) // Redirect stdout messages to DevTools console
|
687
|
-
|
688
|
-
// Promise (Recommended "cache": createElementMap - true)
|
689
|
-
|
690
|
-
getElementById(value: string, sync?: boolean, cache?: boolean) // sync - false | cache - true (default)
|
691
|
-
querySelector(value: string, sync?: boolean, cache?: boolean)
|
692
|
-
querySelectorAll(value: string, sync?: boolean, cache?: boolean)
|
693
|
-
|
694
|
-
fromElement(element: HTMLElement | string, sync?: boolean, cache?: boolean) // sync - false | cache - false (default)
|
695
|
-
fromNode(node: Node, sync?: boolean, cache?: boolean)
|
696
|
-
findDocumentNode(element: HTMLElement | string /* querySelector | elementId | controlId */, all?: boolean) // Use before saving to modify internal Node attributes
|
697
|
-
|
698
|
-
observeSrc(element: HTMLElement | string /* querySelector */, callback: WebSocketMessageChange, options?: FileObserveOptions) // Can be used to watch any element with externally hosted files (src/href)
|
699
|
-
observeSrc(element: HTMLElement | string, options: FileObserveOptions) // Uses location.reload (reload - true)
|
700
|
-
```
|
701
|
-
|
702
|
-
Packaging methods will return a Promise and requires a squared-express installation. These features are not supported when the framework is VDOM.
|
703
|
-
|
704
|
-
```javascript
|
705
|
-
saveAs(filename: string, options?: {}, setting?: string, overwrite?: boolean) // Save current session as a new archive
|
706
|
-
saveFiles(filename: string, options: {}, setting?: string, overwrite?: boolean) // Create new archive from FileAsset[]
|
707
|
-
|
708
|
-
// Required (local archives): --disk-read | --unc-read | --access-all (command-line)
|
709
|
-
|
710
|
-
appendTo(pathname: string, options?: {}, setting?: string, overwrite?: boolean) // Create new archive from a preexisting archive and current session
|
711
|
-
appendFiles(pathname: string, options: {}, setting?: string, overwrite?: boolean) // Create new archive from a preexisting archive and FileAsset[]
|
712
|
-
|
713
|
-
// Required (all): --disk-write | --unc-write | --access-all (command-line)
|
714
|
-
|
715
|
-
copyTo(pathname: string | string[], options?: {}, setting?: string, overwrite?: boolean) // Copy current session to local
|
716
|
-
copyFiles(pathname: string | string[], options: {}, setting?: string, overwrite?: boolean) // Copy FileAsset[] to local
|
717
|
-
|
718
|
-
kill(pid: number, timeout?: number) // Use -1 or options.pid (set by system) + seconds
|
719
|
-
kill(timeout: string)
|
720
|
-
kill() // Terminate previous request
|
721
|
-
kill(0) // By username (auth required)
|
722
|
-
kill(-1, 10) // Terminate previous request in 10 seconds
|
723
|
-
kill(NaN, 10) // Terminate in 10 seconds (next request) ("timeout" is required)
|
724
|
-
kill("10s") // Only "s" + "ms" (next request)
|
725
|
-
```
|
726
|
-
|
727
|
-
## Extending Node object
|
728
|
-
|
729
|
-
You can add functions and initial variables to the Node object including overwriting preexisting class definitions per framework. Accessor properties are also supported using the *get/set* object syntax.
|
730
|
-
|
731
|
-
```javascript
|
732
|
-
squared.extend({
|
733
|
-
_id: 1,
|
734
|
-
altId: {
|
735
|
-
get() {
|
736
|
-
return this._id;
|
737
|
-
},
|
738
|
-
set(value) {
|
739
|
-
this._id += value;
|
740
|
-
}
|
741
|
-
},
|
742
|
-
customId: {
|
743
|
-
value: 2,
|
744
|
-
configurable: false,
|
745
|
-
enumerable: false
|
746
|
-
},
|
747
|
-
addEvent(eventName, callback) {
|
748
|
-
this.element.addEventListener(eventName, callback);
|
749
|
-
}
|
750
|
-
});
|
751
|
-
squared.setFramework(vdom);
|
752
|
-
|
753
|
-
const body = await squared.fromElement(document.body);
|
754
|
-
body.altId = 2; // body.altId: 3
|
755
|
-
body.addEvent("click", function (ev) {
|
756
|
-
this.classList.toggle("example");
|
757
|
-
});
|
758
|
-
```
|
759
|
-
|
760
|
-
## Forwarding Request
|
761
|
-
|
762
|
-
Using another identical remote server to build the project when performing a `saveAs` or `copyTo` request can be achieved by changing only the origin address.
|
763
|
-
|
764
|
-
```javascript
|
765
|
-
squared.setHostname("http://hostname:8000");
|
766
|
-
// OR
|
767
|
-
squared.setHostname(); // Reset to window.location (e.g. localhost:3000)
|
768
|
-
|
769
|
-
await squared.saveAs("chrome.zip"); // Current browser
|
770
|
-
// OR
|
771
|
-
await squared.copyTo("/path/project"); // Remote server
|
772
|
-
```
|
773
|
-
|
774
|
-
## Broadcasting
|
775
|
-
|
776
|
-
Console messages (stdout) can be sent to the browser console instead through DevTools.
|
777
|
-
|
778
|
-
```javascript
|
779
|
-
squared.broadcast(result => { console.log(result.value); }, "111-111-111"); // System messages from squared-express
|
780
|
-
squared.broadcast(result => { console.log(result.value); }, "222-222-222"); // Messages from "project-1" project
|
781
|
-
squared.broadcast(result => { console.log(result.value); }, { socketId: "333-333-333", socketKey: "socket_id" }); // Messages sent from another channel (default is "socketId")
|
782
|
-
|
783
|
-
await squared.copyTo("/path/project/project-1", {
|
784
|
-
projectId: "project-1",
|
785
|
-
log: { useColor: true }, // Chromium
|
786
|
-
broadcastId: "222-222-222" // Specific use alias for "socketId"
|
787
|
-
});
|
788
|
-
```
|
789
|
-
|
790
|
-
## Extension Configuration
|
791
|
-
|
792
|
-
Layout rendering can be customized using extensions as the program was built to be nearly completely modular. Some of the common layouts already have built-in extensions which you can load or unload based on your preference.
|
793
|
-
|
794
|
-
```typescript
|
795
|
-
// Create an extension
|
796
|
-
class Sample extends squared.base.Extension {
|
797
|
-
options = {
|
798
|
-
attributeName: [];
|
799
|
-
};
|
800
|
-
|
801
|
-
constructor(name, framework = 0, options = {}) { // 0 - ALL | 1 - vdom | 2 - android | 4 - chrome (framework)
|
802
|
-
super(name, framework, options);
|
57
|
+
# REPO_ROOT = /workspaces # Dir.pwd
|
58
|
+
# rake = /workspaces/Rakefile #
|
59
|
+
# REPO_HOME = /workspaces/squared # main: "squared"
|
60
|
+
|
61
|
+
# pathname = /workspaces/pathname
|
62
|
+
# optparse = /workspaces/optparse
|
63
|
+
# log = /workspaces/logger
|
64
|
+
# emc = /workspaces/e-mc
|
65
|
+
# pir = /workspaces/pi-r
|
66
|
+
# squared = /workspaces/squared
|
67
|
+
# cli = /workspaces/squared/publish/sqd-cli
|
68
|
+
# sqd-serve = /workspaces/squared/publish/sqd-serve
|
69
|
+
# sqd = /workspaces/squared/sqd
|
70
|
+
|
71
|
+
Workspace::Application
|
72
|
+
.new(Dir.pwd, main: "squared") # Dir.pwd? (main? is implicitly basename)
|
73
|
+
.banner("group", "project", styles: ["yellow", "black"], border: "bold") # name | project | path | ref | group? | parent? | version?
|
74
|
+
.repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "build:prod"], ref: :node) # Repo (optional)
|
75
|
+
.run("rake install", ref: :ruby)
|
76
|
+
.depend(false, group: "default")
|
77
|
+
.clean("rake clean", group: "default")
|
78
|
+
.clean(["build/"], group: "app")
|
79
|
+
.log({ file: "tmp/%Y-%m-%d.log", level: "debug" }, group: "app")
|
80
|
+
.add("pathname", run: "rake compile", copy: "rake install", test: "rake test", group: "default", env: { # Ruby (with C extensions)
|
81
|
+
"CFLAGS" => "-fPIC -O1"
|
82
|
+
})
|
83
|
+
.add("optparse", doc: "rake rdoc", group: "default") # Uses bundler/gem_tasks (without C extensions)
|
84
|
+
.add("logger", copy: { from: "lib", glob: "**/*.rb", into: "~/.rvm/gems/ruby-3.4.0/gems/logger-1.6.1" }, clean: ["tmp/"]) # autodetect: true
|
85
|
+
.add("e-mc", "emc", copy: { from: "publish", scope: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
|
86
|
+
.add("pi-r", "pir", copy: { from: "publish", scope: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
|
87
|
+
.add("squared", script: ["build:stage1", "build:stage2"], group: "app") do # Copy target (main)
|
88
|
+
# Repo (global)
|
89
|
+
as(:run, "build:dev", "dev") # npm run build:dev -> npm run dev
|
90
|
+
as(:run, { "build:dev": "dev", "build:prod": "prod" })
|
91
|
+
|
92
|
+
add("publish/sqd-cli", "cli", exclude: [:git]) # rake cli:build
|
93
|
+
add("publish/sqd-serve") # rake sqd-serve:build
|
94
|
+
add("publish/sqd-admin", group: "sqd", exclude: [:base])
|
95
|
+
# OR
|
96
|
+
with(exclude: [:base]) { add("publish/*", "packages") } # rake packages:sqd-serve:build
|
97
|
+
# OR
|
98
|
+
add(["publish/sqd-cli", "publish/sqd-serve", "publish/sqd-admin"], true, exclude: [:base]) # rake squared:sqd-serve:build
|
99
|
+
end
|
100
|
+
.add("squared/sqd", exclude: :git, pass: [:node, 'checkout', 'bump']) do # Skip initialize(:node) + squared:checkout:* + squared:bump:*
|
101
|
+
variable_set :script, "build:sqd" # Override detection
|
102
|
+
variable_set :depend, false
|
103
|
+
variable_set :clean, ["build/sqd/"]
|
104
|
+
end
|
105
|
+
.pass("pull", group: "default") { test? || doc? } # pathname:pull | optparse:pull
|
106
|
+
.style("banner", 255.255) # 256 colors (fg | fg.bg | -0.bg)
|
107
|
+
.build(default: "build", parallel: ["pull", "fetch", "rebase", "copy", "clean", /^outdated:/], pass: ['publish']) do |workspace|
|
108
|
+
workspace
|
109
|
+
.enable_aixterm
|
110
|
+
.style({
|
111
|
+
banner: ["bright_cyan", "bold", "bright_black!"],
|
112
|
+
border: "bright_white"
|
113
|
+
})
|
114
|
+
end
|
115
|
+
|
116
|
+
# default = /workspaces/ruby/*
|
117
|
+
# pathname = /workspaces/ruby/pathname
|
118
|
+
# optparse = /workspaces/ruby/optparse
|
119
|
+
# logger = /workspaces/ruby/logger
|
120
|
+
# android = /workspaces/android-docs
|
121
|
+
# chrome = /workspaces/chrome-docs
|
122
|
+
|
123
|
+
Workspace::Application
|
124
|
+
.new(ENV["SQUARED_HOME"], prefix: "rb", common: false) # Local styles
|
125
|
+
.group("ruby", "default", run: "rake build", copy: "rake install", clean: "rake clean", ref: :ruby, override: {
|
126
|
+
pathname: {
|
127
|
+
run: "rake compile" # rake rb:pathname:build
|
803
128
|
}
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
129
|
+
})
|
130
|
+
.with(:python) do # ref=Symbol | group=String
|
131
|
+
banner([:name, ": ", :version], "path") # chrome-docs: 0.1.0 | /workspaces/chrome-docs
|
132
|
+
doc("make html") # rake rb:doc:python
|
133
|
+
run(false) # rake rb:build:python (disabled)
|
134
|
+
exclude(%i[base git]) # Project::Git.ref (superclass)
|
135
|
+
add("android-docs", "android") # rake rb:android:doc
|
136
|
+
add("chrome-docs", "chrome") # rake rb:chrome:doc
|
137
|
+
end
|
138
|
+
.style("inline", "bold")
|
139
|
+
.build
|
140
|
+
```
|
141
|
+
|
142
|
+
**NOTE**: The use of "**ref**" (class name) is only necessary when initializing an empty directory (e.g. *rake repo:init*).
|
143
|
+
|
144
|
+
### Clone
|
145
|
+
|
146
|
+
The task is only active when the project directory is empty or does not exist.
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
Workspace::Application
|
150
|
+
.new(main: "squared")
|
151
|
+
.git(
|
152
|
+
"emc": "https://github.com/anpham6/e-mc", # rake emc:clone
|
153
|
+
"pir": { # rake pir:clone
|
154
|
+
uri: "https://github.com/anpham6/pi-r", #
|
155
|
+
options: { #
|
156
|
+
"origin": "github", # --origin='github'
|
157
|
+
"recurse-submodules": false, # --no-recurse-submodules
|
158
|
+
"shallow-exclude": ["v0.0.1", "v0.0.2"] # --shallow-exclude='v0.0.1' --shallow-exclude='v0.0.2'
|
159
|
+
}
|
810
160
|
}
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
squared.add([sample, {/* config */}]);
|
818
|
-
|
819
|
-
// Configure an extension
|
820
|
-
squared.attr("widget.example.com", "attributeName", ["width", "height"]); // typeof is enforced and will only set existing attributes
|
821
|
-
|
822
|
-
// Add project data
|
823
|
-
const ext = squared.get("widget.example.com");
|
824
|
-
|
825
|
-
ext.project.set(element, await fetch(url?id=1)); // Map interface with optional "projectId" argument
|
826
|
-
ext.project.set(element, await fetch(url?id=2), "project-1");
|
827
|
-
|
828
|
-
const data = ext.project.get(element, "project-2"); // Returns data from default project (id=1)
|
829
|
-
```
|
830
|
-
|
831
|
-
Some extensions have a few settings which can be configured. The default settings usually achieve the best overall rendering accuracy without noticeably affecting performance.
|
832
|
-
|
833
|
-
## ANDROID
|
834
|
-
|
835
|
-
### Public Methods
|
836
|
-
|
837
|
-
- [Read the Docs](https://squared.readthedocs.io/en/latest/methods/android.html)
|
838
|
-
|
839
|
-
```javascript
|
840
|
-
android.setViewModel(data: {}, sessionId?: string) // Object data for layout bindings
|
841
|
-
android.setViewModelByProject(data: {}, projectId?: string)
|
842
|
-
android.removeObserver(element: HTMLElement) // Disconnect an observed element from "parseDocument"
|
843
|
-
android.addXmlNs(name: string, uri: string) // Add global namespaces for third-party controls
|
844
|
-
android.addDependency(group: string, name: string, version?: string, type?: number) // Add application dependency implementation (build.gradle)
|
845
|
-
android.addDependencyByProject(projectId: string, group: string, name: string, version?: string, type?: number) // DEPENDENCY_TYPE: 0 - implementation 1 - api 2 - compileOnly 3 - compileOnlyApi 4 - runtimeOnly 5 - testImplementation 8 - androidTestImplementation
|
846
|
-
android.customize(build: number, tagNameOrWidget: string, options: {}) // Global attributes applied to specific views
|
847
|
-
android.loadCustomizations(name: string) // Load customizations from Local Storage
|
848
|
-
android.saveCustomizations(name: string) // Save "customize" data into Local Storage (includes xmlns)
|
849
|
-
android.resetCustomizations() // All session customizations are deleted
|
850
|
-
android.addFontProvider(authority: string, package: string, certs: string[], webFonts: string | {}) // Add additional Web fonts (Google Fonts already included)
|
851
|
-
android.setResolutionByDeviceName(value: string) // Settings prefixed with "resolution" (e.g. Pixel C)
|
852
|
-
android.getLocalSettings() // Modify controller styles and parsing rules
|
853
|
-
```
|
854
|
-
|
855
|
-
```javascript
|
856
|
-
// NOTE: squared.settings.targetAPI is always parsed (Except: customizationsBaseAPI = -1)
|
857
|
-
|
858
|
-
android.customize(android.lib.constant.BUILD_VERSION.ALL /* 0 */, "Button", {
|
859
|
-
android: {
|
860
|
-
minWidth: "35px",
|
861
|
-
minHeight: "25px"
|
161
|
+
)
|
162
|
+
.git("squared", "/path/to/squared", options: { local: true }) # Relative paths resolve from workspace root
|
163
|
+
.git(
|
164
|
+
{
|
165
|
+
emc: { uri: "e-mc", options: { "depth": 2 } }, # https://github.com/anpham6/e-mc
|
166
|
+
pir: "pi-r" # Maps task alias to repository folder
|
862
167
|
},
|
863
|
-
"
|
864
|
-
|
168
|
+
base: "https://github.com/anpham6", # Required
|
169
|
+
repo: ["squared", "android-docs", "chrome-docs"], # https://github.com/anpham6/squared
|
170
|
+
options: { # Only "repo"
|
171
|
+
"depth": 1,
|
172
|
+
"quiet": true
|
865
173
|
}
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
174
|
+
)
|
175
|
+
.with(:node) do # rake clone:node
|
176
|
+
add("e-mc", "emc") # https://github.com/anpham6/e-mc
|
177
|
+
add("pi-r", "pir") # https://github.com/anpham6/pi-r
|
178
|
+
add("squared") # https://github.com/anpham6/squared
|
179
|
+
end
|
180
|
+
.with(:python) do # rake clone:python
|
181
|
+
add("android-docs")
|
182
|
+
add("chrome-docs")
|
183
|
+
end
|
184
|
+
.git("https://github.com/anpham6") # Uses already defined root projects
|
185
|
+
.git("https://github.com/anpham6", ["emc", "pir"]) # Targets any defined project
|
186
|
+
.build(parallel: ["clone"]) # rake clone + rake clone:sync
|
187
|
+
```
|
188
|
+
|
189
|
+
### Graph
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
Workspace::Application
|
193
|
+
.new(main: "squared")
|
194
|
+
.graph(["depend"], ref: :git) # Optional
|
195
|
+
.with(:python) do
|
196
|
+
add("android-docs", "android")
|
197
|
+
add("chrome-docs", "chrome", graph: "android")
|
198
|
+
end
|
199
|
+
.with(:node) do
|
200
|
+
graph(["build", "copy"], on: { # Overrides "git"
|
201
|
+
first: proc { puts "1" },
|
202
|
+
last: proc { puts "2" }
|
203
|
+
})
|
204
|
+
script("build:dev") # npm run build:dev
|
205
|
+
# OR
|
206
|
+
run([nil, "build:dev", { "PATH" => "~/.bin" }, "--workspace", "--silent"]) # PATH="~/.bin" npm run build:dev --workspace -- --silent
|
207
|
+
|
208
|
+
add("e-mc", "emc") do
|
209
|
+
first("build", "emc:clean", "emc:depend") # rake emc:clean && rake emc:depend && rake emc:build && echo "123"
|
210
|
+
last("build", out: "123") { |out: nil| puts out } #
|
211
|
+
error("build") { |err: nil| log.debug err } #
|
212
|
+
end
|
213
|
+
add("pi-r", "pir", graph: "emc", first: {
|
214
|
+
build: proc { puts self.name } # puts "pir"
|
215
|
+
})
|
216
|
+
add("squared-express", "express", graph: "pir")
|
217
|
+
add("squared", graph: ["chrome", "express"]) do
|
218
|
+
first("git:ls-files") { puts path }
|
219
|
+
last("git:ls-files") { puts workspace.root }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
.with(:ruby) do
|
223
|
+
run("gem build") # gem build
|
224
|
+
# OR
|
225
|
+
run(["gem build", "--force", { "RUBY_VERSION" => "3.4.0" }]) # RUBY_VERSION="3.4.0" gem build --force
|
226
|
+
# OR
|
227
|
+
run(["gem pristine", ["gem build", "gem cleanup"], nil, "--debug"]) # gem pristine --debug && gem build --debug && gem cleanup --debug
|
228
|
+
# OR
|
229
|
+
run([ # PATH="~/.bin" GEM_HOME="~/.gems/ruby-3.4.0" (merged)
|
230
|
+
["gem pristine", "--all", { "PATH" => "~/.bin" }, "--silent"], # gem pristine --silent --all
|
231
|
+
["gem build", { strict: true }, { "GEM_HOME" => "~/.gems/ruby-3.4.0" }] # gem build --strict
|
232
|
+
])
|
233
|
+
|
234
|
+
add("pathname", test: ["rake test", { jobs: ENV["RAKE_JOBS"] }]) # rake test --jobs 4
|
235
|
+
add("fileutils", graph: "pathname")
|
236
|
+
add("optparse", run: "gem build", env: { "PATH" => "~/.bin" }, opts: "-v") # PATH="~/.bin" gem build -v
|
237
|
+
add("rake", graph: ["fileutils", "optparse"])
|
238
|
+
banner(command: false) # Always hide banner
|
239
|
+
end
|
240
|
+
.build
|
878
241
|
```
|
879
242
|
|
880
|
-
```
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
### Static Methods
|
892
|
-
|
893
|
-
Project resources can include additional values that are required during compilation. TypeScript definitions are available in the `types/android` directory.
|
894
|
-
|
895
|
-
```javascript
|
896
|
-
squared.parseDocument().then(node => {
|
897
|
-
const resourceId = node.localSettings.resourceId;
|
898
|
-
android.base.Resource.addString(resourceId, value, /* name */);
|
899
|
-
android.base.Resource.addArray(resourceId, name, items);
|
900
|
-
android.base.Resource.addColor(resourceId, color);
|
901
|
-
android.base.Resource.addDimen(resourceId, name, value);
|
902
|
-
android.base.Resource.addTheme(resourceId, theme);
|
903
|
-
squared.save();
|
904
|
-
});
|
905
|
-
```
|
906
|
-
|
907
|
-
### Data Binding
|
908
|
-
|
909
|
-
View model data can be applied to most HTML elements using the dataset attribute. Different view models can be used for every `parseDocument` session.
|
910
|
-
|
911
|
-
Leaving the `sessionId` empty uses the default view model which is searched last for all projects when attempting a bind.
|
912
|
-
|
913
|
-
```javascript
|
914
|
-
// NOTE: latest(undefined = 1): string (1: most recent sessionId | -1: first sessionId)
|
915
|
-
|
916
|
-
squared.parseDocument("id-1", "id-2", "id-3").then(nodes => {
|
917
|
-
const sessions = squared.latest(2); // ["00001", "00002", "00003"] => ["00002", "00003"]
|
918
|
-
android.setViewModel(
|
919
|
-
{
|
920
|
-
import: ["java.util.Map", "java.util.List"],
|
921
|
-
variable: [
|
922
|
-
{ name: "user", type: "com.example.User" },
|
923
|
-
{ name: "list", type: "List<String>" },
|
924
|
-
{ name: "map", type: "Map<String, String>" },
|
925
|
-
{ name: "index", type: "int" },
|
926
|
-
{ name: "key", type: "String" }
|
927
|
-
]
|
928
|
-
},
|
929
|
-
sessions[0] // nodes[1].sessionId
|
930
|
-
);
|
931
|
-
android.setViewModel(
|
932
|
-
{
|
933
|
-
import: ["java.util.Map"],
|
934
|
-
variable: [
|
935
|
-
{ name: "map", type: "Map<String, String>" }
|
936
|
-
]
|
937
|
-
},
|
938
|
-
sessions[1] // nodes[2].sessionId
|
939
|
-
);
|
940
|
-
});
|
941
|
-
|
942
|
-
squared.parseDocument({
|
943
|
-
element: "main",
|
944
|
-
enabledViewModel: true,
|
945
|
-
dataBindableElements: [
|
946
|
-
{
|
947
|
-
selector: "#first_name",
|
948
|
-
namespace: "android", // "android" is default
|
949
|
-
attr: "text",
|
950
|
-
expression: "user.firstName"
|
951
|
-
},
|
952
|
-
{
|
953
|
-
selector: "#last_name",
|
954
|
-
attr: "text",
|
955
|
-
expression: "user.lastName"
|
956
|
-
},
|
957
|
-
{
|
958
|
-
selector: "#remember_me",
|
959
|
-
attr: "checked",
|
960
|
-
expression: "user.rememberMe",
|
961
|
-
twoWay: true
|
962
|
-
}
|
963
|
-
],
|
964
|
-
data: {
|
965
|
-
viewModel: {
|
966
|
-
import: ["java.util.Map"],
|
967
|
-
variable: [
|
968
|
-
{ name: "map", type: "Map<String, String>" }
|
969
|
-
]
|
970
|
-
}
|
971
|
-
}
|
972
|
-
});
|
243
|
+
```sh
|
244
|
+
rake pir:graph # emc + pir
|
245
|
+
rake express:graph # emc + pir + express
|
246
|
+
rake chrome:graph # android + chrome
|
247
|
+
rake graph:python # same
|
248
|
+
rake squared:graph # android + chrome + emc + pir + express + squared
|
249
|
+
rake graph:node # same
|
250
|
+
rake rake:graph # pathname + fileutils + optparse + rake
|
251
|
+
rake graph:ruby # same
|
252
|
+
rake graph # graph:node + graph:ruby
|
973
253
|
|
974
|
-
squared
|
254
|
+
rake squared:graph:run[express,pir] # emc + pir + express + squared
|
255
|
+
rake squared:graph:run[node,-emc] # pir + express + squared
|
975
256
|
```
|
976
257
|
|
977
|
-
|
258
|
+
### Batch
|
978
259
|
|
260
|
+
```ruby
|
261
|
+
Workspace::Series.batch(:ruby, :node, {
|
262
|
+
stage: %i[graph test],
|
263
|
+
reset: %i[stash pull]
|
264
|
+
})
|
979
265
|
```
|
980
|
-
data-viewmodel-{namespace}-{attribute} -> data-viewmodel-android-text
|
981
|
-
```
|
982
|
-
|
983
|
-
These two additional output parameters are required when using the "**data-viewmodel**" prefix.
|
984
266
|
|
985
|
-
|
986
|
-
<div id="main">
|
987
|
-
<label>Name:</label>
|
988
|
-
<input id="first_name" type="text" data-viewmodel-android-text="user.firstName" />
|
989
|
-
<input id="last_name" type="text" data-viewmodel-android-text="user.lastName" />
|
990
|
-
<input id="remember_me" type="checkbox" data-viewmodel-android-checked="=user.rememberMe" /> <!-- "=" for two-way binding -->
|
991
|
-
</div>
|
992
|
-
```
|
267
|
+
### Rename
|
993
268
|
|
994
|
-
```
|
995
|
-
|
996
|
-
<data>
|
997
|
-
<import type="java.util.Map" />
|
998
|
-
<import type="java.util.List" />
|
999
|
-
<variable name="user" type="com.example.User" />
|
1000
|
-
<variable name="list" type="List<String>" />
|
1001
|
-
<variable name="map" type="Map<String, String>" />
|
1002
|
-
<variable name="index" type="int" />
|
1003
|
-
<variable name="key" type="String" />
|
1004
|
-
</data>
|
1005
|
-
<LinearLayout android:id="@+id/main">
|
1006
|
-
<TextView android:text="Name:" />
|
1007
|
-
<EditText
|
1008
|
-
android:id="@+id/first_name"
|
1009
|
-
android:inputType="text"
|
1010
|
-
android:text="@{user.firstName}" />
|
1011
|
-
<EditText
|
1012
|
-
android:id="@+id/last_name"
|
1013
|
-
android:inputType="text"
|
1014
|
-
android:text="@{user.lastName}" />
|
1015
|
-
<CheckBox
|
1016
|
-
android:id="@+id/remember_me"
|
1017
|
-
android:checked="@={user.rememberMe}" />
|
1018
|
-
</LinearLayout>
|
1019
|
-
</layout>
|
269
|
+
```ruby
|
270
|
+
Workspace::Series.rename("depend", "install")
|
1020
271
|
```
|
1021
272
|
|
1022
|
-
|
1023
|
-
|
1024
|
-
Some applications can benefit from using includes or merge tags to share common templates. Nested includes is supported.
|
1025
|
-
|
1026
|
-
```html
|
1027
|
-
<div>
|
1028
|
-
<div id="item1">Item 1</div>
|
1029
|
-
<div id="item2" data-android-include-start="true" data-android-include-merge="true" data-pathname-android="app/src/main/res/layout-land" data-filename-android="filename1.xml">Item 2</div>
|
1030
|
-
<div id="item3">Item 3</div>
|
1031
|
-
<div id="item4" data-android-include-end="true">Item 4</div>
|
1032
|
-
<div id="item5" data-android-include="filename2" data-android-include-end="true" data-android-include-viewmodel="exampleData">Item 5</div> <!-- viewModel -->
|
1033
|
-
</div>
|
1034
|
-
```
|
273
|
+
## Usage
|
1035
274
|
|
1036
|
-
```
|
1037
|
-
|
1038
|
-
|
1039
|
-
squared.parseDocument({
|
1040
|
-
element: document.body,
|
1041
|
-
projectId: "project-1", // Affects all layouts in same project
|
1042
|
-
enabledIncludes: true,
|
1043
|
-
includableElements: [
|
1044
|
-
{
|
1045
|
-
selectorStart: "#item2",
|
1046
|
-
selectorEnd: "#item4",
|
1047
|
-
pathname: "app/src/main/res/layout-land",
|
1048
|
-
filename: "filename1.xml",
|
1049
|
-
merge: true // Multiple elements will auto-merge
|
1050
|
-
},
|
1051
|
-
{
|
1052
|
-
selectorStart: "#item5",
|
1053
|
-
selectorEnd: "#item5",
|
1054
|
-
filename: "filename2",
|
1055
|
-
viewModel: "exampleData" // One element only (merge=false)
|
1056
|
-
}
|
1057
|
-
]
|
1058
|
-
});
|
1059
|
-
```
|
1060
|
-
> [!NOTE]
|
1061
|
-
> By sessionId has precedence when associating a view model.
|
1062
|
-
|
1063
|
-
```xml
|
1064
|
-
<LinearLayout>
|
1065
|
-
<TextView>Item 1</TextView>
|
1066
|
-
<include layout="@layout/filename1" />
|
1067
|
-
<include layout="@layout/filename2" app:exampleData="@{exampleData}" />
|
1068
|
-
</LinearLayout>
|
1069
|
-
<!-- res/layout/activity_main.xml -->
|
1070
|
-
|
1071
|
-
<merge>
|
1072
|
-
<TextView>Item 2</TextView>
|
1073
|
-
<TextView>Item 3</TextView>
|
1074
|
-
<TextView>Item 4</TextView>
|
1075
|
-
</merge>
|
1076
|
-
<!-- res/layout-land/filename1.xml -->
|
1077
|
-
|
1078
|
-
<layout>
|
1079
|
-
<data>
|
1080
|
-
<variable name="exampleData" type="com.example.ExampleData" />
|
1081
|
-
</data>
|
1082
|
-
<TextView>Item 5</TextView>
|
1083
|
-
</layout>
|
1084
|
-
<!-- res/layout/filename2.xml -->
|
1085
|
-
```
|
275
|
+
```sh
|
276
|
+
rake -T # List tasks
|
277
|
+
rake # rake status (usually "build")
|
1086
278
|
|
1087
|
-
|
279
|
+
# GIT_OPTIONS=rebase
|
280
|
+
rake pull # All except "default" + "app"
|
281
|
+
rake pull:ruby # pathname + optparse + logger
|
282
|
+
rake pull:default # pathname + optparse
|
283
|
+
rake pull:app # squared
|
284
|
+
rake pull:node # emc + pir + squared
|
1088
285
|
|
1089
|
-
|
1090
|
-
|
286
|
+
rake build # All except "android"
|
287
|
+
rake doc # optparse + android
|
288
|
+
rake depend # All except "default"
|
1091
289
|
|
1092
|
-
|
290
|
+
rake build:ruby # rake compile + rake install + rake install
|
1093
291
|
|
1094
|
-
|
292
|
+
rake clean # All except "default" + "app"
|
293
|
+
rake clean:ruby # rake clean + rake clean + ["tmp/"]
|
294
|
+
rake clean:default # rake clean + rake clean + skip
|
295
|
+
rake clean:app # none + skip + ["build/"]
|
296
|
+
rake clean:node # none + ["publish/**/*.js", "tmp/"] + ["build/"]
|
1095
297
|
|
1096
|
-
|
1097
|
-
|
1098
|
-
<span>Item 1</span>
|
1099
|
-
<span data-android-target="location">Item 2</span>
|
1100
|
-
<span data-android-target="location" data-android-target-index="1">Item 3</span>
|
1101
|
-
<div>
|
1102
|
-
<ul id="location">
|
1103
|
-
<li>Item 4</li>
|
1104
|
-
<li>Item 5</li>
|
1105
|
-
<!-- span -->
|
1106
|
-
</ul>
|
298
|
+
rake squared:run[#] # List scripts (node)
|
299
|
+
rake squared:rake[#] # List tasks (ruby)
|
1107
300
|
```
|
1108
301
|
|
1109
|
-
```
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
<TextView>Item 3</TextView>
|
1116
|
-
<TextView>Item 5</TextView>
|
1117
|
-
<TextView>Item 2</TextView>
|
1118
|
-
</LinearLayout>
|
302
|
+
```sh
|
303
|
+
rake build:app # squared + cli + sqd-serve
|
304
|
+
rake squared:build:workspace # cli + sqd-serve
|
305
|
+
rake pull:sqd # sqd-admin
|
306
|
+
rake squared:pull:workspace # sqd-serve + sqd-admin
|
307
|
+
rake squared:outdated:workspace # cli + sqd-serve + sqd-admin
|
1119
308
|
```
|
1120
309
|
|
1121
|
-
|
310
|
+
## Methods
|
1122
311
|
|
1123
|
-
|
312
|
+
Task:
|
1124
313
|
|
1125
|
-
|
314
|
+
* run
|
315
|
+
* script
|
316
|
+
* depend
|
317
|
+
* graph
|
318
|
+
* doc
|
319
|
+
* lint
|
320
|
+
* test
|
321
|
+
* clean
|
1126
322
|
|
1127
|
-
|
1128
|
-
data-android-attr-{namespace}? -> Default is "android"
|
1129
|
-
```
|
323
|
+
Non-task:
|
1130
324
|
|
1131
|
-
|
1132
|
-
|
1133
|
-
data-android-attr="layout_width::match_parent;layout_height::match_parent"
|
1134
|
-
data-android-attr-app="layout_scrollFlags::scroll|exitUntilCollapsed">
|
1135
|
-
</div>
|
1136
|
-
```
|
325
|
+
* log
|
326
|
+
* exclude
|
1137
327
|
|
1138
|
-
|
1139
|
-
<LinearLayout
|
1140
|
-
android:id="@+id/customId"
|
1141
|
-
android:layout_width="match_parent"
|
1142
|
-
android:layout_height="match_parent"
|
1143
|
-
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
|
1144
|
-
```
|
328
|
+
## Styles
|
1145
329
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
330
|
+
* banner
|
331
|
+
* border
|
332
|
+
* header
|
333
|
+
* active
|
334
|
+
* inline
|
335
|
+
* current
|
336
|
+
* major
|
337
|
+
* red
|
338
|
+
* yellow
|
339
|
+
* green
|
1152
340
|
|
1153
|
-
|
341
|
+
## Environment
|
1154
342
|
|
1155
|
-
|
343
|
+
### Path
|
1156
344
|
|
1157
|
-
|
1158
|
-
import android.graphics.drawable.Animatable;
|
345
|
+
All project executable programs can have their binary path set to a non-global alias.
|
1159
346
|
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
347
|
+
```ruby
|
348
|
+
Common::PATH.merge!({
|
349
|
+
GIT: '/usr/bin/git',
|
350
|
+
GEM: '~/.rvm/rubies/ruby-3.4.0/bin/gem',
|
351
|
+
BUNDLE: '~/.rvm/gems/ruby-3.4.0/bin/bundle',
|
352
|
+
RAKE: '~/.rvm/gems/ruby-3.4.0/bin/rake',
|
353
|
+
NPM: '/opt/node/v22.0.0/bin/npm',
|
354
|
+
PYTHON: "#{ENV['PYTHONPATH']}/bin/python"
|
355
|
+
})
|
1165
356
|
```
|
1166
357
|
|
1167
|
-
###
|
358
|
+
### Build
|
1168
359
|
|
1169
|
-
|
360
|
+
```ruby
|
361
|
+
Workspace::Application
|
362
|
+
.new
|
363
|
+
.add("squared", run: "gcc a.c -o a.o", opts: { __debug__: { g: true, O2: true, c: nil }, c: true, j: 4 }) # gcc a.c -o a.o -c -j4
|
1170
364
|
|
1171
|
-
|
1172
|
-
squared.settings.composableElements = ["main", "#content", "--boxShadow", "--height=300px", {
|
1173
|
-
selector: "main",
|
1174
|
-
android: {
|
1175
|
-
layout_height: "match_parent"
|
1176
|
-
},
|
1177
|
-
tools: {
|
1178
|
-
composableName: "com.example.compose.Preview"
|
1179
|
-
}
|
1180
|
-
}];
|
1181
|
-
squared.settings.createBuildDependencies = true; // Optional
|
1182
|
-
```
|
1183
|
-
|
1184
|
-
You can also do it using the "**android.substitute**" extension directly inside the HTML element.
|
365
|
+
BUILD_TYPE # global
|
1185
366
|
|
1186
|
-
|
1187
|
-
|
367
|
+
# :env :run :opts :type
|
368
|
+
# LD_LIBRARY_PATH="path/to/lib" CFLAGS="-Wall" gcc a.c -o a.o -g -O2
|
369
|
+
BUILD_${NAME} # gcc a.c -o a.o
|
370
|
+
BUILD_${NAME}_OPTS # -g
|
371
|
+
BUILD_${NAME}_ENV # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
|
372
|
+
BUILD_${NAME}_TYPE # debug
|
1188
373
|
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
}
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
/* OR */
|
1198
|
-
squared.attr("android.substitute", "viewAttributes", items.concat(["hint", "buttonTint"])); // Attributes to preserve (default is "android.view.View")
|
1199
|
-
squared.attr("android.substitute", "attributeMapping", { "android:src": "app:srcCompat", "icon": "navigationIcon" /* android */});
|
1200
|
-
|
1201
|
-
squared.parseDocument({
|
1202
|
-
element: document.body,
|
1203
|
-
substitutableElements: [{
|
1204
|
-
selector: "#content",
|
1205
|
-
tag: "androidx.compose.ui.platform.ComposeView",
|
1206
|
-
renderChildren: false
|
1207
|
-
}],
|
1208
|
-
|
1209
|
-
// Some extensions have convenience properties
|
1210
|
-
enabledSubstitute: true,
|
1211
|
-
/* OR */
|
1212
|
-
include: ["android.substitute"]
|
1213
|
-
});
|
1214
|
-
```
|
374
|
+
# :env :opts :script :args
|
375
|
+
# NODE_ENV="production" NO_COLOR="1" npm run --loglevel=error --workspaces=false build:dev -- --quiet
|
376
|
+
BUILD_${NAME} # build:dev
|
377
|
+
BUILD_${NAME}_OPTS # --loglevel=error --workspaces=false
|
378
|
+
BUILD_${NAME}_ENV # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
|
379
|
+
BUILD_${NAME}_DEV # pattern,0,1 (:dev)
|
380
|
+
BUILD_${NAME}_PROD # pattern,0,1 (:prod)
|
381
|
+
SCRIPT_${NAME}_OPTS # --quiet
|
1215
382
|
|
1216
|
-
|
1217
|
-
<body>
|
1218
|
-
<header style="height: 100px"></header>
|
1219
|
-
<main id="content"
|
1220
|
-
data-use="android.substitute"
|
1221
|
-
data-android-substitute-tag="androidx.compose.ui.platform.ComposeView"
|
1222
|
-
style="height: 300px; box-shadow: 10px 5px 5px black;">
|
1223
|
-
<!-- Interior elements are not rendered -->
|
1224
|
-
</main>
|
1225
|
-
<footer style="height: 80px"></footer>
|
1226
|
-
</body>
|
383
|
+
BUILD_${NAME}=0 # skip project
|
1227
384
|
```
|
1228
385
|
|
1229
|
-
|
386
|
+
### Graph
|
1230
387
|
|
1231
|
-
```
|
1232
|
-
|
1233
|
-
|
1234
|
-
data-android-substitute-tag="androidx.fragment.app.FragmentContainerView"
|
1235
|
-
data-android-substitute-render-children="false"
|
1236
|
-
data-android-attr="name::com.github.fragment;tag::example">
|
1237
|
-
<!-- Interior elements are not rendered -->
|
1238
|
-
</div>
|
388
|
+
```ruby
|
389
|
+
GRAPH_${NAME} # depend,build => squared:depend + squared:build
|
390
|
+
GRAPH_${NAME}_PASS # -emc,pir,express => pir + express
|
1239
391
|
```
|
1240
392
|
|
1241
|
-
|
1242
|
-
|
1243
|
-
Usually you do not render child elements when using Compose View. There are some cases where it can be used effectively to reproduce the desired layout.
|
1244
|
-
|
1245
|
-
```javascript
|
1246
|
-
squared.parseDocument({
|
1247
|
-
element: document.body,
|
1248
|
-
include: ["android.substitute"], // OR: settings.enabledSubstitute
|
1249
|
-
substitutableElements: [{
|
1250
|
-
selector: "#navigation",
|
1251
|
-
tag: "com.google.android.material.tabs.TabLayout",
|
1252
|
-
tagChild: "com.google.android.material.tabs.TabItem",
|
1253
|
-
tagChildAttr: {
|
1254
|
-
android: {
|
1255
|
-
layout_height: "match_parent"
|
1256
|
-
}
|
1257
|
-
},
|
1258
|
-
renderChildren: true,
|
1259
|
-
autoLayout: true
|
1260
|
-
}]
|
1261
|
-
});
|
1262
|
-
```
|
393
|
+
### Logger
|
1263
394
|
|
1264
|
-
|
1265
|
-
<ul id="navigation"
|
1266
|
-
data-use-android="android.substitute"
|
1267
|
-
data-android-attr="layout_height::match_parent"
|
1268
|
-
data-android-substitute-tag="com.google.android.material.tabs.TabLayout"
|
1269
|
-
data-android-substitute-tag-child="com.google.android.material.tabs.TabItem"
|
1270
|
-
data-android-substitute-tag-child-attr="layout_height::match_parent"
|
1271
|
-
data-android-substitute-auto-layout="true">
|
1272
|
-
<li>TAB 1</li>
|
1273
|
-
<li>TAB 2</li>
|
1274
|
-
<li>TAB 3</li>
|
1275
|
-
</ul>
|
1276
|
-
```
|
395
|
+
These global options also can target the project suffix `${NAME}`. (e.g. LOG_FILE_EMC)
|
1277
396
|
|
1278
|
-
```
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
android:text="@string/tab_1" />
|
1287
|
-
<com.google.android.material.tabs.TabItem
|
1288
|
-
android:layout_height="match_parent"
|
1289
|
-
android:layout_width="wrap_content"
|
1290
|
-
android:text="@string/tab_2" />
|
1291
|
-
<com.google.android.material.tabs.TabItem
|
1292
|
-
android:layout_height="match_parent"
|
1293
|
-
android:layout_width="wrap_content"
|
1294
|
-
android:text="@string/tab_3" />
|
1295
|
-
</com.google.android.material.tabs.TabLayout>
|
1296
|
-
```
|
1297
|
-
|
1298
|
-
### Downloadable Fonts
|
1299
|
-
|
1300
|
-
Google Fonts are pre-installed and can be used without any additional configuration.
|
1301
|
-
|
1302
|
-
* [Guide](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts)
|
1303
|
-
|
1304
|
-
```xml
|
1305
|
-
<!-- build.gradle -->
|
1306
|
-
dependencies {
|
1307
|
-
implementation 'androidx.appcompat:appcompat:1.6.0' <!-- createBuildDependencies = true -->
|
1308
|
-
<!-- OR -->
|
1309
|
-
implementation 'com.android.support:appcompat-v7:28.0.0'
|
1310
|
-
}
|
1311
|
-
|
1312
|
-
<!-- AndroidManifest.xml -->
|
1313
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <!-- createManifest = true -->
|
1314
|
-
<application android:theme="@style/AppTheme">
|
1315
|
-
<meta-data android:name="preloaded_fonts" android:resource="@array/preloaded_fonts" />
|
1316
|
-
</application>
|
1317
|
-
</manifest>
|
1318
|
-
```
|
1319
|
-
|
1320
|
-
```javascript
|
1321
|
-
// https://developers.google.com/fonts/docs/developer_api
|
1322
|
-
|
1323
|
-
await android.addFontProvider(
|
1324
|
-
"com.google.android.gms.fonts",
|
1325
|
-
"com.google.android.gms",
|
1326
|
-
["MIIEqDCCA5CgAwIBAgIJANWFuGx9007...", "MIIEQzCCAyugAwIBAgIJAMLgh0Zk..."],
|
1327
|
-
"https://www.googleapis.com/webfonts/v1/webfonts?key=1234567890" // JSON object is synchronous
|
1328
|
-
);
|
1329
|
-
/* OR */
|
1330
|
-
squared.attr("android.resource.fonts", "installGoogleFonts", false); // Use browser and local fonts only
|
397
|
+
```ruby
|
398
|
+
LOG_FILE # %Y-%m-%d.log
|
399
|
+
# OR
|
400
|
+
LOG_AUTO # year,y,month,m,day,d,1
|
401
|
+
# Optional
|
402
|
+
LOG_DIR # exist?
|
403
|
+
LOG_LEVEL # See gem "logger"
|
404
|
+
LOG_COLUMNS # terminal width (default: 80)
|
1331
405
|
```
|
1332
406
|
|
1333
|
-
###
|
1334
|
-
|
1335
|
-
Most attributes can be excluded from the generated XML using the dataset feature in HTML. One or more can be applied to any tag using the OR "**|**" operator. These may cause warnings when you compile your project and should only be used when an extension has their custom attributes overwritten.
|
1336
|
-
|
1337
|
-
NOTE: Defining an element "**id**" will prevent it from being removed during the optimization phase.
|
407
|
+
### Repo
|
1338
408
|
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
409
|
+
These global options also can target the application main suffix `${NAME}`. (e.g. REPO_ROOT_SQUARED)
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
REPO_ROOT # parent dir
|
413
|
+
REPO_HOME # project dir (main)
|
414
|
+
REPO_BUILD # run,script
|
415
|
+
REPO_GROUP # string
|
416
|
+
REPO_REF # e.g. ruby,node
|
417
|
+
REPO_DEV # pattern,0,1
|
418
|
+
REPO_PROD # pattern,0,1
|
419
|
+
REPO_WARN # 0,1
|
420
|
+
REPO_SYNC # 0,1
|
421
|
+
REPO_MANIFEST # e.g. latest,nightly,prod
|
422
|
+
REPO_TIMEOUT # confirm dialog (seconds)
|
423
|
+
```
|
424
|
+
|
425
|
+
## Git
|
426
|
+
|
427
|
+
Most project classes will inherit from `Git` which enables these tasks:
|
428
|
+
|
429
|
+
| Task | Git | Command |
|
430
|
+
| :--------- | :--------------- | :-------------------------------------------- |
|
431
|
+
| branch | branch | create set delete move copy list edit current |
|
432
|
+
| checkout | checkout | commit branch track detach path |
|
433
|
+
| commit | commit | add all amend amend-orig |
|
434
|
+
| diff | diff | head cached branch files between contain |
|
435
|
+
| fetch | fetch | origin remote |
|
436
|
+
| files | ls-files | cached modified deleted others |
|
437
|
+
| pull | pull | origin remote |
|
438
|
+
| rebase | rebase | branch onto send |
|
439
|
+
| refs | ls-remote --refs | heads tags remote |
|
440
|
+
| reset | reset | commit index patch mode |
|
441
|
+
| restore | restore | source worktree staged overlay |
|
442
|
+
| rev | rev | commit branch output parseopt |
|
443
|
+
| show | show | format oneline |
|
444
|
+
| stash | stash | push pop apply drop list |
|
445
|
+
| tag | tag | add delete list |
|
446
|
+
|
447
|
+
You can disable all of them at once using the `exclude` property.
|
448
|
+
|
449
|
+
```ruby
|
450
|
+
Workspace::Application
|
451
|
+
.new
|
452
|
+
.add("squared", exclude: :git)
|
453
|
+
```
|
454
|
+
|
455
|
+
You can disable one or more of them using the `pass` property as a *string*.
|
456
|
+
|
457
|
+
```ruby
|
458
|
+
Workspace::Application
|
459
|
+
.new
|
460
|
+
.add("squared", pass: ["pull"], ref: :node)
|
461
|
+
.pass("pull", ref: :node) { read_packagemanager(:private) }
|
1349
462
|
```
|
1350
463
|
|
1351
464
|
## LICENSE
|