debug / SubscribeWorkflow Demo

push: … caps: none

Modal workflows — showModal()

#1 Full workflow

Push required + email optional (form mode) + pwa optional. The most common setup for a book gate.

.require('push', { grants:['read','book-download'],
           label:'🔔 أريد الكتب المجانية' })
.optional('email', { emailMode:'form' })
.optional('pwa',   { label:'📲 أضف للشاشة' })
.onComplete(fn)
.showModal()
#2 Push-only

Single required push channel. No email or PWA. Resolves to mode:'push-only'.

.require('push', {
   label: '🔔 اشترك للوصول',
   grants: ['read', 'notifications']
})
.showModal()
#3 Email-only (form)

Email required, inline form injected by EmailSubscribe. Resolves to mode:'email-only'.

.require('email', {
   label: '📧 اشترك عبر البريد',
   emailMode: 'form'
})
.showModal()
#4 Email-only (link)

Email required as a plain link to the subscribe page. No inline form.

.require('email', {
   label: 'أو عبر البريد الإلكتروني',
   emailMode: 'link',
   url: '/subscribe-direct'
})
.showModal()
#5 Both required

Push AND email are both required. Resolves to mode:'both' — shown together.

.require('push',  { label: '🔔 بالإشعارات' })
.require('email', {
   label: '📧 والبريد الإلكتروني',
   emailMode: 'form'
})
.showModal()
#6 Sequential

Push required, email optional link. After push subscribes, email follow-up appears inline. Resolves to mode:'sequential'.

.require('push',  { label: '🔔 اشترك بالإشعارات' })
.optional('email',{ label: 'أو عبر البريد' })
.showModal()
#7 Push + PWA

Push required, PWA optional. PWA button appears if deferredPrompt is available.

.require('push', {
   label: '🔔 اشترك للوصول',
   grants: ['read', 'book-download',
            'post-download', 'notifications']
})
.optional('pwa', {
   label: '📲 أضف التطبيق للشاشة الرئيسية'
})
.showModal()
#8 Full options + onComplete

All text overrides set explicitly. onComplete logs to debug panel instead of reloading.

.title('🔓 افتح المحتوى الحصري')
.desc('اشترك مجاناً للوصول الفوري...')
.require('push', {
   label: '🔔 فعّل الإشعارات',
   grants: ['read', 'notifications']
})
.optional('email', {
   label: 'أو عبر البريد الإلكتروني',
   emailMode: 'form'
})
.onComplete(() => log('✅ onComplete fired!'))
.showModal()

Inline render — renderInto(el)

#9 renderInto() — inline card

Renders the workflow as an inline GateCard into the slot below. Useful for embedding a subscribe CTA mid-page.

.title('اقرأ بلا حدود')
.require('push',  { label: '🔔 احصل على الوصول المجاني' })
.optional('email',{ emailMode: 'form' })
.onComplete(() => log('inline onComplete!'))
.renderInto(document.getElementById('inline-slot'))
slot empty — click ▶ renderInto() above

Raw opts — toGateCardOpts()

#10 Inspect resolved GateCard opts

Call toGateCardOpts() on any workflow without rendering. Shows the exact object passed to GateCard — useful for debugging mode resolution.

// click a button above