@htmlplus/element 0.1.2 → 0.1.5
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/README.md +123 -25
- package/dist/client/decorators/bind.js +2 -1
- package/dist/client/decorators/element.js +113 -3
- package/dist/client/decorators/event.d.ts +19 -1
- package/dist/client/decorators/event.js +2 -2
- package/dist/client/decorators/index.js +0 -1
- package/dist/client/decorators/listen.d.ts +8 -1
- package/dist/client/decorators/method.js +2 -2
- package/dist/client/decorators/property.d.ts +11 -1
- package/dist/client/decorators/property.js +14 -5
- package/dist/client/decorators/state.js +8 -4
- package/dist/client/helpers/direction.d.ts +1 -1
- package/dist/client/helpers/slots.js +2 -1
- package/dist/client/services/link.js +3 -3
- package/dist/client/utils/api.d.ts +5 -1
- package/dist/client/utils/define-property.d.ts +1 -0
- package/dist/client/utils/define-property.js +1 -0
- package/dist/client/utils/host.js +1 -1
- package/dist/client/utils/index.d.ts +1 -1
- package/dist/client/utils/index.js +1 -1
- package/dist/compiler/compiler.js +3 -3
- package/dist/compiler/index.d.ts +1 -2
- package/dist/compiler/index.js +1 -2
- package/dist/compiler/plugins/attach.js +7 -10
- package/dist/compiler/plugins/docs.js +1 -0
- package/dist/compiler/plugins/extract.js +14 -2
- package/dist/compiler/plugins/index.d.ts +1 -0
- package/dist/compiler/plugins/index.js +1 -0
- package/dist/compiler/plugins/react.proxy/index.d.ts +1 -0
- package/dist/compiler/plugins/react.proxy/index.js +1 -0
- package/dist/compiler/plugins/react.proxy/react.proxy.d.ts +9 -0
- package/dist/compiler/plugins/react.proxy/react.proxy.js +60 -0
- package/dist/compiler/plugins/react.proxy/templates/README.md.hbs +1 -0
- package/dist/compiler/plugins/react.proxy/templates/_.gitignore.hbs +2 -0
- package/dist/compiler/plugins/react.proxy/templates/package.json.hbs +36 -0
- package/dist/compiler/plugins/react.proxy/templates/rollup.config.js.hbs +20 -0
- package/dist/compiler/plugins/react.proxy/templates/src/components/index.ts.hbs +3 -0
- package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.ts.hbs +38 -0
- package/dist/compiler/plugins/react.proxy/templates/src/index.ts.hbs +1 -0
- package/dist/compiler/plugins/react.proxy/templates/src/proxy.ts.hbs +277 -0
- package/dist/compiler/plugins/react.proxy/templates/tsconfig.json.hbs +17 -0
- package/dist/compiler/utils/__dirname.d.ts +1 -0
- package/dist/compiler/utils/__dirname.js +5 -0
- package/dist/compiler/utils/index.d.ts +3 -0
- package/dist/compiler/utils/index.js +3 -0
- package/dist/compiler/utils/is-directory-empty.d.ts +1 -0
- package/dist/compiler/utils/is-directory-empty.js +19 -0
- package/dist/compiler/utils/render-template.d.ts +1 -0
- package/dist/compiler/utils/render-template.js +25 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types/plugin.d.ts +4 -3
- package/package.json +10 -4
- package/dist/client/decorators/listen-options.d.ts +0 -2
- package/dist/client/decorators/listen-options.js +0 -2
- package/dist/types/api.d.ts +0 -5
- package/dist/types/api.js +0 -1
- package/dist/types/direction.d.ts +0 -1
- package/dist/types/direction.js +0 -1
- package/dist/types/event-options.d.ts +0 -18
- package/dist/types/event-options.js +0 -1
- package/dist/types/listen-options.d.ts +0 -7
- package/dist/types/listen-options.js +0 -1
- package/dist/types/property-options.d.ts +0 -10
- package/dist/types/property-options.js +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
export const isDirectoryEmpty = (directory) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
try {
|
|
13
|
+
const files = yield fs.readdirSync(directory);
|
|
14
|
+
return !files.length;
|
|
15
|
+
}
|
|
16
|
+
catch (_a) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderTemplate: (source: string | Array<string>, destination: string, options?: any) => (context: any) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import glob from 'fast-glob';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import handlebars from 'handlebars';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
export const renderTemplate = (source, destination, options) => (context) => {
|
|
6
|
+
const files = glob.sync(source, options);
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
const from = path.resolve((options === null || options === void 0 ? void 0 : options.cwd) || '', file);
|
|
9
|
+
const to = path.join(destination, path
|
|
10
|
+
.normalize(file)
|
|
11
|
+
.split(path.sep)
|
|
12
|
+
.slice(1)
|
|
13
|
+
.map((section) => handlebars.compile(section)(context))
|
|
14
|
+
.join(path.sep)
|
|
15
|
+
.replace('_.', '.')
|
|
16
|
+
.replace('.hbs', ''));
|
|
17
|
+
const directory = path.dirname(to);
|
|
18
|
+
const raw = fs.readFileSync(from, 'utf8');
|
|
19
|
+
const template = handlebars.compile(raw)(context);
|
|
20
|
+
if (!fs.existsSync(directory)) {
|
|
21
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
fs.writeFileSync(to, template, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
};
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
|
|
2
2
|
export interface Context {
|
|
3
3
|
script?: string;
|
|
4
|
+
componentClassName?: string;
|
|
5
|
+
componentInterfaceName?: string;
|
|
4
6
|
componentKey?: string;
|
|
5
7
|
componentTag?: string;
|
|
6
8
|
directoryName?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from './api.js';
|
|
2
1
|
export * from './context.js';
|
|
3
|
-
export * from './direction.js';
|
|
4
|
-
export * from './event-options.js';
|
|
5
|
-
export * from './listen-options.js';
|
|
6
2
|
export * from './plugin.js';
|
|
7
3
|
export * from './plus-element.js';
|
|
8
|
-
export * from './property-options.js';
|
package/dist/types/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from './api.js';
|
|
2
1
|
export * from './context.js';
|
|
3
|
-
export * from './direction.js';
|
|
4
|
-
export * from './event-options.js';
|
|
5
|
-
export * from './listen-options.js';
|
|
6
2
|
export * from './plugin.js';
|
|
7
3
|
export * from './plus-element.js';
|
|
8
|
-
export * from './property-options.js';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Context } from './context.js';
|
|
2
|
+
export declare type Return<T> = void | T | Promise<T>;
|
|
2
3
|
export declare type Plugin = {
|
|
3
4
|
name: string;
|
|
4
|
-
start?: (global: any) =>
|
|
5
|
-
next?: (context: Context, global: any) =>
|
|
6
|
-
finish?: (global: any) =>
|
|
5
|
+
start?: (global: any) => Return<any>;
|
|
6
|
+
next?: (context: Context, global: any) => Return<Context>;
|
|
7
|
+
finish?: (global: any) => Return<any>;
|
|
7
8
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlplus/element",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Masood Abdolian <m.abdolian@gmail.com>",
|
|
6
6
|
"description": "Compiler of HTMLPlus",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"
|
|
9
|
+
"prebuild": "npm run clean",
|
|
10
|
+
"build": "tsc",
|
|
10
11
|
"build:watch": "tsc -w",
|
|
12
|
+
"postbuild": "node scripts/build.post.js",
|
|
11
13
|
"clean": "rimraf dist",
|
|
12
|
-
"
|
|
13
|
-
"start": "node src/dev/start.js"
|
|
14
|
+
"format": "prettier --write .",
|
|
15
|
+
"dev:start": "node src/dev/start.js",
|
|
16
|
+
"dev:build": "node src/dev/build.js"
|
|
14
17
|
},
|
|
15
18
|
"exports": {
|
|
16
19
|
".": {
|
|
@@ -78,6 +81,8 @@
|
|
|
78
81
|
"@babel/types": "^7.16.0",
|
|
79
82
|
"@types/node": "^16.11.11",
|
|
80
83
|
"change-case": "^4.1.2",
|
|
84
|
+
"fast-glob": "^3.2.11",
|
|
85
|
+
"handlebars": "^4.7.7",
|
|
81
86
|
"log-update": "^5.0.0",
|
|
82
87
|
"sass": "^1.43.4",
|
|
83
88
|
"ts-node": "^10.4.0",
|
|
@@ -86,6 +91,7 @@
|
|
|
86
91
|
},
|
|
87
92
|
"devDependencies": {
|
|
88
93
|
"@trivago/prettier-plugin-sort-imports": "^3.1.1",
|
|
94
|
+
"cpy": "^9.0.0",
|
|
89
95
|
"prettier": "^2.5.0",
|
|
90
96
|
"rimraf": "^3.0.2",
|
|
91
97
|
"vite": "^2.7.10"
|
package/dist/types/api.d.ts
DELETED
package/dist/types/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type Direction = 'ltr' | 'rtl';
|
package/dist/types/direction.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface EventOptions {
|
|
2
|
-
/**
|
|
3
|
-
* A string custom event name to override the default.
|
|
4
|
-
*/
|
|
5
|
-
name?: string;
|
|
6
|
-
/**
|
|
7
|
-
* A Boolean indicating whether the event bubbles up through the DOM or not. default is `false`.
|
|
8
|
-
*/
|
|
9
|
-
bubbles?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* A Boolean indicating whether the event is cancelable. default is `false`.
|
|
12
|
-
*/
|
|
13
|
-
cancelable?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* A Boolean value indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM. The default is false.
|
|
16
|
-
*/
|
|
17
|
-
composed?: boolean;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|