@plasmicpkgs/wordpress 0.0.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/LICENSE.md +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.esm.js +116 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +7 -0
- package/package.json +43 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Plasmic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Plasmic custom functions for Wordpress REST API
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function _ensure<T>(x: T | null | undefined, message?: string): T;
|
|
2
|
+
|
|
3
|
+
export declare type _QueryOperator = (typeof _queryOperators)[number]["value"];
|
|
4
|
+
|
|
5
|
+
export declare const _queryOperators: readonly [{
|
|
6
|
+
readonly value: "search";
|
|
7
|
+
readonly label: "Search";
|
|
8
|
+
}, {
|
|
9
|
+
readonly value: "slug";
|
|
10
|
+
readonly label: "Filter by Slug";
|
|
11
|
+
}, {
|
|
12
|
+
readonly value: "author";
|
|
13
|
+
readonly label: "Filter by author";
|
|
14
|
+
}];
|
|
15
|
+
|
|
16
|
+
export declare function queryWordpress(wordpressUrl: string, type: "pages" | "posts", queryOperator?: _QueryOperator, filterValue?: string, limit?: number): Promise<any>;
|
|
17
|
+
|
|
18
|
+
export declare function registerWordpress(loader?: {
|
|
19
|
+
registerFunction: any;
|
|
20
|
+
}): void;
|
|
21
|
+
|
|
22
|
+
export { }
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/index.ts
|
|
23
|
+
import registerFunction from "@plasmicapp/host/registerFunction";
|
|
24
|
+
|
|
25
|
+
// src/utils.ts
|
|
26
|
+
var queryOperators = [
|
|
27
|
+
{
|
|
28
|
+
value: "search",
|
|
29
|
+
label: "Search"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: "slug",
|
|
33
|
+
label: "Filter by Slug"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: "author",
|
|
37
|
+
label: "Filter by author"
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
function ensure(x, message) {
|
|
41
|
+
if (x === null || x === void 0) {
|
|
42
|
+
debugger;
|
|
43
|
+
throw new Error(message != null ? message : `Value must not be undefined or null`);
|
|
44
|
+
} else {
|
|
45
|
+
return x;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/query-wordpress.ts
|
|
50
|
+
function queryWordpress(wordpressUrl, type, queryOperator, filterValue, limit) {
|
|
51
|
+
return __async(this, null, function* () {
|
|
52
|
+
const urlParams = new URLSearchParams();
|
|
53
|
+
if (queryOperator && filterValue) {
|
|
54
|
+
urlParams.append(queryOperator, filterValue);
|
|
55
|
+
}
|
|
56
|
+
if (limit) {
|
|
57
|
+
urlParams.append("per_page", limit.toString());
|
|
58
|
+
}
|
|
59
|
+
const urlWithSlash = wordpressUrl.endsWith("/") ? wordpressUrl : `${wordpressUrl}/`;
|
|
60
|
+
const url = new URL(`wp-json/wp/v2/${type}`, urlWithSlash);
|
|
61
|
+
url.search = urlParams.toString();
|
|
62
|
+
const resp = yield fetch(url);
|
|
63
|
+
return yield resp.json();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var queryWordpressMeta = {
|
|
67
|
+
name: "queryWordpress",
|
|
68
|
+
displayName: "Query WordPress",
|
|
69
|
+
importPath: "@plasmicpkgs/wordpress",
|
|
70
|
+
params: [
|
|
71
|
+
{
|
|
72
|
+
name: "wordpressUrl",
|
|
73
|
+
type: "string"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "queryType",
|
|
77
|
+
type: "choice",
|
|
78
|
+
options: ["pages", "posts"]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "queryOperator",
|
|
82
|
+
type: "choice",
|
|
83
|
+
options: Object.values(queryOperators).map((item) => ({
|
|
84
|
+
label: item.label,
|
|
85
|
+
value: item.value
|
|
86
|
+
}))
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "filterValue",
|
|
90
|
+
type: "string"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "limit",
|
|
94
|
+
type: "number"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/index.ts
|
|
100
|
+
function registerWordpress(loader) {
|
|
101
|
+
function _registerFunction(fn, meta) {
|
|
102
|
+
if (loader) {
|
|
103
|
+
loader.registerFunction(fn, meta);
|
|
104
|
+
} else {
|
|
105
|
+
registerFunction(fn, meta);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_registerFunction(queryWordpress, queryWordpressMeta);
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
ensure as _ensure,
|
|
112
|
+
queryOperators as _queryOperators,
|
|
113
|
+
queryWordpress,
|
|
114
|
+
registerWordpress
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/utils.ts", "../src/query-wordpress.ts"],
|
|
4
|
+
"sourcesContent": ["import registerFunction, {\n CustomFunctionMeta,\n} from \"@plasmicapp/host/registerFunction\";\nimport { queryWordpress, queryWordpressMeta } from \"./query-wordpress\";\n\nexport function registerWordpress(loader?: { registerFunction: any }) {\n function _registerFunction<T extends (...args: any[]) => any>(\n fn: T,\n meta: CustomFunctionMeta<T>\n ) {\n if (loader) {\n loader.registerFunction(fn, meta);\n } else {\n registerFunction(fn, meta);\n }\n }\n\n _registerFunction(queryWordpress, queryWordpressMeta);\n}\n\nexport { queryWordpress };\n\n// used by @plasmicpkgs/plasmic-wordpress\nexport { ensure as _ensure, queryOperators as _queryOperators } from \"./utils\";\nexport type { QueryOperator as _QueryOperator } from \"./utils\";\n", "export const queryOperators = [\n {\n value: \"search\",\n label: \"Search\",\n },\n {\n value: \"slug\",\n label: \"Filter by Slug\",\n },\n {\n value: \"author\",\n label: \"Filter by author\",\n },\n] as const;\n\nexport type QueryOperator = (typeof queryOperators)[number][\"value\"];\n\nexport function ensure<T>(x: T | null | undefined, message?: string): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(message ?? `Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n", "import { CustomFunctionMeta } from \"@plasmicapp/host/registerFunction\";\nimport { QueryOperator, queryOperators } from \"./utils\";\n\nexport async function queryWordpress(\n wordpressUrl: string,\n type: \"pages\" | \"posts\",\n queryOperator?: QueryOperator,\n filterValue?: string,\n limit?: number\n): Promise<any> {\n const urlParams = new URLSearchParams();\n if (queryOperator && filterValue) {\n urlParams.append(queryOperator, filterValue);\n }\n if (limit) {\n urlParams.append(\"per_page\", limit.toString());\n }\n const urlWithSlash = wordpressUrl.endsWith(\"/\")\n ? wordpressUrl\n : `${wordpressUrl}/`;\n const url = new URL(`wp-json/wp/v2/${type}`, urlWithSlash);\n url.search = urlParams.toString();\n\n const resp = await fetch(url);\n return await resp.json();\n}\n\nexport const queryWordpressMeta: CustomFunctionMeta<typeof queryWordpress> = {\n name: \"queryWordpress\",\n displayName: \"Query WordPress\",\n importPath: \"@plasmicpkgs/wordpress\",\n params: [\n {\n name: \"wordpressUrl\",\n type: \"string\",\n },\n {\n name: \"queryType\",\n type: \"choice\",\n options: [\"pages\", \"posts\"],\n },\n {\n name: \"queryOperator\",\n type: \"choice\",\n options: Object.values(queryOperators).map((item) => ({\n label: item.label,\n value: item.value,\n })),\n },\n {\n name: \"filterValue\",\n type: \"string\",\n },\n {\n name: \"limit\",\n type: \"number\",\n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,QACpD,OAAO,KAAK;AAAA,QACZ,OAAO,KAAK;AAAA,MACd,EAAE;AAAA,IACJ;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AACF;;;AFrDO,SAAS,kBAAkB,QAAoC;AACpE,WAAS,kBACP,IACA,MACA;AACA,QAAI,QAAQ;AACV,aAAO,iBAAiB,IAAI,IAAI;AAAA,IAClC,OAAO;AACL,uBAAiB,IAAI,IAAI;AAAA,IAC3B;AAAA,EACF;AAEA,oBAAkB,gBAAgB,kBAAkB;AACtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/index.ts
|
|
51
|
+
var src_exports = {};
|
|
52
|
+
__export(src_exports, {
|
|
53
|
+
_ensure: () => ensure,
|
|
54
|
+
_queryOperators: () => queryOperators,
|
|
55
|
+
queryWordpress: () => queryWordpress,
|
|
56
|
+
registerWordpress: () => registerWordpress
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(src_exports);
|
|
59
|
+
var import_registerFunction = __toESM(require("@plasmicapp/host/registerFunction"));
|
|
60
|
+
|
|
61
|
+
// src/utils.ts
|
|
62
|
+
var queryOperators = [
|
|
63
|
+
{
|
|
64
|
+
value: "search",
|
|
65
|
+
label: "Search"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: "slug",
|
|
69
|
+
label: "Filter by Slug"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: "author",
|
|
73
|
+
label: "Filter by author"
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
function ensure(x, message) {
|
|
77
|
+
if (x === null || x === void 0) {
|
|
78
|
+
debugger;
|
|
79
|
+
throw new Error(message != null ? message : `Value must not be undefined or null`);
|
|
80
|
+
} else {
|
|
81
|
+
return x;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/query-wordpress.ts
|
|
86
|
+
function queryWordpress(wordpressUrl, type, queryOperator, filterValue, limit) {
|
|
87
|
+
return __async(this, null, function* () {
|
|
88
|
+
const urlParams = new URLSearchParams();
|
|
89
|
+
if (queryOperator && filterValue) {
|
|
90
|
+
urlParams.append(queryOperator, filterValue);
|
|
91
|
+
}
|
|
92
|
+
if (limit) {
|
|
93
|
+
urlParams.append("per_page", limit.toString());
|
|
94
|
+
}
|
|
95
|
+
const urlWithSlash = wordpressUrl.endsWith("/") ? wordpressUrl : `${wordpressUrl}/`;
|
|
96
|
+
const url = new URL(`wp-json/wp/v2/${type}`, urlWithSlash);
|
|
97
|
+
url.search = urlParams.toString();
|
|
98
|
+
const resp = yield fetch(url);
|
|
99
|
+
return yield resp.json();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var queryWordpressMeta = {
|
|
103
|
+
name: "queryWordpress",
|
|
104
|
+
displayName: "Query WordPress",
|
|
105
|
+
importPath: "@plasmicpkgs/wordpress",
|
|
106
|
+
params: [
|
|
107
|
+
{
|
|
108
|
+
name: "wordpressUrl",
|
|
109
|
+
type: "string"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "queryType",
|
|
113
|
+
type: "choice",
|
|
114
|
+
options: ["pages", "posts"]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "queryOperator",
|
|
118
|
+
type: "choice",
|
|
119
|
+
options: Object.values(queryOperators).map((item) => ({
|
|
120
|
+
label: item.label,
|
|
121
|
+
value: item.value
|
|
122
|
+
}))
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "filterValue",
|
|
126
|
+
type: "string"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "limit",
|
|
130
|
+
type: "number"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/index.ts
|
|
136
|
+
function registerWordpress(loader) {
|
|
137
|
+
function _registerFunction(fn, meta) {
|
|
138
|
+
if (loader) {
|
|
139
|
+
loader.registerFunction(fn, meta);
|
|
140
|
+
} else {
|
|
141
|
+
(0, import_registerFunction.default)(fn, meta);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
_registerFunction(queryWordpress, queryWordpressMeta);
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/utils.ts", "../src/query-wordpress.ts"],
|
|
4
|
+
"sourcesContent": ["import registerFunction, {\n CustomFunctionMeta,\n} from \"@plasmicapp/host/registerFunction\";\nimport { queryWordpress, queryWordpressMeta } from \"./query-wordpress\";\n\nexport function registerWordpress(loader?: { registerFunction: any }) {\n function _registerFunction<T extends (...args: any[]) => any>(\n fn: T,\n meta: CustomFunctionMeta<T>\n ) {\n if (loader) {\n loader.registerFunction(fn, meta);\n } else {\n registerFunction(fn, meta);\n }\n }\n\n _registerFunction(queryWordpress, queryWordpressMeta);\n}\n\nexport { queryWordpress };\n\n// used by @plasmicpkgs/plasmic-wordpress\nexport { ensure as _ensure, queryOperators as _queryOperators } from \"./utils\";\nexport type { QueryOperator as _QueryOperator } from \"./utils\";\n", "export const queryOperators = [\n {\n value: \"search\",\n label: \"Search\",\n },\n {\n value: \"slug\",\n label: \"Filter by Slug\",\n },\n {\n value: \"author\",\n label: \"Filter by author\",\n },\n] as const;\n\nexport type QueryOperator = (typeof queryOperators)[number][\"value\"];\n\nexport function ensure<T>(x: T | null | undefined, message?: string): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(message ?? `Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n", "import { CustomFunctionMeta } from \"@plasmicapp/host/registerFunction\";\nimport { QueryOperator, queryOperators } from \"./utils\";\n\nexport async function queryWordpress(\n wordpressUrl: string,\n type: \"pages\" | \"posts\",\n queryOperator?: QueryOperator,\n filterValue?: string,\n limit?: number\n): Promise<any> {\n const urlParams = new URLSearchParams();\n if (queryOperator && filterValue) {\n urlParams.append(queryOperator, filterValue);\n }\n if (limit) {\n urlParams.append(\"per_page\", limit.toString());\n }\n const urlWithSlash = wordpressUrl.endsWith(\"/\")\n ? wordpressUrl\n : `${wordpressUrl}/`;\n const url = new URL(`wp-json/wp/v2/${type}`, urlWithSlash);\n url.search = urlParams.toString();\n\n const resp = await fetch(url);\n return await resp.json();\n}\n\nexport const queryWordpressMeta: CustomFunctionMeta<typeof queryWordpress> = {\n name: \"queryWordpress\",\n displayName: \"Query WordPress\",\n importPath: \"@plasmicpkgs/wordpress\",\n params: [\n {\n name: \"wordpressUrl\",\n type: \"string\",\n },\n {\n name: \"queryType\",\n type: \"choice\",\n options: [\"pages\", \"posts\"],\n },\n {\n name: \"queryOperator\",\n type: \"choice\",\n options: Object.values(queryOperators).map((item) => ({\n label: item.label,\n value: item.value,\n })),\n },\n {\n name: \"filterValue\",\n type: \"string\",\n },\n {\n name: \"limit\",\n type: \"number\",\n },\n ],\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAEO;;;ACFA,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO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,EACF;AACF;;;AFrDO,SAAS,kBAAkB,QAAoC;AACpE,WAAS,kBACP,IACA,MACA;AACA,QAAI,QAAQ;AACV,aAAO,iBAAiB,IAAI,IAAI;AAAA,IAClC,OAAO;AACL,kCAAAA,SAAiB,IAAI,IAAI;AAAA,IAC3B;AAAA,EACF;AAEA,oBAAkB,gBAAgB,kBAAkB;AACtD;",
|
|
6
|
+
"names": ["registerFunction"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plasmicpkgs/wordpress",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Plasmic registration for WordPress",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/plasmicapp/plasmic.git",
|
|
8
|
+
"directory": "plasmicpkgs/wordpress"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"module": "./dist/index.esm.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.esm.js",
|
|
20
|
+
"require": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn build:types && yarn build:index",
|
|
28
|
+
"build:types": "yarn tsc",
|
|
29
|
+
"build:index": "node ../../build.mjs ./src/index.ts",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"prepublishOnly": "npm run build",
|
|
32
|
+
"postpublish": "bash ../../scripts/publish-api-doc-model.sh"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@plasmicapp/host": "1.0.226",
|
|
36
|
+
"typescript": "^5.7.3",
|
|
37
|
+
"vitest": "3.2.4"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@plasmicapp/host": "^1.0.211"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "271df799332249e475d73cb1414b5174c32bb0b8"
|
|
43
|
+
}
|