@plaidev/karte-action-sdk 1.1.99 → 1.1.100-27899110.44bc6d7c
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/dist/templates.d.ts +4 -0
- package/dist/templates.js +107 -0
- package/package.json +22 -3
@@ -0,0 +1,107 @@
|
|
1
|
+
function createAppScript(script = '') {
|
2
|
+
return `\
|
3
|
+
<script lang="ts">
|
4
|
+
// SDK generated imports: DON'T TOUCH THIS
|
5
|
+
// @ts-ignore
|
6
|
+
import type { ActionProps, CustomVariables } from "@plaidev/karte-action-sdk";
|
7
|
+
import type { Data, Props, Variables } from './gen';
|
8
|
+
import { onMount } from 'svelte';
|
9
|
+
import { writable } from 'svelte/store';
|
10
|
+
import {
|
11
|
+
// functions
|
12
|
+
// opened,
|
13
|
+
state,
|
14
|
+
customVariables,
|
15
|
+
|
16
|
+
// Layout
|
17
|
+
State,
|
18
|
+
StateItem,
|
19
|
+
Modal,
|
20
|
+
Grid,
|
21
|
+
GridItem,
|
22
|
+
List,
|
23
|
+
ListItem,
|
24
|
+
|
25
|
+
// Elements
|
26
|
+
TextElement,
|
27
|
+
ImageElement,
|
28
|
+
TextButtonElement,
|
29
|
+
EmbedElement,
|
30
|
+
|
31
|
+
// svelte-ignore unused-export-let @ts-ignore
|
32
|
+
} from '@plaidev/karte-action-sdk';
|
33
|
+
// svelte-ignore unused-export-let @ts-ignore
|
34
|
+
|
35
|
+
export let send: (event_name: string, values?: any) => void;
|
36
|
+
let data_: Data;
|
37
|
+
export { data_ as data };
|
38
|
+
let data = writable<Data & CustomVariables>({ ...data_ });
|
39
|
+
export let close: () => void;
|
40
|
+
export let onShow: (props: ActionProps<Props, Variables>) => void = _props => {};
|
41
|
+
export let onChangeState: (props: ActionProps<Props, Variables>, stateId: string) => void = (_props, _state) => {};
|
42
|
+
${script}
|
43
|
+
onMount(() => {
|
44
|
+
onShow({ send, data: $data });
|
45
|
+
});
|
46
|
+
|
47
|
+
// $: {
|
48
|
+
// if (!$opened) {
|
49
|
+
// close();
|
50
|
+
// }
|
51
|
+
// }
|
52
|
+
|
53
|
+
$: {
|
54
|
+
if ($state) {
|
55
|
+
onChangeState({ send, data: $data }, $state);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
$: {
|
60
|
+
data.update(current => {
|
61
|
+
return { ...current, ...$customVariables };
|
62
|
+
});
|
63
|
+
}
|
64
|
+
</script>`;
|
65
|
+
}
|
66
|
+
function createIndexTsx(script = '') {
|
67
|
+
return `\
|
68
|
+
import type { KarteAction, Send, Props, Variables } from "./gen";
|
69
|
+
|
70
|
+
import "https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver";
|
71
|
+
import { initialize, finalize, create } from "@plaidev/karte-action-sdk";
|
72
|
+
|
73
|
+
import { props } from "./gen";
|
74
|
+
import App from "./App.svelte";
|
75
|
+
import onCreate from "./customScript";
|
76
|
+
${script}
|
77
|
+
const action = (options: { send: Send; props: Props; variables: Variables }): KarteAction => {
|
78
|
+
initialize({ send: options.send });
|
79
|
+
|
80
|
+
return create(App, {
|
81
|
+
props,
|
82
|
+
send: options.send,
|
83
|
+
variables: options.variables,
|
84
|
+
onCreate,
|
85
|
+
onClose: () => finalize(),
|
86
|
+
});
|
87
|
+
};
|
88
|
+
|
89
|
+
export default action;`;
|
90
|
+
}
|
91
|
+
function createCustomScript(script = '') {
|
92
|
+
return `\
|
93
|
+
/**
|
94
|
+
* アクションをカスタマイズするスクリプト
|
95
|
+
*/
|
96
|
+
// ここでSDKをインポートしてください
|
97
|
+
//import jQuery from "jquery";
|
98
|
+
//import { onShow, onClose, onChangeState, onDestroy, customVariables } from "@plaidev/karte-action-sdk";
|
99
|
+
${script}
|
100
|
+
const onCreate = ({ send, data }) => {
|
101
|
+
// ここでアクションが作成される時のスクリプトを書いてください
|
102
|
+
};
|
103
|
+
|
104
|
+
export default onCreate;`;
|
105
|
+
}
|
106
|
+
|
107
|
+
export { createAppScript, createCustomScript, createIndexTsx };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@plaidev/karte-action-sdk",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.100-27899110.44bc6d7c",
|
4
4
|
"author": "Plaid Inc.",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"module": "./dist/index.es.js",
|
@@ -17,9 +17,26 @@
|
|
17
17
|
"import": "./dist/hydrate/index.es.js",
|
18
18
|
"types": "./dist/hydrate/index.es.d.ts"
|
19
19
|
},
|
20
|
+
"./templates": {
|
21
|
+
"import": "./dist/templates.js",
|
22
|
+
"types": "./dist/templates.d.ts"
|
23
|
+
},
|
20
24
|
"./package.json": "./package.json",
|
21
25
|
"./dist/*": "./dist/*"
|
22
26
|
},
|
27
|
+
"typesVersions": {
|
28
|
+
"*": {
|
29
|
+
"hydrate": [
|
30
|
+
"./dist/hydrate/index.es.d.ts"
|
31
|
+
],
|
32
|
+
"templates": [
|
33
|
+
"./dist/templates.d.ts"
|
34
|
+
],
|
35
|
+
"*": [
|
36
|
+
"./dist/index.es.d.ts"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
},
|
23
40
|
"files": [
|
24
41
|
"dist",
|
25
42
|
"index.mjs",
|
@@ -37,8 +54,10 @@
|
|
37
54
|
"@sveltejs/vite-plugin-svelte": "1.0.0-next.37",
|
38
55
|
"@testing-library/svelte": "^3.1.3",
|
39
56
|
"@tsconfig/svelte": "^2.0.1",
|
57
|
+
"@types/brotli": "^1.3.1",
|
40
58
|
"@types/serve-static": "^1.13.10",
|
41
59
|
"@vitest/ui": "latest",
|
60
|
+
"brotli": "^1.3.3",
|
42
61
|
"c8": "^7.12.0",
|
43
62
|
"happy-dom": "^6.0.3",
|
44
63
|
"isomorphic-fetch": "3.0.0",
|
@@ -74,8 +93,8 @@
|
|
74
93
|
"setup:concat": "jiti ./scripts/concat.ts",
|
75
94
|
"setup:compile": "jiti ./scripts/compile.ts",
|
76
95
|
"prepare": "npm run setup:default && npm run setup:template && npm run setup:concat",
|
77
|
-
"build": "rollup -
|
78
|
-
"build:watch": "rollup -
|
96
|
+
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-ts",
|
97
|
+
"build:watch": "rollup --config rollup.config.ts --configPlugin rollup-plugin-ts -w",
|
79
98
|
"check:svelte": "svelte-check --tsconfig ./tsconfig.json",
|
80
99
|
"check:type": "tsc --noEmit",
|
81
100
|
"test": "vitest run test",
|