@plaidev/karte-action-sdk 1.1.151 → 1.1.152
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.cjs.d.ts +29 -1
- package/dist/templates.cjs.js +47 -13
- package/dist/templates.d.ts +29 -1
- package/dist/templates.js +47 -14
- package/package.json +1 -1
package/dist/templates.cjs.d.ts
CHANGED
@@ -1,7 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* 最新SDKに対応したアクションコードを生成する関数群
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* アクションのアプリコード(App.svelte)の初期値の生成
|
6
|
+
*
|
7
|
+
* @internal
|
8
|
+
*/
|
1
9
|
declare function createAppScript(script?: string, icons?: string[]): string;
|
10
|
+
/**
|
11
|
+
* アクションのエントリーコード(index.tsx)の初期値の生成
|
12
|
+
*
|
13
|
+
* @internal
|
14
|
+
*/
|
2
15
|
declare function createIndexTsx({ script, polyfill, }?: {
|
3
16
|
script?: string;
|
4
17
|
polyfill?: boolean;
|
5
18
|
}): string;
|
19
|
+
/**
|
20
|
+
* 後方互換のためのカスタムスクリプトの初期値の生成
|
21
|
+
*
|
22
|
+
* customScript.tsが存在しない場合の後方互換コードを生成する。
|
23
|
+
* 実際のコードはアクションテンプレートごとに異なるため、この関数で生成するコードを不用意に初期値にしないこと。
|
24
|
+
*
|
25
|
+
* export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない。
|
26
|
+
* 標準以外の使い方をするケースはサポートドキュメントでフォローする。
|
27
|
+
*
|
28
|
+
* @internal
|
29
|
+
*/
|
30
|
+
declare function createCompatibleCustomScript({ script, templateType, }?: {
|
31
|
+
script?: string;
|
32
|
+
templateType?: 'webpopup' | 'script';
|
33
|
+
}): string;
|
6
34
|
declare function createCustomScript(script?: string): string;
|
7
|
-
export { createAppScript, createIndexTsx, createCustomScript };
|
35
|
+
export { createAppScript, createIndexTsx, createCompatibleCustomScript, createCustomScript };
|
package/dist/templates.cjs.js
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
/**
|
4
|
+
* 最新SDKに対応したアクションコードを生成する関数群
|
5
|
+
*/
|
6
|
+
/**
|
7
|
+
* アクションのアプリコード(App.svelte)の初期値の生成
|
8
|
+
*
|
9
|
+
* @internal
|
10
|
+
*/
|
3
11
|
function createAppScript(script = '', icons = []) {
|
4
12
|
// TODO: `script` should be validated!
|
5
13
|
return `<script lang="ts">
|
6
|
-
//
|
7
|
-
|
8
|
-
import type { ActionProps, ActionVariables } from "@plaidev/karte-action-sdk";
|
14
|
+
// DON'T TOUCH THIS: SDK generates the following imports
|
15
|
+
import type { ActionProps, ActionVariables } from '@plaidev/karte-action-sdk';
|
9
16
|
import type { Data, Props, Variables } from './gen';
|
10
17
|
import { onMount } from 'svelte';
|
11
18
|
import { writable } from 'svelte/store';
|
@@ -65,15 +72,20 @@ $: {
|
|
65
72
|
}
|
66
73
|
</script>`;
|
67
74
|
}
|
75
|
+
/**
|
76
|
+
* アクションのエントリーコード(index.tsx)の初期値の生成
|
77
|
+
*
|
78
|
+
* @internal
|
79
|
+
*/
|
68
80
|
function createIndexTsx({ script = '', polyfill = false, } = {}) {
|
69
81
|
// TODO: `script` should be validated!
|
70
|
-
return `import type { KarteAction, Send, Publish, Props, Variables } from
|
71
|
-
${polyfill ? `import
|
72
|
-
import { create } from
|
82
|
+
return `import type { KarteAction, Send, Publish, Props, Variables } from './gen';
|
83
|
+
${polyfill ? `import 'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver';` : ''}
|
84
|
+
import { create } from '@plaidev/karte-action-sdk';
|
73
85
|
|
74
|
-
import { props, localVariablesQuery } from
|
75
|
-
import App from
|
76
|
-
import onCreate from
|
86
|
+
import { props, localVariablesQuery } from './gen';
|
87
|
+
import App from './App.svelte';
|
88
|
+
import onCreate from './customScript';
|
77
89
|
${script}
|
78
90
|
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
|
79
91
|
return create(App, {
|
@@ -88,19 +100,41 @@ const action = (options: { send: Send; publish: Publish, props: Props; variables
|
|
88
100
|
|
89
101
|
export default action;`;
|
90
102
|
}
|
91
|
-
|
92
|
-
|
93
|
-
|
103
|
+
/**
|
104
|
+
* 後方互換のためのカスタムスクリプトの初期値の生成
|
105
|
+
*
|
106
|
+
* customScript.tsが存在しない場合の後方互換コードを生成する。
|
107
|
+
* 実際のコードはアクションテンプレートごとに異なるため、この関数で生成するコードを不用意に初期値にしないこと。
|
108
|
+
*
|
109
|
+
* export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない。
|
110
|
+
* 標準以外の使い方をするケースはサポートドキュメントでフォローする。
|
111
|
+
*
|
112
|
+
* @internal
|
113
|
+
*/
|
114
|
+
function createCompatibleCustomScript({ script = '', templateType = 'webpopup', } = {}) {
|
94
115
|
// TODO: `script` should be validated!
|
116
|
+
if (templateType === 'script') {
|
117
|
+
return `\
|
118
|
+
${script}
|
119
|
+
export default ({ send, data }) => {
|
120
|
+
// ここにスクリプトを書いてください
|
121
|
+
};`;
|
122
|
+
}
|
95
123
|
return `\
|
96
|
-
import { showAction } from
|
124
|
+
import { showAction } from '@plaidev/karte-action-sdk';
|
97
125
|
${script}
|
98
126
|
export default ({ send, data }) => {
|
99
127
|
// ここにスクリプトを書いてください
|
100
128
|
showAction();
|
101
129
|
};`;
|
102
130
|
}
|
131
|
+
// 以下は後方互換。action-editor-frontをデプロイしたら削除可能。
|
132
|
+
// @internal
|
133
|
+
function createCustomScript(script = '') {
|
134
|
+
return createCompatibleCustomScript({ script });
|
135
|
+
}
|
103
136
|
|
104
137
|
exports.createAppScript = createAppScript;
|
138
|
+
exports.createCompatibleCustomScript = createCompatibleCustomScript;
|
105
139
|
exports.createCustomScript = createCustomScript;
|
106
140
|
exports.createIndexTsx = createIndexTsx;
|
package/dist/templates.d.ts
CHANGED
@@ -1,7 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* 最新SDKに対応したアクションコードを生成する関数群
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* アクションのアプリコード(App.svelte)の初期値の生成
|
6
|
+
*
|
7
|
+
* @internal
|
8
|
+
*/
|
1
9
|
declare function createAppScript(script?: string, icons?: string[]): string;
|
10
|
+
/**
|
11
|
+
* アクションのエントリーコード(index.tsx)の初期値の生成
|
12
|
+
*
|
13
|
+
* @internal
|
14
|
+
*/
|
2
15
|
declare function createIndexTsx({ script, polyfill, }?: {
|
3
16
|
script?: string;
|
4
17
|
polyfill?: boolean;
|
5
18
|
}): string;
|
19
|
+
/**
|
20
|
+
* 後方互換のためのカスタムスクリプトの初期値の生成
|
21
|
+
*
|
22
|
+
* customScript.tsが存在しない場合の後方互換コードを生成する。
|
23
|
+
* 実際のコードはアクションテンプレートごとに異なるため、この関数で生成するコードを不用意に初期値にしないこと。
|
24
|
+
*
|
25
|
+
* export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない。
|
26
|
+
* 標準以外の使い方をするケースはサポートドキュメントでフォローする。
|
27
|
+
*
|
28
|
+
* @internal
|
29
|
+
*/
|
30
|
+
declare function createCompatibleCustomScript({ script, templateType, }?: {
|
31
|
+
script?: string;
|
32
|
+
templateType?: 'webpopup' | 'script';
|
33
|
+
}): string;
|
6
34
|
declare function createCustomScript(script?: string): string;
|
7
|
-
export { createAppScript, createIndexTsx, createCustomScript };
|
35
|
+
export { createAppScript, createIndexTsx, createCompatibleCustomScript, createCustomScript };
|
package/dist/templates.js
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* 最新SDKに対応したアクションコードを生成する関数群
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* アクションのアプリコード(App.svelte)の初期値の生成
|
6
|
+
*
|
7
|
+
* @internal
|
8
|
+
*/
|
1
9
|
function createAppScript(script = '', icons = []) {
|
2
10
|
// TODO: `script` should be validated!
|
3
11
|
return `<script lang="ts">
|
4
|
-
//
|
5
|
-
|
6
|
-
import type { ActionProps, ActionVariables } from "@plaidev/karte-action-sdk";
|
12
|
+
// DON'T TOUCH THIS: SDK generates the following imports
|
13
|
+
import type { ActionProps, ActionVariables } from '@plaidev/karte-action-sdk';
|
7
14
|
import type { Data, Props, Variables } from './gen';
|
8
15
|
import { onMount } from 'svelte';
|
9
16
|
import { writable } from 'svelte/store';
|
@@ -63,15 +70,20 @@ $: {
|
|
63
70
|
}
|
64
71
|
</script>`;
|
65
72
|
}
|
73
|
+
/**
|
74
|
+
* アクションのエントリーコード(index.tsx)の初期値の生成
|
75
|
+
*
|
76
|
+
* @internal
|
77
|
+
*/
|
66
78
|
function createIndexTsx({ script = '', polyfill = false, } = {}) {
|
67
79
|
// TODO: `script` should be validated!
|
68
|
-
return `import type { KarteAction, Send, Publish, Props, Variables } from
|
69
|
-
${polyfill ? `import
|
70
|
-
import { create } from
|
80
|
+
return `import type { KarteAction, Send, Publish, Props, Variables } from './gen';
|
81
|
+
${polyfill ? `import 'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver';` : ''}
|
82
|
+
import { create } from '@plaidev/karte-action-sdk';
|
71
83
|
|
72
|
-
import { props, localVariablesQuery } from
|
73
|
-
import App from
|
74
|
-
import onCreate from
|
84
|
+
import { props, localVariablesQuery } from './gen';
|
85
|
+
import App from './App.svelte';
|
86
|
+
import onCreate from './customScript';
|
75
87
|
${script}
|
76
88
|
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
|
77
89
|
return create(App, {
|
@@ -86,17 +98,38 @@ const action = (options: { send: Send; publish: Publish, props: Props; variables
|
|
86
98
|
|
87
99
|
export default action;`;
|
88
100
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
101
|
+
/**
|
102
|
+
* 後方互換のためのカスタムスクリプトの初期値の生成
|
103
|
+
*
|
104
|
+
* customScript.tsが存在しない場合の後方互換コードを生成する。
|
105
|
+
* 実際のコードはアクションテンプレートごとに異なるため、この関数で生成するコードを不用意に初期値にしないこと。
|
106
|
+
*
|
107
|
+
* export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない。
|
108
|
+
* 標準以外の使い方をするケースはサポートドキュメントでフォローする。
|
109
|
+
*
|
110
|
+
* @internal
|
111
|
+
*/
|
112
|
+
function createCompatibleCustomScript({ script = '', templateType = 'webpopup', } = {}) {
|
92
113
|
// TODO: `script` should be validated!
|
114
|
+
if (templateType === 'script') {
|
115
|
+
return `\
|
116
|
+
${script}
|
117
|
+
export default ({ send, data }) => {
|
118
|
+
// ここにスクリプトを書いてください
|
119
|
+
};`;
|
120
|
+
}
|
93
121
|
return `\
|
94
|
-
import { showAction } from
|
122
|
+
import { showAction } from '@plaidev/karte-action-sdk';
|
95
123
|
${script}
|
96
124
|
export default ({ send, data }) => {
|
97
125
|
// ここにスクリプトを書いてください
|
98
126
|
showAction();
|
99
127
|
};`;
|
100
128
|
}
|
129
|
+
// 以下は後方互換。action-editor-frontをデプロイしたら削除可能。
|
130
|
+
// @internal
|
131
|
+
function createCustomScript(script = '') {
|
132
|
+
return createCompatibleCustomScript({ script });
|
133
|
+
}
|
101
134
|
|
102
|
-
export { createAppScript, createCustomScript, createIndexTsx };
|
135
|
+
export { createAppScript, createCompatibleCustomScript, createCustomScript, createIndexTsx };
|